Here is a a minimal example causing GL to render a black screen:
// ... all the usual GL init code etc. & GLAM includes
const int SHADOW_SIZE = 1024;
const int SWIDTH = 1200, SHEIGHT = 900;
unsigned int shadowMap, albedoSpec;
// Begin snip 1
glGenTextures(1, &shadowMap);
glBindTexture(GL_TEXTURE_CUBE_MAP, shadowMap);
for (unsigned int i = 0; i < 6; ++i)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_DEPTH_COMPONENT, SHADOW_SIZE, SHADOW_SIZE, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
// End snip 1
glGenTextures(1, &gAlbedoSpec);
glBindTexture(GL_TEXTURE_2D, gAlbedoSpec);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, SWIDTH, SHEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
// ... some time later, in the draw loop
// The active shader is called `shader`
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gAlbedoSpec);
// sets the `uniform sampler2D gAlbedoSpec` to use texture unit `0`
shader.setInt("gAlbedoSpec", 0);
// ... code which draws the scene using `shader`
Now, in my shader I have something like this:
uniform sampler2D gAlbedoSpec;
uniform samplerCube shadowMap;
// ... some code which uses gAlbedoSpec
if (valueWhichIsFalseInThisExample) {
// ... some code which uses shadowMap
}
If I remove the bit of code marked snip 1
, then GL will render whatever I tell it to. Otherwise, the screen will be black without exception. To me it seems that the act of simply generating a cubemap has lead to GL to refuse to render. So, my question is, why does generating a cubemap lead GL to refuse to render anything to the screen?
(This is all the relevant code and does minimally reproduce the problem.)