Take the tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.