hi all.
i am currently skipping through the code and trying to replace pre-processor checks by runtime checks.
i see a lot of references to HaveValidContext() in __APPLE__. i think some of them are obsolete or leftovers.
what bothers me a bit is, that whenver HaveValidContext is used, there is also an include for <AGL/agl.h>. is this necessary or is it just a copy'n'paste leftover? (i think there is nothing special in most of these files which would require AGL)
also i noticed that <Carbon/Carbon.h> and <AGL/agl.h> are included using the #import directive, which i think is ugly. are these 2 files save to include more than once?
mf.asdr IOhannes
Those checks are to prevent crashes when making GL calls without a context. On the Mac side the context is created with the first window creation so any object with GL calls in the creator method will often crash when loading a patch before having a window. Jamie has done something which creates a context when GEM loads and removes the need for these checks but I don't know if it's tested and ready or not.
cgc
On 1/30/06, IOhannes m zmoelnig zmoelnig@iem.at wrote:
hi all.
i am currently skipping through the code and trying to replace pre-processor checks by runtime checks.
i see a lot of references to HaveValidContext() in __APPLE__. i think some of them are obsolete or leftovers.
what bothers me a bit is, that whenver HaveValidContext is used, there is also an include for <AGL/agl.h>. is this necessary or is it just a copy'n'paste leftover? (i think there is nothing special in most of these files which would require AGL)
also i noticed that <Carbon/Carbon.h> and <AGL/agl.h> are included using the #import directive, which i think is ugly. are these 2 files save to include more than once?
mf.asdr IOhannes
GEM-dev mailing list GEM-dev@iem.at http://lists.puredata.info/listinfo/gem-dev
chris clepper wrote:
Those checks are to prevent crashes when making GL calls without a context. On the Mac side the context is created with the first window creation so any object with GL calls in the creator method will often
well, i did not try to question the HaveValidContext as such (i imagined that it was pretty important, otherwise it wouldn't be there)
my first idea was to add a haveValidContext field to GemState - however, i think there is (currently) _always_ a valid context when the render() method of an object is called.
most occurences of the valid-context querying are when it comes to loading something (a vertex_program, a model,...): probably the best solution for this would be to defer the loading until the actual the rendering starts (which would ensure that we have a context); so the users don't have to worry about the right time to click on the "open" button.
however what remains unclear is why there is the AGL-reference alongside the HaveValidContext() declaration? (e.g. in Geos/imageVert.cpp) unfortunately i wasn't able to find an AGL/agl.h reference-file on the web...so i don't know which magic happens in there.
crash when loading a patch before having a window. Jamie has done something which creates a context when GEM loads and removes the need for these checks but I don't know if it's tested and ready or not.
that might be very nice
mf.asdr IOhannes
hi IO,
On Jan 30, 2006, at 10:40 AM, IOhannes m zmoelnig wrote:
i am currently skipping through the code and trying to replace pre- processor checks by runtime checks.
i see a lot of references to HaveValidContext() in __APPLE__. i think some of them are obsolete or leftovers.
...this is necessary currently in order to prevent GEM crashing when making gl calls without a context (ie. before a window is created)...this usually happens when using media that isn't loaded...apple has a strict interpretation of opengl, so it doesn't allow gl commands to be silently ignored...
...the good news is that while working recently on the multiple_windows branch, I came up with a way to initialize a "master context" at GemMan::initGem(), which creates a minimal gl context that is never directly associated with a glwindow, but instead is shared when creating actual windows (and their associated context)...this removes the need for the HaveValidContext() stuff altogether, plus it allows sharing of resources between contexts (so it's easier to swap things back and forth between offscreen & onscreen contexts)...
...the bad news is that I haven't committed it to cvs: will try to get that today...
what bothers me a bit is, that whenver HaveValidContext is used, there is also an include for <AGL/agl.h>. is this necessary or is it just a copy'n'paste leftover? (i think there is nothing special in most of these files which would require AGL)
...yeh, that's mostly just cut n'paste: <AGL/agl.h> only needs one inclusion...
also i noticed that <Carbon/Carbon.h> and <AGL/agl.h> are included using the #import directive, which i think is ugly. are these 2 files save to include more than once?
...yes, they're safe...#import is really supposed to be for obj-c, but it as far as I know it's equivalent to #include in the eyes of gcc when doing non-obj-c code...
...so to sum up: you're finding a lot of archeology of my "beginning to learning to code"...enjoy!
jamie