[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GL viewports

Keith Lucas wrote:

> What's a good way to get OpenGL to render just a bit of the display?
> What I need is a 3D view and a bit of 2D UI. So I figured I can set
> the viewport up to draw the 3D view most of the time and just rewire
> it to draw the 2D UI when that changes.

glScissor is the thing you need - but there is a snag.

You can't draw the GUI just once in the same rendering context (window)
as the 3D stuff if you are using double-buffered rendering context.
On some cards you can render the GUI twice (once in the front buffer
and again in the back) - but that's not legal OpenGL because the
contents of the back buffer following a buffer swap is undefined - and
*might* not contain what was in the front buffer just before the swap.

Even on cards where it does seem to work, you'll get in trouble when the
GUI area is overlaid by another window or partially off the screen.

There are really only three alternatives:

1) Draw the GUI into a different window using a single-buffered context.

2) Redraw the GUI every frame along with the 3D stuff.

3) Do all the 3D stuff in a single-buffered context.

Of these, (1) and (2) are most likely to be useful.

If you want your code to be portable onto a Voodoo-1 or -2 card then
you are stuck with (2) if you want any performance because those early
Voodoo's can only render full-screen and with a single window...well,
more or less.  Quite a few PC cards can't do single-buffered rendering.

If you choose (2) or (3) you'll need to draw the GUI using OpenGL
commands, for which you could use my 'PUI' library, or another
package called 'GLUI'...there are probably other choices also.

PUI can be found here:


Steve Baker                  http://web2.airmail.net/sjbaker1
sjbaker1@airmail.net (home)  http://www.woodsoup.org/~sbaker
sjbaker@hti.com      (work)

To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: linuxgames-help@sunsite.auc.dk