I am sorry if this is trivial, but I got into OpenGL just very very recently.

I am trying to render skybox (with cubemaps) and this is what I have done:

  • Created a VBO with vertices positions (36 of them +- 10.0f, +- 10.0f, +-10.0f ). Using gDebugger I know the data are loaded correctly.

    glGenBuffers(1, &cubeMap.positionBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, cubeMap.positionBuffer);
    glBufferData(GL_ARRAY_BUFFER, 3*36*sizeof(float), &cubePoints[0], GL_STATIC_DRAW);
  • I create a texture, bound to GL_TEXTURE_CUBE_MAP, and load (using stbi) each face image to the right side. Again gDebugger tells me that the texture is loaded correctly as it shows with all the faces in the right place.

    glGenTextures(1, &textureID);
    glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
    --- for each image (looping through faces with index i) --- 
    data = stbi_load_from_file(file,&width,&height,&comp,0);
    // determine format based on comp 
    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, &data[0]);
  • In my draw loop I draw the cube map as:

    glBindTexture(GL_TEXTURE_CUBE_MAP, textureID );
    setUniform1i("cubeTexture",0); // my wrapper on the glUniform (it is tested)
    glBindBuffer(GL_ARRAY_BUFFER, cubeMap.positionBuffer); // the VBO previously filled
    vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
    glm::mat4 pvMatrix = perspectiveMatrix * viewMatrix; // They are fine
    setUniformMatrix4fv("pvMatrix", 1, &(pvMatrix[0][0]));
    glDrawArrays(GL_TRIANGLES, 0, 36);

Where the shader program cubeMapProgram is very simple:

vertex shader

#version 330

layout(location=0) in vec3 aVP;
uniform mat4 pvMatrix;
out vec3 vUV;

void main(void){
    gl_Position = pvMatrix * vec4(aVP,1.0);
    vUV = aVP;

fragment shader

#version 330

in vec3 vUV;
out vec4 color;
uniform samplerCube cubeTexture;

void main(void){
    color = texture(cubeTexture, vUV);

All I got with this is a black screen. Again according to gDebugger the right VBO is correctly filled and bound when drawing and the cubeMap is loaded correctly. Am I missing something completely stupid?

Thank you

  • \$\begingroup\$ Did you provide texture coordinates for your cube? for debugging purposes set the shader to output fixed color if it appears on screen then there is sth wrong with texturing, if you didnt see anything there is a bigger issue in your code. \$\endgroup\$
    – concept3d
    Oct 1, 2014 at 10:54
  • \$\begingroup\$ Yup I tried with a fixed white, still nothing showing. Do you think the issue may be somewhere else? \$\endgroup\$
    – gufranc
    Oct 1, 2014 at 11:03
  • \$\begingroup\$ Did you provide texture coordinates for your cube? \$\endgroup\$
    – concept3d
    Oct 1, 2014 at 11:33
  • \$\begingroup\$ I derive them from vertex positions \$\endgroup\$
    – gufranc
    Oct 1, 2014 at 13:35
  • 1
    \$\begingroup\$ Check for openGL errors. \$\endgroup\$
    – concept3d
    Oct 1, 2014 at 13:37

2 Answers 2


I didn't see any call to SwapBuffers after your draw commands. That's definitely a problem that will cause a blank screen.

As long as there are no OpenGL errors, it's the only problem.


I use XNA, so even looking at GL code makes my head hurt. On top of that, your variable names do not indicate anything obvious. How does "aVP" represent a worldCoordinate? Anyway...

I can't tell if you've done this in the posted code, or elsewhere:
Since you are inside the skybox, all of its triangles are counter-clockwise from the camera's perspective so you probably need to reverse culling when rendering it; leave everything else the same and/or put it back like you had it.

  • 2
    \$\begingroup\$ This answer addresses the question too indirectly, and rants too much. The culling may be relevant, but since it's speculative it is more suitable as a comment. \$\endgroup\$ Mar 9, 2015 at 23:18

You must log in to answer this question.

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