OpenTTD Source: OpenGLSprite Class Reference

OpenTTD Source 13.2.1

Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
OpenGLSprite Class Reference

Class that encapsulates a RGBA texture together with a paletted remap texture. More...

`#include <opengl.h>`

## Public Member Functions
| OpenGLSprite (uint width, uint height, uint levels, SpriteColourComponent components)
| Create an OpenGL sprite with a palette remap part. More...
void | Update (uint width, uint height, uint level, const SpriteLoader::CommonPixel *data)
| Update a single mip-map level with new pixel data. More...
Dimension | GetSize (ZoomLevel level) const
| Query the sprite size at a certain zoom level. More...

## Private Types
enum | Texture { 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. More...

## Static Private Member Functions
static bool | Create ()
| Create all common resources for sprite rendering. More...
static void | Destroy ()
| Free all common resources for sprite rendering.

## Private Attributes
Dimension | dim
GLuint | tex [NUM_TEX]
| The texture objects.

## Static Private Attributes
static GLuint | dummy_tex [NUM_TEX] = { 0, 0 }
| 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

## Detailed Description

Class that encapsulates a RGBA texture together with a paletted remap texture.

Definition at line 117 of file opengl.h.

## Member Enumeration Documentation

## ◆ Texture

enum OpenGLSprite::Texture
| private

Enum of all used OpenGL texture objects.

Enumerator
TEX_RGBA | RGBA texture part.
TEX_REMAP | Remap texture part.

Definition at line 120 of file opengl.h.

## Constructor & Destructor Documentation

## ◆ OpenGLSprite()

OpenGLSprite::OpenGLSprite | ( | uint | width,
|  | uint | height,
|  | uint | levels,
|  | SpriteColourComponent | components
| ) |  |

Create an OpenGL sprite with a palette remap part.

Parameters

  width | Width of the top-level texture.
  height | Height of the top-level texture.
  levels | Number of mip-map levels.
  components | Indicates which sprite components are used.

Definition at line 1430 of file opengl.cpp.

References MemSetT(), SCC_PAL, tex, TEX_REMAP, and TEX_RGBA.

## Member Function Documentation

## ◆ BindTextures()

bool OpenGLSprite::BindTextures | ( |  | ) |
| private

Bind textures for rendering this sprite.

Returns
  True if the sprite has RGBA data.

Definition at line 1540 of file opengl.cpp.

References tex, TEX_REMAP, and TEX_RGBA.

## ◆ Create()

bool OpenGLSprite::Create | ( |  | ) |
| staticprivate

Create all common resources for sprite rendering.

Returns
  True if no error occurred.

Definition at line 1354 of file opengl.cpp.

References dummy_tex, pal_identity, pal_pbo, pal_tex, TEX_REMAP, and TEX_RGBA.

## ◆ GetSize()

Dimension OpenGLSprite::GetSize | ( | ZoomLevel | level | ) | const
| inline

Query the sprite size at a certain zoom level.

Parameters

  level | The zoom level to query.

Returns
  Sprite size at the given zoom level.

Definition at line 1530 of file opengl.cpp.

## ◆ Update()

void OpenGLSprite::Update | ( | uint | width,
|  | uint | height,
|  | uint | level,
|  | const SpriteLoader::CommonPixel * | data
| ) |  |

Update a single mip-map level with new pixel data.

Parameters

  width | Width of the level.
  height | Height of the level.
  level | Mip-map level.
  data | New pixel data.

Definition at line 1483 of file opengl.cpp.

References SpriteLoader::CommonPixel::a, Colour::a, Align(), ReusableBuffer< T >::Allocate(), SpriteLoader::CommonPixel::b, SpriteLoader::CommonPixel::g, SpriteLoader::CommonPixel::r, tex, TEX_REMAP, and TEX_RGBA.

The documentation for this class was generated from the following files:

- src/video/opengl.h
- src/video/opengl.cpp