iDevGames Forums
Checking for the existance of OGL? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Checking for the existance of OGL? (/thread-7773.html)



Checking for the existance of OGL? - Josh - May 10, 2002 05:51 AM

How do make sure that the user who is running your program has OpenGL correctly installed?


Checking for the existance of OGL? - Nickolei - May 10, 2002 09:28 AM

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


Checking for the existance of OGL? - Jeff Binder - May 10, 2002 01: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.


Checking for the existance of OGL? - Nimrod - May 10, 2002 02:15 PM

Quote: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?


Checking for the existance of OGL? - NCarter - May 11, 2002 01: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:
Code:
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.


Checking for the existance of OGL? - OneSadCookie - May 11, 2002 04: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.