Re: [Plib-users] GL context fecal matter
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2001-08-24 03:55:52
|
Cameron Moore wrote: > Why do non-plib apps like Quake3, Rune, and gltron work while plib ones > do not? I mean, how can these non-plibs apps render without a valid > context? If they can't, how are they getting a valid context when plib > isn't? Or if it's possible to render without a valid context, why do we > care if one exists (playing devil's advocate)? In OpenGL you are NOT ALLOWED TO MAKE ANY OPENGL CALLS WITHOUT A VALID RENDERING CONTEXT. It's a rule - and that's that. Now, IIRC, in one broken Mesa version, the query function that checks whether there is a valid OpenGL context or not is BROKEN...it says "no valid context" even when there is one. That's a bug in that version of Mesa - and it needs to be fixed. So, if your application doesn't CHECK for a valid context - but happens to have one anyway, it'll work just fine - even on the broken version of Mesa. However, if such an application were ever to fail to get a valid context, it would crash mysteriously and without a good error message. HOWEVER, there is another class of "bugs" in OpenGL implementations that you have to watch for. Some of them tolerate you making *some* OpenGL calls before the rendering context has been created. That's not exactly a bug because correctly working OpenGL applications don't do that - and broken OpenGL applications are just broken anyway. So, in the light of all that, you might ask why PLIB goes and checks that the rendering context is valid. Well, before we added that, people would do all sorts of illegal things like loading texture maps before they'd opened up an OpenGL window (a rendering context). In particular they'd try to call ssgInit() before they had a valid rendering context. That was a VERY BAD THING because the 'permissive' OpenGL implementations would allow this and those programs would seem to work perfectly on the authors computer - and then crash mysteriously on other people's machines because they had OpenGL implementations that couldn't tolerate the error. This made life VERY difficult. You'd write a program at home, test it to death on your machine, post it to the internet and get stacks of complaints from people who would claim that it crashed without an error message. So, as a service to mankind, ssgInit (and puInit and IIRC, fntInit) all check that there is a valid rendering context - and if there isn't they'll complain and refuse to continue. That means that even if your OpenGL implementation is a 'tolerant' one, you'll find the error in your program and fix it so that other people will be able to run it too. I think that's "A Good Thing" - and since we've added it, the number of mysterious crashes inside PLIB on startup have been reduced *GREATLY* because people now get a good error message instead. Now, along comes an OpenGL implementation with a bug in it...what should I do? My decision: Tell people to FIX THE BUG!! I'm not about to remove a valuable bug-tracer that's proved useful (especially to PrettyPoly which has a very hard time with keeping the startup sequence right and maintaining a valid OpenGL rendering context at all times). CONCLUSION: PLIB is not in error here...it works very well on other versions of Mesa and on non-Mesa OpenGL implementations. So - I make no apologies - please bitch and whine to the Mesa team (only be gentle with Brian Paul - he's not getting paid to maintain Mesa anymore :-( ...so we have to be nice to him if we want to get things fixed! :-) FOOTNOTE: If you are *desperate*, look for 'glXGetCurrentContext' in src/ssg/ssg.cxx, src/fnt/fntTXF.cxx and src/pui/pu.cxx and make the necessary *HACK* - but please don't distribute that hack to all and sundry because it'll make our lives hell again. If it were me, I'd go to an earlier or later version of Mesa - who knows what else is broken as a consequence of this? ----------------------------- Steve Baker ------------------------------- HomeMail : <sjb...@ai...> WorkMail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sf.net http://tuxaqfh.sf.net http://prettypoly.sf.net http://tuxkart.sf.net http://freeglut.sf.net http://toobular.sf.net |