but when the program is running,it’s black,nothing…I thinks maybe the frame buffer was not written,but when I cut off anything about the “NeedCubeMap”,it just good. Where is the wrong ?
Did use set the samplers to 0 and 1?
This needs to be in your code somewhere:
glUniform1i(getUniLoc(ShaderProg,“cubeMap”),0);
glUniform1i(getUniLoc(ShaderProg,“tex2d”),1);
Any compile or link errors of the shaders?
Any glGetError hit?
Is the shader program in use when you call glUniform? It has no program parameter, so it can only affect the currently bound program.
If you set the glClearColor to non-black, do see something rendered at all?
What’s your vertex shader?
Try this:
void main(void)
{
vec4 color;
if( NeedCubeMap ){
color = textureCube(cubemap,vUV3D);
}else{
color = texture2D(tex2d,vUV2D);
}
gl_FragColor = color * vec4(LightCoeff);
}