forked from davidgfnet/opengx
-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
glTexSubImage2D(), support more texture formats, fast conversions #30
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was used by one of our glu functions.
Use templates to unify the implementation as much as possible. Note that with this commit we temporarily lose support form GL_BGR and GL_BGRA formats, which are part of OpenGL 1.2, but we will bring them back later.
Add a Texel base class for the Texel writer classes, so that they can be used in non-template code. Add a method to set the pixel color from a GXColor. Add a DataReaderBase class defining an interface for pixel readers (using GXColor as the result), and a couple of generic subclasses (one of which needs to be a template, in order to read pixel components as bytes, words, longs and floats without excessive pain) to read texture input data pixel by pixel. Finally, we combine these two sides inside a generic texture conversion function, which reads the client pixel data and stores it into a GX texture. This is a minimal implementation: we will need to support specifying the pitch and the pixel alignment. We also do not support loading textures whose components are encoded with one of the signed types GL_BYTE, GL_SHORT and GL_INTEGER; these are easy to add, but since they would be used in the templated reader, and given that they are fairly uncommon, we leave them out until someone requests them, in order to save on code size.
The bytesperpixelsrc is now just unused, and the infomation in bytesperpixelinternal can be obtained by gx_format.
This is going to grow once we add support for more glTex* functions.
This function will be used by glTexSubImage2D as well.
The width and height parameters are now indicating the size of the source image only; for the destination it's enough to know the row pitch.
This also is going to be used by glTexSubImage2D. We also refactor the way that the texture format GX_TF_A8 is propagated, by keeping a flag in the userdata field, which tells us if the GX_TF_I8 format is in reality a GX_TF_A8.
This is almost trivial, by using the update_texture method. Tested on crack-attack, which uses this feature extensively to write text.
This is a compromise to allow keeping the binary size small while still activating all the faster textures conversions needed: we instantiate all the texture conversion templates, but we don't directly use them, so that the linker will not bring them into the compiled object. Instead, we expose their symbols and a public function to let the client register the conversions it needs. The conversion functions are exposed as intptr_t in order to hide the full signature, since we might need to change it later. If the client doesn't do this, opengx will pick the slower conversion (which can be up to 10x slower), but the program will not break in any case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch contains many loosely-related changes about texture handling:
texture.c
fileAs usual, reviewing commit-by-commit is strongly recommented.