OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Read FBO with PBO

Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Cary, Karl A.

PostPosted: Tue Jul 11, 2017 1:28 am    Post subject:
Read FBO with PBO
Reply with quote

I have a unique situation where I have to render my full scene to the screen, but then also render a separate subset out to a shared memory segment. This was achieved by creating a second camera, attaching the needed subset, rendering to an FBO with a texture applied, and then doing a readImageFromCurrentTexture in the final draw callback. This all works. The resultant data is then memcpy'd to the location in shared memory that it needs to go (unfortunately I can't change that requirement at all, the target is raw data at the location). Alternatively I also tried applying the image directly to the fbo rather than a texture, and it was slightly faster, but still very slow. To test that this method will ultimately work, if I attach the texture but then only do the readImageFromCurrentTexture if I signal it, via keyboard input, the scene continues to render to the FBO and the last scene copied from the texture will be continually sent to the shared memory segment. The performanc
e of this is what we are looking for, we just have the one frame hit every time I signal it. All this really does is prove that if I can speed up the read, this solution will work.

The issue I have is the readImageFromCurrentTexture is extremely slow, about 20 ms. My initial thought was to use a pixel buffer object just like in the osgscreencapture example, which we have done before for applying some post processing effects with the data from the backbuffer with great success. The problem is, I can't figure out how to bind to the frame buffer object. In raw GL, you bind to GL_COLOR_ATTACHMENT0_EXT. That fails and gives a State::apply error and results in simply reading the back buffer instead. I have tried all of the COLOR_ATTACHMENT buffers and they all give me the same result.

Is it possible to bind just to the texture and do a glTexSubImage2D instead of a glReadPixels? If so, how do I actually get that set up? I have attempted to do it the same way I bind the texture for doing the readImageFromCurrentTexture but that does not work either.

Post generated by Mail2Forum
Back to top

Joined: 26 Jan 2017
Posts: 78

PostPosted: Tue Jul 11, 2017 6:40 pm    Post subject:
Reply with quote


This is not a direct answer to your problem, but always keep the source handy and Ctrl-F in visual studio can yield a lot of answers.

See how readImageFromCurrentTexture is implemented.

I don't think it should have to take that long, but the function is a bit clunky.

So in short, you want to copy the pixels of a subset of your final render image to a buffer?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts How do I continuously read the mouse ... kornerr General 8 Wed Feb 06, 2019 2:02 pm View latest post
No new posts Change color of node read from dxf file dhhabyc General 10 Sat Nov 17, 2018 12:58 pm View latest post
No new posts Read Image from RTT romulogcerqueira General 6 Thu Sep 27, 2018 7:06 pm View latest post
No new posts Load OSG trimesh to ODE: Read Vertice... TKoller General 2 Fri Jul 20, 2018 3:06 pm View latest post
No new posts Read frame buffer back into main memory arennuit General 12 Wed Feb 28, 2018 6:05 pm View latest post

Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP