Re: [Plib-users] invalid OpenGL context problem
Brought to you by:
sjbaker
From: Stephen J B. <sj...@li...> - 2002-01-08 17:56:35
|
On Tue, 8 Jan 2002, Roy Wood wrote: > My only concern (not necessarily knowing what I'm talking about, of > course) is that just sleeping might not be enough-- that we might have to > call some OpenGL/glut routines to actually get things going. Yes - but that's what we have to avoid doing. The problem that this function is designed to avoid is the *extremely* common one where some application programmer accidentally calls either an SSG or an OpenGL call *before* they set up the rendering context. When they do that, you get mysterious problems that only show up on some OpenGL implementations and under some OS's. The idea here was to call this function in ssgInit() and in a couple of other 'likely' places to check that there is a valid OpenGL rendering context before we start making OpenGL calls. That way, you get a high quality error message on *all* machines - not just the ones that (justifiably) fail for such broken applications. However, if our function itself makes OpenGL calls before ascertaining that there is a valid rendering context then it will be likely to crash instead of producing the error message - which defeats the entire purpose of it's existance! > Also, I believe that the user code usually registers all the glut > callbacks before calling puInit(), so is it possible that our callbacks > might get called before PLIB has actually been initialized? That's exactly the kind of thing we are trying to prevent. > If so, then > when the callbacks call PLIB code, we're hosed. Then again, all this > occurs before we enter into glutMainLoop(), so that's likely not a > concern, is it? In a well-written application - no. The most common problem is C++ programmers who have OpenGL calls in constructor functions. You might imagine a class object representing a monster in a game who's constructor function loads the SSG model for the monster - and in the process creates an ssgTexture - which in turn calls glTexImage2D or something. Now, with that class wrapped up neatly and forgotten about, the programmer innocently writes: static Monster the_monster_under_the_bed ; ...and wonders why his program crashes (typically deep inside OpenGL where it's impossible to diagnose) - but only on certain graphics cards and under certain OS's. ---- Steve Baker (817)619-2657 (Vox/Vox-Mail) L3Com/Link Simulation & Training (817)619-2466 (Fax) Work: sj...@li... http://www.link.com Home: sjb...@ai... http://www.sjbaker.org |