On Thu, 2008-07-03 at 08:54 -0400, Reid van Melle wrote: > 5. Direct Usage of OpenGL > > Question #4 led me to try direct use of the OpenGL API within a > "Coglbox" actor paint function. It did not seem to work as I hoped. > I was just drawing a simple rectangular polygon via OpenGL... I saw > the rectangle appear and then disappear very quickly in subsequent > calls to the paint function.
Unfortunately there is still some hoops you have to jump through to safely use OpenGL calls directly in a paint function so you may have run in to these problems. COGL changes some of the GL state (with glEnable/glDisable) when it renders textures or shapes and it caches the state so that it doesn't have to make a new GL call unless it actually needs to change the state. So if you have other actors in your scene then when your custom paint function is hit then GL will be in a different state depending on what order the actors are rendered. COGL will get confused if you don't restore the state to what it was once the paint is completed. Therefore your paint function needs to store some of the current settings of GL, set the state to what it needs, do the actual drawing and then restore the GL state. There is an example of this in the Clutter-MD2 renderer here: http://tinyurl.com/5fq6we Regards, - Neil -- To unsubscribe send a mail to [EMAIL PROTECTED]
