OpenTTD Source 20250501-master-ga30f251d05
|
Class that encapsulates a RGBA texture together with a paletted remap texture. More...
#include <opengl.h>
Public Member Functions | |
OpenGLSprite (const SpriteLoader::SpriteCollection &sprite) | |
Create an OpenGL sprite with a palette remap part. | |
OpenGLSprite (const OpenGLSprite &)=delete | |
OpenGLSprite (OpenGLSprite &&)=delete | |
OpenGLSprite & | operator= (const OpenGLSprite &)=delete |
OpenGLSprite & | operator= (OpenGLSprite &&)=delete |
void | Update (uint width, uint height, uint level, const SpriteLoader::CommonPixel *data) |
Update a single mip-map level with new pixel data. | |
Dimension | GetSize (ZoomLevel level) const |
Query the sprite size at a certain zoom level. | |
Private Types | |
enum | Texture : uint8_t { TEX_RGBA , TEX_REMAP , NUM_TEX } |
Enum of all used OpenGL texture objects. More... | |
Private Member Functions | |
bool | BindTextures () |
Bind textures for rendering this sprite. | |
Static Private Member Functions | |
static bool | Create () |
Create all common resources for sprite rendering. | |
static void | Destroy () |
Free all common resources for sprite rendering. | |
Private Attributes | |
Dimension | dim {} |
std::array< GLuint, NUM_TEX > | tex {} |
The texture objects. | |
int16_t | x_offs = 0 |
Number of pixels to shift the sprite to the right. | |
int16_t | y_offs = 0 |
Number of pixels to shift the sprite downwards. | |
Static Private Attributes | |
static std::array< GLuint, NUM_TEX > | dummy_tex {} |
1x1 dummy textures to substitute for unused sprite components. | |
static GLuint | pal_identity = 0 |
Identity texture mapping. | |
static GLuint | pal_tex = 0 |
Texture for palette remap. | |
static GLuint | pal_pbo = 0 |
Pixel buffer object for remap upload. | |
Friends | |
class | OpenGLBackend |
Class that encapsulates a RGBA texture together with a paletted remap texture.
|
private |
OpenGLSprite::OpenGLSprite | ( | const SpriteLoader::SpriteCollection & | sprite | ) |
Create an OpenGL sprite with a palette remap part.
sprite | The sprite to create the OpenGL sprite for |
Definition at line 1403 of file opengl.cpp.
References Font, Palette, tex, TEX_REMAP, TEX_RGBA, Update(), ZOOM_LVL_END, and ZOOM_LVL_MIN.
OpenGLSprite::~OpenGLSprite | ( | ) |
Definition at line 1448 of file opengl.cpp.
|
private |
Bind textures for rendering this sprite.
Definition at line 1518 of file opengl.cpp.
References dummy_tex, tex, TEX_REMAP, and TEX_RGBA.
Referenced by OpenGLBackend::RenderOglSprite().
|
staticprivate |
Create all common resources for sprite rendering.
Definition at line 1330 of file opengl.cpp.
References dummy_tex, pal_identity, pal_pbo, pal_tex, TEX_REMAP, and TEX_RGBA.
Referenced by OpenGLBackend::Init().
|
staticprivate |
Free all common resources for sprite rendering.
Definition at line 1391 of file opengl.cpp.
References dummy_tex, pal_identity, pal_pbo, and pal_tex.
Referenced by OpenGLBackend::~OpenGLBackend().
Query the sprite size at a certain zoom level.
level | The zoom level to query. |
Definition at line 1508 of file opengl.cpp.
References UnScaleByZoomLower().
Referenced by OpenGLBackend::RenderOglSprite().
void OpenGLSprite::Update | ( | uint | width, |
uint | height, | ||
uint | level, | ||
const SpriteLoader::CommonPixel * | data | ||
) |
Update a single mip-map level with new pixel data.
width | Width of the level. |
height | Height of the level. |
level | Mip-map level. |
data | New pixel data. |
Definition at line 1460 of file opengl.cpp.
References SpriteLoader::CommonPixel::a, Align(), ReusableBuffer< T >::Allocate(), SpriteLoader::CommonPixel::b, SpriteLoader::CommonPixel::g, ReusableBuffer< T >::GetBuffer(), SpriteLoader::CommonPixel::m, SpriteLoader::CommonPixel::r, tex, TEX_REMAP, and TEX_RGBA.
Referenced by OpenGLSprite().
|
friend |
|
staticprivate |
1x1 dummy textures to substitute for unused sprite components.
Definition at line 1321 of file opengl.h.
Referenced by BindTextures(), Create(), and Destroy().
|
staticprivate |
Identity texture mapping.
Definition at line 130 of file opengl.h.
Referenced by Create(), Destroy(), and OpenGLBackend::RenderOglSprite().
|
staticprivate |
Pixel buffer object for remap upload.
Definition at line 132 of file opengl.h.
Referenced by Create(), Destroy(), and OpenGLBackend::RenderOglSprite().
|
staticprivate |
Texture for palette remap.
Definition at line 131 of file opengl.h.
Referenced by Create(), Destroy(), and OpenGLBackend::RenderOglSprite().
|
private |
The texture objects.
Definition at line 124 of file opengl.h.
Referenced by BindTextures(), OpenGLSprite(), and Update().
|
private |
Number of pixels to shift the sprite to the right.
Definition at line 125 of file opengl.h.
Referenced by OpenGLBackend::DrawMouseCursor().
|
private |
Number of pixels to shift the sprite downwards.
Definition at line 126 of file opengl.h.
Referenced by OpenGLBackend::DrawMouseCursor().