afritz1 / OpenTESArena

Open-source re-implementation of The Elder Scrolls: Arena.
MIT License
915 stars 68 forks source link

Improve renderer-independent texture format handling, and initial work on indirect texture assets #192

Closed afritz1 closed 3 years ago

afritz1 commented 3 years ago

This reworks how the engine handles different renderer-independent texture formats. Instead of being explicit about 8-bit or 32-bit textures via Image and Surface/Texture, textures are represented with a TextureBuilder that contains the texels and texture format that is then passed to the renderer for conversion to an implementation-specific format for performance. Design changes to the TextureManager also allow for relatively easy loading of new texture formats like PNG.

The Renderer class now also takes TextureBuilderIDs and can internally manage Texture instances. This is a stopgap until it is able to return allocated texture handles like VoxelTextureID/UiTextureID/etc. to users of the renderer.

TextureAssetReference has also started being used in a few places. This is one step further beyond TextureBuilderID in that it does not assume that the referenced texture is in memory. This class is useful in more memory-constrained situations, especially if modding eventually allows for large textures like 1024x1024. Currently it is not very useful because DOS textures are relatively small in RAM.