Re: [Plib-users] Re: plib-users digest, Vol 1 #170 - 9 msgs
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2001-01-18 02:22:30
|
Stephen Lee wrote: > > Hi, I'm a new user of plib and OpenGL in general, can i mix OpenGL commands > with ssg ? e.g draw a cube using GL_QUADS ? Yes! This is a major design goal of SSG. (It has to be like that so that you can use multiple OpenGL libraries in the same program - for example PLIB's SSG *and* FNT *and* PUI all in the same program. There are a *couple* of caveats. 1) Changing 'state' in OpenGL (eg switching texture maps, using glEnable/glDisable, etc) can be quite costly in performance. Because of that, SSG uses 'lazy' state updates. It keeps track of the current OpenGL state - and only changes the minimum of state settings when it has to. If you start messing around switching things on and off without telling SSG, it can get a little confused. There are three ways to fix that. * Be sure to glPushAttrib/glPopAttrib around your state changes - so that SSG's states are restored afterwards. * Don't do your own state switching at all. Use SSG for that. Create ssgSimpleState's and use the 'apply' member function to make that state be the current one. That way, SSG always knows the current state. * Do what the heck you like to the state - but be sure to call the 'force' member function of any ssgSimpleState before you give control back to SSG. 'force' is just like 'apply' except that it doesn't use lazy evaluation, it just unconditionally sets all the state elements. Which to do? The answer is "it depends" - and unfortunately, there is no clear best solution. 2) As with lazy state changes, we also have lazy matrix switching. Be sure to restore the modelview and projection matrices when you are done messing around. One *cool* way to do this is to derive your own ssgLeaf class. That makes your OpenGL commands become a part of the SSG system and you can let SSG deal with the uglinesses of field of view culling for you. -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net http://freeglut.sourceforge.net |