I have been beating my head against the wall trying to load a 16-bit texture into OpenGL but with no success and I am beginning to think either I’m incredibly stupid, or my drivers are not cooperating.
I have provided the code that works and that which doesn’t
Here’s the code-
Call glBindTexture(glTexture2D, texName(index)) Call glPixelStorei(GL_UNPACK_ALIGNMENT, 1) Call glTexParameteri(glTexture2D, tpnTextureWrapS, GL_REPEAT) Call glTexParameteri(glTexture2D, tpnTextureWrapT, GL_REPEAT) Call glTexParameteri(glTexture2D, tpnTextureMagFilter, GL_NEAREST) Call glTexParameteri(glTexture2D, tpnTextureMinFilter, GL_NEAREST) Call glTexEnvi(tetTextureEnv, tenTextureEnvMode, tepModulate) ' THIS WORKS GREAT! (not what I want) Call glTexImage2D(glTexture2D, 0&, GL_RGBA, ogfWidth, ogfHeight, 0&, GL_RGBA, GL_UNSIGNED_BYTE, data(0)) ' THIS DOESN'T WORK AT ALL ' This is not what I want ideally, but this ' would be acceptable Call glTexImage2D(glTexture2d,0&,GL_RGBA4, ogfWidth, ogfHeight, 0&, GL_RGBA4, GL_UNSIGNED_BYTE, data16(0)) ' THIS DOESN'T WORK AT ALL ' This is what I really want, but I assume ' I don't have the extensions. Call glTexImage2D(glTexture2d,0&,GL_RGBA4, ogfWidth, ogfHeight, 0&, GL_RGB5_A1, UNSIGNED_SHORT_5_5_5_1, data5551(0))
The code is in Visual Basic. It works perfectly fine if I use GL_RGBA for internal format, and format with 32 bit textures, however I have to convert the textures from 16-bit to 32-bit then, and as 16-bits is my limit from reading in, it would make little sense to waste all that space.
I have tried changing pixel alignment to Packed alignment for the GL_RGB5_A1 code, but it kept spitting out ‘Invalid Enum’, so I guess the Microsoft OpenGL32.dll doesn’t support it, however even the 16 bit functions, RGBA4 don’t work.
So, can someone tell me if my code is correct? If it is, then I will suspect my drivers. If not, could you please give a sample of what would be the proper way to generate a 16 bit texture from a 16 bit source texture without conversion? or just let me know it can’t be done.
I really appreciate any help as I have searched far and wide looking for this. Yes, I have Redbook, and many, many, tutorials, manuals, OpenGLFaq, etc.,. Maybe I’m just blind cause I didn’t see this mentioned.