3
votes

In the OpenGL wiki glTexImage2D, it writes:

internalFormat Specifies the number of color components in the texture. Must be one of base internal formats given in Table 1, one of the sized internal formats given in Table 2, or one of the compressed internal formats given in Table 3, below.

In OpenGL Programming Guide, Chapter 9, Texture Mapping

By definition, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, and GL_RGBA are lenient, because they do not ask for a specific resolution.

So if we assign GL_RGBA to the internalformat, what datatype is used? Default by the GPU processor?

2
There is no default type, that's why constants like GL_RGBA8 were created.Andon M. Coleman

2 Answers

5
votes

The size used for GL_RGBA is specifically undefined.

From the OpenGL 4.5 spec, section "8.5 Texture Image Specification", page 153 (emphasis added):

The internal component resolution is the number of bits allocated to each value in a texture image. If internalformat is specified as a base internal format, the GL stores the resulting texture with internal component resolutions of its own choosing.

where "base internal format" refers to the formats listed in table 8.11, which includes GL_RGBA.

I would expect the chosen format to typically be GL_RGBA8, but there's really no guarantee. If you care about the size, you should use a sized format. In fact, I think you always should. The unsized formats seem to still be there to maintain backwards compatibility. I was always surprised that they were not removed in the Core Profile. For example the newer glTexStorage*() entry points, which serve as better replacements for glTexImage*() in many use cases, only accept sized internal formats.

0
votes

I'm not sure what your question here is but GL_RGBA is normally a 4x8bit (4-byte/GL_BYTE type) format in the R,G,B,A order respectively but the constant is just saying that the buffer is composed of this order and not exactly how big each channel width is.

More info here

Edit: For some methods, you also need to specify this channel width (e.g. glReadPixels() or glDrawPixels())