Problem with cubemap fetch

I’m now rewriting my dynamic cubemapping demo into GLSL shaders from fixed pipelines,
but I have a problem with cubemap fetch and the cubemap location.

fragment shader:

uniform samplerCube CubeMap;
 
varying vec3 vTexCoord;
 
void main(void)
{
   gl_FragColor = textureCube(CubeMap, vTexCoord);
}

main program:

#define CUBE_MAP_ID 0
 
GLuint g_CubeMap;
 
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, g_CubeMap);
g_CubeMapLoc = glGetUniformLocationARB(g_ProgObj, "CubeMap");
glUniform1iARB(g_CubeMapLoc, CUBE_MAP_ID);

Does anywone know what the problem is?

Thanks.

Looks fine to me but make sure g_CubeMapLoc is not -1 and vTexCoord contains good values.

Did you call glUseProgramObjectARB(g_ProgObj) before calling glUniform1iARB?

Are you getting any OpenGL errors?

Yep, both g_CubeMapLoc and vTexCoord contain correct values.
And of course I’m calling glUseProgramObjectARB() before calling calling glUniform1iARB().

This is very mysterious for me…
I gotta keep working on this.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.