Jump to content
  • Advertisement
Sign in to follow this  
Paul Griffiths

creating GL_TEXTURE_CUBE_MAP_ARRAY and binding to a layer?

This topic is 653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you create a GL_TEXTURE_CUBE_MAP_ARRAY with 4 layers?

Heres my current code;

   

// Configure depth map FBO

    const int maxLights = 4;

    const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;

    GLuint depthMapFBO;

    glGenFramebuffers(1, &depthMapFBO);

    // Create depth cubemap texture

    GLuint depthCubemap;

    glGenTextures(1, &depthCubemap);

    glBindTexture(GL_TEXTURE_CUBE_MAP, depthCubemap);

    for (GLuint i = 0; i < 6; ++i)

        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

    // Attach cubemap as depth map FBO's color buffer

    glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);

    glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthCubemap, 0);

    glDrawBuffer(GL_NONE);

    glReadBuffer(GL_NONE);

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)

        std::cout << "Framebuffer not complete!" << std::endl;

    glBindFramebuffer(GL_FRAMEBUFFER, 0);

Then how do you bind to a specific layer?
 

glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);

renderScene();

I've searched google, bing and here for an example but nothing of any use.
Is this rare or something?

 

Thanks.

Edited by paulgriffiths

Share this post


Link to post
Share on other sites
Advertisement

Ive got this so far but don't know what to put for depth? It's for a shadow map.
Also, is GL_RGBA8 correct for a shadowmap? Or should I use GL_R8 since I'm only dealing with depth?
 

glGenTextures(1, &depthCubemap);
    glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, depthCubemap);
    glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, maxLights, GL_RGBA8, SHADOW_WIDTH, SHADOW_HEIGHT, ?);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    // Attach cubemap as depth map FBO's color buffer
    glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
    glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthCubemap, 0);

As for glFramebufferTextureLayer, i dont know how to fill the rest in?
Lets say I want layer 6.
 

glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, ?, ?, 6)

Do  I still bind to buffer or is that now glFramebufferTextureLayer?
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);

I've searched goggle and bing for +"GL_TEXTURE_CUBE_MAP_ARRAY", google came up with nothing relevant, and bing went from page 8 to page 6, there's a bug in their code because of the limited amount of results orr lack of searches.

Edited by paulgriffiths

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!