Jump to content
  • Advertisement
Sign in to follow this  
Icarus0508

OpenGL a question about geometry shader and FBO

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

Hi i am new in opengl. i tried to render 6 textures simultaneously by tex_array and Geometry shader. how can i get the texture from a texture_array after rendering to the targets? glGetTexImage(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA, GL_UNSIGNED_BYTE, gVisibilityTexturePixels); does not work since it can not control the layers of texture_array. Can someone help me? thank you

Share this post


Link to post
Share on other sites
Advertisement
Accordingly to spec GetTexImage returns all layers of array texture:
Quote:
(14) Should we provide a way to query a single layer of an array texture?

RESOLVED: No; we don't expect this to be an issue in practice.
GetTexImage() will return a two- or three-dimensional image for one- and
two-dimensional arrays, including all levels. If this were identified
as an important need, a follow-on extension could be added in the
future.

Share this post


Link to post
Share on other sites
Thanks for answer.

i followed spec but it still nothing.

i think the bug is at the setting of FBO

here is some codes:
creating:
glEnable(GL_TEXTURE_2D_ARRAY_EXT);
glEnable(GL_TEXTURE_3D_EXT);
glEnable( GL_FRAMEBUFFER_EXT );

glGenTextures(1, &tColorCubeMap);
glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, tColorCubeMap);
.......
glTexImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA, 1024, 1024, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

glGenTextures(1, &tDepthCubeMap);
glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, tDepthCubeMap);
.......
glTexImage3DEXT(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 6, 0, GL_RGB, GL_FLOAT, NULL);

glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glDrawBuffer(GL_NONE);

glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, tDepthCubeMap, 0 );
glFramebufferTextureEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, tColorCubeMap,0);


rendering:

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
for (int i=0;i<6;i++)
{
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, tDepthCubeMap, 0 ,i);
glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, tColorCubeMap,0,i);
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);

RenderScene();

}
tDepthCubeMap and tColorCubeMap are Texture_array.
and i used GS to render through gl_layers.
VS:
void main()
{
gl_Position = ftransform();
}
GS:
void main()
{


int i, layer;
for (layer = 0; layer < 6; layer++)
{
gl_Layer = layer;
for (i = 0; i < 3; i++)
{

gl_Position = gl_PositionIn;


EmitVertex();
}
EndPrimitive();
}

}
PS:
void main (void)
{

gl_FragData[0] = vec4(0.0,0.0,1.0,1.0);

}

Is the setting wrong?

thanks

[Edited by - Icarus0508 on May 5, 2009 12:32:58 AM]

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!