Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 23 commits into from Jan 3, 2021

Conversation

afritz1
Copy link
Owner

@afritz1 afritz1 commented Jan 3, 2021

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.

Need to implement texture loading support for all formats in tryLoadTextureBuilders().
Going to keep it alongside TextureBuilderIdGroup and eventually delete the others.
Probably going to always pass a palette with texture builders no matter what, since the renderer interfaces need to work with both paletted and true color.
Each frame of an entity animation, etc. should be able to use this for indirect texture references with the texture manager.
This should be useful when trying to allocate entity animation keyframes without worrying about texel data.
The Renderer drawing API is currently broken with several not-implemented macro placeholders and will need to be changed to internally allocate Texture instances for TextureBuilderID + PaletteID pairs as an interim solution to the renderer returning allocated texture handles. Much less of the codebase makes assumptions about textures being 8-bit now, which is a big improvement.
ArenaPaletteName and ArenaTextureName provide direct string references to original assets, instead of having to go through an unnecessary enum-to-string step.
The renderer will handle converting texture builders to SDL textures temporarily until a better design is used where the renderer returns allocated texture handles for users of the renderer to keep track of.
Cleaning up the Texture class a bit.
@afritz1 afritz1 added this to the 0.13.0 milestone Jan 3, 2021
@afritz1 afritz1 merged commit 66ce7d2 into master Jan 3, 2021
@afritz1 afritz1 deleted the indirect-texture-assets branch January 3, 2021 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant