glTexImage2D probs..

Hi

I’am using both 16Bpp & 32Bpp textures. is there any trick to directly send them with
glTexImage2D(…) in their original format
(16 or 32)?? …
The only formats (and not gl internal format for the destination) which seem to work are GL_RGBA,GL_RGB,GL_BGRA_EXT which are 32,24,32 Bpp while i need a 16 Bpp entry with alpha or not (1555 | 565).

Did i miss something in the documentation?

any extensions?

Yep, that through me for a loop too. I discovered the MSDN info on glTexImage2D was not very precise. For example the MSDN info says this:
void glTexImage2D(
GLenum target,
GLint level,
GLint components,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels
);
…snip…
components
The number of color components in the texture. Must be 1, 2, 3, or 4.
…snip…

That turns out to be false, or at best a half truth.

For for 32 bpp use 1,2,3, or 4. For 16 bpp use GL_RGBA4, GL_RGB5, or GL_RGB5_A1.
RGBA4 is (4,4,4,4), RGB5 is (5,5,5) and RGB5_A1 is (5,5,5,1). I didn’t notice a (5,6,5) constant available.
I found a better explanation (and a whole lot more constants) in a pdf file titled opengl1.2.1.pdf . I think I downloaded it from the home page of opengl.org or somewhere nearby.

Just wanted to add a bit more information.

Picking GL_RGB or GL_RGBA does not mean you will get 24 and 32 bit textures respectively. It is a general request that gives some freedom to the implementation/dirver. I have found that GL_RGB on 98 usually uses 16bit textures, where as on 2000 it uses 24/32bit format.

If you want 16bit, or 24 bit textures you really should explictly specifiy GL_RGB5 or GL_RGB8 respectively. That way you have a better chance of getting what you want, though even then it is only a suggestion to GL.

I think, you have not understood a question.

is there any trick to directly send them with glTexImage2D(…) in their original format (16 or 32)??

For for 32 bpp use 1,2,3, or 4. For 16 bpp use GL_RGBA4, GL_RGB5, or GL_RGB5_A1. RGBA4 is (4,4,4,4), RGB5 is (5,5,5) and RGB5_A1 is (5,5,5,1). I didn’t notice a (5,6,5) constant available.

  • All this constants are for internal texture format.

If you want to use 16bpp and 32bpp directly, it’s possible only with the GL_EXT_packed_pixels extension.
(btw, it has no 5:6:5 format - too bad, all this “packed” stuff was available even in DirectX 3)

Maybe I wasn’t clear on what I was saying…

I was just adding some information on internal format specifications. using 1,2,3,4 will NOT necessarily get you 32bpp internal texture formats as was indicated in an earlier response. 1,2,3,4 are there only for legacy support where 3 and 4 map to GL_RGB and GL_RGBA. What GL uses for these two internal formats varies from implementation. My point was ask for what you want GL_RGB8 or GL_RGB5 etc. or you leave it up to the implementation and it will vary as I mentioned. 98 would map GL_RGB to GL_RGB5 on 2000 it maps to GL_RGB8.

Hi elroy,
Your message is good and correct.
(as an addition to DFrey answer)

Only the question was about the “external” pixel format, instead of internal.

> What GL uses for these two internal formats varies from implementation. My point was ask for what you want GL_RGB8 or GL_RGB5 etc. or you leave it up to the implementation and it will vary as I mentioned.
98 would map GL_RGB to GL_RGB5 on 2000 it maps to GL_RGB8.

It’s depends from driver/chip/etc…
For example, my ELSA Gloria L/MX uses 24/32bit for GL_RGB/GL_RGBA.
But ATI Rage 128 and TNT2 - 16bit (565/1555(?) for RGB and 4444 for RGBA).