The third internalFormat of qglTexImage2D in Quake2

246 Views Asked by At

From Quake2 source, the function GL_BeginBuildingLightmaps at gl_rsufr.c, i saw these codes:

if ( toupper( gl_monolightmap->string[0] ) == 'A' )
{
    gl_lms.internal_format = gl_tex_alpha_format;
}
/*
** try to do hacked colored lighting with a blended texture
*/
else if ( toupper( gl_monolightmap->string[0] ) == 'C' )
{
    gl_lms.internal_format = gl_tex_alpha_format;
}
else if ( toupper( gl_monolightmap->string[0] ) == 'I' )
{
    gl_lms.internal_format = GL_INTENSITY8;
}
else if ( toupper( gl_monolightmap->string[0] ) == 'L' ) 
{
    gl_lms.internal_format = GL_LUMINANCE8;
}
else
{
    gl_lms.internal_format = gl_tex_solid_format;
}
GL_Bind( gl_state.lightmap_textures + 0 );
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexImage2D( GL_TEXTURE_2D, 
               0, 
               gl_lms.internal_format,
               BLOCK_WIDTH, BLOCK_HEIGHT, 
               0, 
               GL_LIGHTMAP_FORMAT, 
               GL_UNSIGNED_BYTE, 
               dummy );

qglTexImage2D is same as glTexImage2D.

The problem is from debugging i saw the input value of third parameter(internalFormat) of qglTexImage2D is gl_tex_solid_format, which is 3. Is 3 a valid value for parameter internalFormat?

2

There are 2 best solutions below

1
On BEST ANSWER

3 is a perfectly legitimate value for internalFormat.

From the the glTexImage2D() documentation:

internalFormat: Specifies the number of color components in the texture. Must be 1, 2, 3, or 4, or one of the following symbolic constants: ...

0
On

Where is the value of the variable gl_tex_solid_format from? Are you sure you have assigned GL_RGBA to the variable gl_tex_solid_format? Maybe you assigned 3 to the variable gl_tex_solid_format.