For memory-efficient realtime embedded graphics I have traditionally used DDS images encoded using GL_LUMINANCE
when I need lossless grayscale images (or GL_LUMINANCE_ALPHA
when there is alpha needed). However, I have just discovered that these file formats were deprecated in OpenGL 3 and removed from 3.1.
Is there a replacement image format for lossless grayscale-only data that is 8 bits per pixel or less (or 16bpp when alpha is involved)?
If you scroll up a bit on that wiki page you'll see GL_RED/GL_R*
and GL_RG*
for 1- and 2-channel images.
glTexImage2D()
:
GL_RED
: Each element is a single red component. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for green and blue, and 1 for alpha...
GL_RG
: Each element is a red/green double. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for blue, and 1 for alpha...
As GuyRT pointed out if you have EXT_texture_swizzle/ARB_texture_swizzle
and/or OpenGL version >= 3.3 you can use swizzle mask to expand out/rearrange your texture color components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With