0
\$\begingroup\$

I see alot of tutorials and sources use the following code snippet when defining each face of a cube map:

for (i = 0; i < 6; i++)
    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, InternalFormat, size, size, 0, Format, Type, NULL);

Is it safe to assume GL_TEXTURE_CUBE_MAP_POSITIVE_X + i will properly iterate the following cube map targets, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y etc?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Yes, it is safe because if you look at the original extension spec for cubemaps, you can see that those enums are all defined as consecutive numbers.

Accepted by the <target> parameter of GetTexImage,
GetTexLevelParameteriv, GetTexLevelParameterfv, TexImage2D,
CopyTexImage2D, TexSubImage2D, and CopySubTexImage2D:

    TEXTURE_CUBE_MAP_POSITIVE_X_ARB     0x8515
    TEXTURE_CUBE_MAP_NEGATIVE_X_ARB     0x8516
    TEXTURE_CUBE_MAP_POSITIVE_Y_ARB     0x8517
    TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB     0x8518
    TEXTURE_CUBE_MAP_POSITIVE_Z_ARB     0x8519
    TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB     0x851A
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .