According to the opengl's reference page, glTexImage2D's structure looks like this:
void glTexImage2D( GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid * data);
As far as I know, the last 3 parameters are how the function should interpret the image data given by const GLvoid * data
Meanwhile, I was studying the topic of framebuffers. And in the section called 'Floating point framebuffers' of this link https://learnopengl.com/Advanced-Lighting/HDR, the writer creates a framebuffer's color attachment like this
glBindTexture(GL_TEXTURE_2D, colorBuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
My question is, why did he give GL_FLOAT as the parameter for GLenum type
? If const GLvoid * data
is NULL
anyway, is there a need to use GL_FLOAT? I first thought it's something related to GL_RGBA16F
, but 16 bits is 2 bytes and floats are 4 bytes, so I guess it's not related at all.
Furthermore, before this tutorial, the writer used to make color attachments like this:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
In this case, why did he use GL_UNSIGNED_BYTE
for the GLenum type
parameter?