Jump to content

  • Log In with Google      Sign In   
  • Create Account


glGetTexImage/glGetTextureImageEXT with render to texture and FBO


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 B_old   Members   -  Reputation: 642

Like
0Likes
Like

Posted 20 December 2013 - 12:40 PM

I render to the individual faces of  a cubemap by setting different views on the cubemap texture on the bound FBO.

After rendering is done I want to download the texture data using glGetTextureImageEXT.

I read somewhere that I should unbind the FBO before calling glGetTextureImageEXT. If I do that the first call to glGetTextureImageEXT works as expected, but the second call gives all zeros.

However, if I bind the FBO, set with the different texture views, before glGetTextureImageEXT, I get exactly the data I expect. The most confusing thing is, that it works a single time when no FBO is bound. 

(I tried it with glGetTexImage and it behaves exactly the same.)

Any idea how this is supposed to behave?



Sponsor:

#2 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 21 December 2013 - 05:38 PM

You can use glFramebufferTexture2DEXT to attach a texture and render to it instead of getting the data after. Make sure you don't have it auto-generating mipmaps.

 

You can use a PBO, glReadBuffer(GL_COLOR_ATTACHMENT_0), glReadPixels to get data after you render.

 

I'm not familiar with the process you're describing, but you should definitely provide minimized code that demonstrates the problem when asking for help with this stuff. Rendering to texture is always a multi-step process with a lot of setup and such that you can get wrong, so it's hard to just guess where you went wrong. If you can't provide sample code and need to stick with this approach, what result do you get if you replace glGetTexImage with glCopyTexImage? At least that would help narrow down the cause.



#3 B_old   Members   -  Reputation: 642

Like
0Likes
Like

Posted 22 December 2013 - 04:11 AM

Ok, it seems like I provided a bad description.

 

What I am doing is rendering to texture and then I want to download the data to the CPU. As far as I know PBOs are only a means of meaking the downloading stuff asynchronous, which can be a performance win if handled smartly.

 

Anyway, glGetTextureImageEXT should download the texture data to system memory, but it only works the "first" time for me. Unless I bind the FBO which I used to render to the texture in the first place. And this is contradictory to some information I found on this topic. 



#4 richardurich   Members   -  Reputation: 1187

Like
0Likes
Like

Posted 23 December 2013 - 11:12 AM

I think the FBO restriction is just that it's not supposed to be an active render target when reading data from it, and unbinding it ensures it's not active. When you read from an active target framebuffer, I think the results are undefined. So you might see results that make sense right now, but you might see different results on a different video card or different results when you change what you are rendering.

 

Without more detailed code or more information, I can't narrow down why you're seeing the results you're seeing. Are you following a certain tutorial about rendering a cubemap? Is there any other information you can share?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS