openframeworks / openframeworks/openFrameworks
ofTexture : allow uploading DXT pre-compressed data
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
I've been working on an addon to compress pixel data with DXT (ofxDXT) to upload already compressed texture data into ofTextures (vs uploading raw RGBA data and making the GPU compress it). This is very useful to be able to preload more textures in GPU memory (think image sequences / sprite sheets), but also to stream them from disk. DXT gives you a 4:1 compression ratio with a quite acceptable quality loss on RGBA texture data, and a 8:1 ratio on RGB data.
This currently works on my branch of OF (close to 0.10.1) in GL2, GL3 and GL4, but it requires some changes to ofTexture.
The changes are quite small (see here, sorry for tab vs space mess), and would only affect anything when a texture glInternalType is DXT. Basically when the internal type is of the GL_COMPRESSED_RGB_S3TC_DXT*_EXT family, instead of calling glTexImage2D() you need to call glCompressedTexImage2D() for both alloc() and load(). After this, the ofTexture just works as normal.
But I wonder if this is a chance to revisit what's up with with the compression options im ofTexture. There's an ofTextureCompression type in ofTextureData that you can seet, but its not being used anywhere in the implementation.
There's two ways you can use texture compression as far as I can tell:
- You upload raw RGBA data as usual, but specify you want it store compressed (and the GPU does the compression at upload time)
- You upload already compressed data, the GPU just stores what you send and treats it as compressed.
I feel 2 is probably more common, but 1 can also be very useful because of the upload bandwith savings.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in libs/openFrameworks/gl/ofTexture.h, especially ofTextureData and the alloc() and load() paths described in the issue. Compare the linked branch and commit for GL2, GL3, and GL4 handling of DXT internal types. Done means pre-compressed DXT data uploads correctly while existing texture behavior remains intact, with the unused compression options clarified or addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100