Loading textures like 1:5:5:5 directly

Hi!

On the one hand we have DDS format that supports textures like 1:5:5:5, 0:5:5:5,
5:6:5, 4:4:4:4
on the other hand we have corresponding OpenGL internal formats like GL_RGB5_A1, GL_RGB5, GL_RGBA4.

So why couldn’t we load directly say 16 bits 1:5:5:5 to GL_RGB5_A1 and have to convert the data to GL_RGBA consisting of GL_UNSIGNED_BYTE’s instead, that then would be converted by driver to internal GL_RGB5_A1

Or I’ve missed some appropriate extensions?

Thanks.

You’re looking for this?

glTexImage2D(GL_TEXTURE_2D,level,GL_RGB5_A1,level_width,level_height,0,GL_BGRA_EXT,GL_UNSIGNED_SHORT_5_5_5_1_REV,data);

Try unpack byte swapping, if it doesn’t work right away.

Note that this doesn’t work if you build mipmaps through the glu (glu is simply too old).

edit:
This requires EXT_packed_pixels. Fortunately every card I’ve ever seen supports this one.

[This message has been edited by zeckensack (edited 04-09-2003).]

EXT_packed_pixels is a core feature since OpenGL 1.2.

Thanks.

It’s exactly that I need.