Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Render To Texture Array

This topic is 2103 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

I am using OpenGL 4.0  (GLSL 4.20)


I have a texture array I created like this:

unsigned int NumLayers = 2;
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA32F, Width, Height, NumLayers);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA32F, Width, Height, NumLayers, 0, GL_RGBA, GL_FLOAT, 0);

I also created a framebuffer and attached the two layers (to GL_COLOR_ATTACHMENT0 and GL_COLOR_ATTACHMENT1) with glFramebufferTextureLayer.


So first, I bind the framebuffer, and attempt to render to the two layers.  I've tried both of these output variable methods in the shader to render to the layers of the texture array:

out vec4 frag_color[2];



layout(location = 0) out vec4 frag_color0;
layout(location = 1) out vec4 frag_color1;
(I'm not sure which I'm supposed to use.)
After I've rendered it I switch off the framebuffer I created and try to just render the texture array.  When I bind the texture array (using GL_TEXTURE_2D_ARRAY of course) and render it with a shader that uses a sampler2DArray and a vec3 for texture coordinates, I only see my data when I set the z parameter of the vec3 to 0.0.  If I use 1.0, to see what's in the second layer, there is nothing.  Not even a black texture.
Can anyone give me advice on how to render to a texture array?
Edited by Funkymunky

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!