View Full Version : Checking for the existance of OGL?
How do make sure that the user who is running your program has OpenGL correctly installed?
Nickolei
2002.05.10, 01:28 PM
I don't know the code but I can tell you where to look...
One way would be to dig through the opengl samples from apple...they have error checking for any libraries they use. I'm messing with Carbon SetUpGL, and there are examples for Cocoa also.
http://developer.apple.com/samplecode/Sample_Code/Graphics_3D.htm
Jeff Binder
2002.05.10, 05:50 PM
Correct me if I'm wrong, but in OS 9, the Finder will produce an error if a library that you link against is missing. In OS X, GL should always be there, so there's nothing to worry about. So as long as you properly report errors AGL, CGL or NSGL gives you, you should be fine.
Nimrod
2002.05.10, 06:15 PM
Originally posted by Jeff Binder
Correct me if I'm wrong, but in OS 9, the Finder will produce an error if a library that you link against is missing. In OS X, GL should always be there, so there's nothing to worry about. So as long as you properly report errors AGL, CGL or NSGL gives you, you should be fine.
The Finder will produce an error for the user, unless you weak link OpenGL, so they don't have to have OpenGL for your program to run. I think, anyway. You might want to do that if you have an alternative renderer. But for most cases, it makes sense just to link normally. And if you're using OpenGL, what are the chances you'll want it to run on a computer that has a system old enough not to have OpenGL?
NCarter
2002.05.11, 05:09 AM
The danger if with relying on linkage to produce error messages when libraries aren't found is that the system will pop up a nonsense message that the user won't understand. Then they'll throw your game in the trash because they thought it crashed!
It's better to weak link and then check for OpenGL yourself, just in case the user has foolishly pruned their system folder. This way you can put up your own explanatory dialog containing a more readable error message.
My game runs under CFM, so I do:
bool IsOpenGLAvailable()
{
return ((Ptr)aglGetVersion != (Ptr)kUnresolvedCFragSymbolAddress);
}
In conjunction with weak linking, this checks to see if the aglGetVersion() function is available at runtime. If it is, I can safely call it to see what version of AGL I have before going any further. You should only have to do this for one function in any given library, because if one function is there, they should all be.
Of course, the function above only applies to AGL under CFM. Unfortunately, I don't know what you'd do with CGL under Mach-O.
OneSadCookie
2002.05.11, 08:57 AM
If you're on MacOSX, OpenGL is always installed, so there's no need to check for its presence. This is only an issue on MacOS9 or less.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.