OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
12 #ifndef VIDEO_OPENGL_H
13 #define VIDEO_OPENGL_H
15 #include "../core/alloc_type.hpp"
16 #include "../core/geometry_type.hpp"
17 #include "../gfx_type.h"
18 #include "../spriteloader/spriteloader.hpp"
19 #include "../misc/lrucache.hpp"
21 typedef void (*OGLProc)();
22 typedef OGLProc (*GetOGLProcAddressProc)(
const char *proc);
81 static const char *
Create(GetOGLProcAddressProc get_proc);
84 void PrepareContext();
87 bool Resize(
int w,
int h,
bool force =
false);
GLsync sync_vid_mapping
Sync object for the persistently mapped video buffer.
void RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int x, int y, ZoomLevel zoom)
Render a sprite to the back buffer.
uint GetSpriteAlignment() override
Get the value which the height and width on a sprite have to be aligned by.
static GLuint pal_tex
Texture for palette remap.
GLuint pal_program
Shader program for rendering a paletted video buffer.
@ TEX_RGBA
RGBA texture part.
bool Is32BppSupported() override
Can the sprite encoder make use of RGBA sprites?
Dimensions (a width and height) of a rectangle in 2D.
Dimension GetSize(ZoomLevel level) const
Query the sprite size at a certain zoom level.
static GLuint pal_identity
Identity texture mapping.
static void Destroy()
Free all common resources for sprite rendering.
GLuint tex[NUM_TEX]
The texture objects.
OpenGLSprite(uint width, uint height, uint levels, SpriteColourComponent components)
Create an OpenGL sprite with a palette remap part.
@ TEX_REMAP
Remap texture part.
@ ZOOM_LVL_COUNT
Number of zoom levels.
void * vid_buffer
Pointer to the mapped video buffer.
ZoomLevel
All zoom levels we know.
static GLuint pal_pbo
Pixel buffer object for remap upload.
~OpenGLBackend()
Free allocated resources.
GLint sprite_zoom_loc
Uniform location for sprite zoom;.
static OpenGLBackend * Get()
Get singleton instance of this class.
GLuint anim_pbo
Pixel buffer object storing the memory used for the animation buffer.
Platform-independent back-end class for OpenGL video drivers.
GLuint vid_texture
Texture handle for the video buffer texture.
GLint remap_rgb_loc
Uniform location for RGB mode flag;.
void DrawMouseCursor()
Draw mouse cursor on screen.
PaletteID last_sprite_pal
Last uploaded remap palette.
void * anim_buffer
Pointer to the mapped animation buffer.
void ReleaseVideoBuffer(const Rect &update_rect)
Update video buffer texture after the video buffer was filled.
Base class that provides memory initialization on dynamically created objects.
GLuint vbo_quad
Vertex buffer with a fullscreen quad.
static bool Create()
Create all common resources for sprite rendering.
Definition of a common pixel in OpenTTD's realm.
void * GetVideoBuffer()
Get a pointer to the memory for the video driver to draw to.
static OpenGLBackend * instance
Singleton instance pointer.
GLuint anim_texture
Texture handle for the animation buffer texture.
GLint sprite_screen_loc
Uniform location for screen size;.
GLsync sync_anim_mapping
Sync object for the persistently mapped animation buffer.
static void Destroy()
Free resources and destroy singleton back-end class.
Interface for something that can encode a sprite.
bool persistent_mapping_supported
Persistent pixel buffer mapping supported.
LRUCache< SpriteID, Sprite > cursor_cache
Cache of encoded cursor sprites.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
GLuint vao_quad
Vertex array object storing the rendering state for the fullscreen quad.
static GLuint dummy_tex[NUM_TEX]
1x1 dummy textures to substitute for unused sprite components.
const char * Init()
Check for the needed OpenGL functionality and allocate all resources.
void ClearCursorCache()
Clear all cached cursor sprites.
void Update(uint width, uint height, uint level, const SpriteLoader::CommonPixel *data)
Update a single mip-map level with new pixel data.
GLuint pal_texture
Palette lookup texture.
const char * FindStringInExtensionList(const char *string, const char *substring)
Find a substring in a string made of space delimited elements.
uint32 PaletteID
The number of the palette.
GLint sprite_sprite_loc
Uniform location for sprite parameters.
Structure for passing information from the sprite loader to the blitter.
bool BindTextures()
Bind textures for rendering this sprite.
void Paint()
Render video buffer to the screen.
GLint remap_sprite_loc
Uniform location for sprite parameters.
void UpdatePalette(const Colour *pal, uint first, uint length)
Update the stored palette.
GLuint sprite_program
Shader program for blending and rendering a sprite to the video buffer.
GLint sprite_crash_loc
Uniform location for crash remap mode flag;.
Class that encapsulates a RGBA texture together with a paletted remap texture.
OpenGLBackend()
Construct OpenGL back-end class.
GLint sprite_rgb_loc
Uniform location for RGB mode flag;.
GLint remap_zoom_loc
Uniform location for sprite zoom;.
GLint remap_screen_loc
Uniform location for screen size;.
Specification of a rectangle with absolute coordinates of all edges.
GLuint vid_pbo
Pixel buffer object storing the memory used for the video driver to draw to.
Data structure describing a sprite.
void ReleaseAnimBuffer(const Rect &update_rect)
Update animation buffer texture after the animation buffer was filled.
GLuint remap_program
Shader program for blending and rendering a RGBA + remap texture.
GLuint vid_program
Shader program for rendering a RGBA video buffer.
bool Resize(int w, int h, bool force=false)
Change the size of the drawing window and allocate matching resources.
uint8 * GetAnimBuffer()
Get a pointer to the memory for the separate animation buffer.
Sprite * Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override
Convert a sprite from the loader to our own format.
bool IsOpenGLVersionAtLeast(byte major, byte minor)
Check if the current OpenGL version is equal or higher than a given one.
static const char * Create(GetOGLProcAddressProc get_proc)
Create and initialize the singleton back-end class.
bool InitShaders()
Create all needed shader programs.
SpriteColourComponent
The different colour components a sprite can have.
Texture
Enum of all used OpenGL texture objects.