Sign in to follow this  

creating GL_TEXTURE_CUBE_MAP_ARRAY and binding to a layer?

Recommended Posts

Posted (edited)

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
Posted (edited)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this