Rendering one scene multiple times per frame to a frame buffer

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Rendering one scene multiple times per frame to a frame buffer

gtt023
Hi,

I am very new to OpenGL, and I am having problems getting my code to work.  I am trying to write a program that takes a scene and tries to determine how much the camera has moved from the previous frame.  My strategy is to slightly move and rotate my camera, and compare the pixels it sees after the transformation with the pixels from the previous frame.  The transformation that yields the smallest difference is what I use.

Now, to achieve that, I create an FBO once, and every time I want to render the scene, I create a texture, and attach it to the FBO at GL_COLOR_ATTACHMENT0.  The problem I am having is that seemingly the function I wrote which returns a ByteBuffer of the scene pixels works 3 times, and then always returns a ByteBuffer with all zeroes until I advance to the next frame.  I don't understand why that happens, and since I just got my head around the whole concept of FBOs, I have no idea as to where to start to debug this.  Any help would be appreciated.  Here's my rendering code: ScreenRenderer.java
Reply | Threaded
Open this post in threaded view
|

Re: Rendering one scene multiple times per frame to a frame buffer

Wade Walker
Administrator
My advice would be to start with a working example code from the web that uses FBOs, then gradually change it to do what you want, while keeping it working at every step. OpenGL codes can be very painful to debug if you've just got a bunch of non-working code and no idea why it doesn't work

Is your processing of the rendered image going to happen on the GPU or CPU? If on the CPU, it might be faster to only create one FB to render into each time, and just copy it back to the CPU for processing before overwriting it. If you're going to process it on the GPU (via OpenCL-OpenGL interoperation, for example), you still might just want to create only one FB for the sake of speed (or maybe two if you're going so fast you need to double-buffer).

It sounds like you're working on the pose estimation problem (http://en.wikipedia.org/wiki/Pose_(computer_vision)) -- are you a computer vision researcher perhaps?
Reply | Threaded
Open this post in threaded view
|

Re: Rendering one scene multiple times per frame to a frame buffer

gtt023
Thanks for the reply.  I am an aspiring computer graphics researcher, but still an undergraduate currently.  And yes, the pose estimation problem is exactly what I am working on...but it is only estimating the pose of a wall for now.  But who knows about later...

Right now, I am not concerned with speed. I just need to be able to render a scene, say, 18 times (three times per degree of freedom) per frame.  However, my code only seems to work 3 times per frame, and I don't know why that would be the case.

Reply | Threaded
Open this post in threaded view
|

Re: Rendering one scene multiple times per frame to a frame buffer

Wade Walker
Administrator
gtt023 wrote
However, my code only seems to work 3 times per frame, and I don't know why that would be the case.
Yeah, not sure what's going on there either :) But it sounds like a generic OpenGL problem, rather than one specific to JOGL -- perhaps you could ask on an OpenGL forum?