Skip to main content
GameDev.net gamedev.net
🔒 Locked

internalFormat

Started by Tom Backton Apr 11, 2009 at 12:53 PM 2 replies 550+ views
Original Post
Tom Backton
Tom Backton
glTexImage2D() has an internalFormal parameter. It can have one of 38 possible values...Two of them are GL_RGBA and GL_RGBA8. My question is: how are textures saved in the texture memory? Are they normally saved with float components or ubyte components? Is there a difference between the two mentioned formats? (I need answers for a PC, Windows, 32-bit)
Brother Bob
Brother Bob
The difference between the two is that GL_RGBA is an implicit format and GL_RGBA8 is an explicit format.

With implicit formats, you basically only say what channels you want and OpenGL picks an exact format that is suitable for the environment (can depend on pixel format, such that, for example, the bit depth and channel bit allocation match the frame buffer).

The explicit formats are more explicit in what you ask for. The RGBA part says you want R, G, B and A channel in your texture, and 8 means you want 8 bits per channel. This is only a request, and OpenGL is free to ignore this and pick another format if it want to. It could make a difference if, say, OpenGL follows your request and gives you 32 bits when the frame buffer is 16 bits, where GL_RGBA only would give you a 16 bit texture.

Unless you have a reason and know the effects, stick with the implicit formats.
kRogue
kRogue
just one comment: you will *want* to specify the texture inernal format explicitly if you are going to render to that texture in a framebufer object. This is so because you will, depending on your situation, want possible a floating pointer texturet that allows unclamped values, or a native integer texture for writing integer values in a shader; also current framebuffer object rule are relaxed some: the formats don't need to be identical, but they do need to be the exact same bit depths.
Close this Gamedev account, I have outgrown Gamedev.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.