Selection rectangle over complex scene

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

Selection rectangle over complex scene

cyril
I need to draw a mouse operated selection rectangle over GLCanvas with rather complex scene inside.
So the re-rendering the whole scene on each mouse move is a problem.
Can someone point me to the simplest solution? I tried to use Overlay class but it's not updating in the mouse listeners.
Reply | Threaded
Open this post in threaded view
|

Re: Selection rectangle over complex scene

Wade Walker
Administrator
I'm not an expert, but from a quick reading of the Overlay class, it looks like you're supposed to draw 2D stuff into it, then render your OpenGL scene, then call Overlay.drawAll() to draw over your scene. So it seems like it wouldn't save you from having to render your whole scene every frame.

You could try something like this:

- On mouse down, snapshot your complex scene to an offscreen buffer
- While mouse down, draw the offscreen buffer contents instead of your real complex scene
- On mouse move, draw your selection rectangle on top
- On mouse up, restore the unaltered snapshot

But how low is your frame rate while rendering the complex scene? You'd only want to do this sort of snapshotting technique if your app doesn't permit interactive frame rates even with reduced quality.

Usually in apps with hugely complex scenes, I see them do mouse selection and stuff in a wireframe or reduced-fidelity rendering that permits interactive frame rates, then they render the full-fidelity scene only on request.
Reply | Threaded
Open this post in threaded view
|

Re: Selection rectangle over complex scene

Demoscene Passivist
Administrator
As Wade already suggested making a snapshot by copying the current framebuffer is one way to go, but on hardware that supports "Frame Buffer Objects" (wich nearly all GPUs still alive should)  u should definitly render ur scene to texture directly. Its much faster.

Ur scene would then be only composed of the FBO billboard + the overlay billboard rendered on top of that with additive blending mode or alpha channel blending. U could then independently update ur scene or the overlay.

Reply | Threaded
Open this post in threaded view
|

Re: Selection rectangle over complex scene

gouessej
Administrator
In reply to this post by cyril
Why not simply disabling buffer swap and OpenGL rendering (in your GLEventListener) when you don't want to redraw the scene but only your rectangle? The only problem is that this mode consumes a lot of memory because of a bug.
Julien Gouesse | Personal blog | Website