Checking for the existance of OGL?

Moderator
Posts: 608
Joined: 2002.04
Post: #1
How do make sure that the user who is running your program has OpenGL correctly installed?
Quote this message in a reply
Member
Posts: 33
Joined: 2002.04
Post: #2
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/Sa...ics_3D.htm
Quote this message in a reply
Jeff Binder
Unregistered
 
Post: #3
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.
Quote this message in a reply
Nimrod
Unregistered
 
Post: #4
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?
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #5
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.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Checking renderer capabilities akb825 5 3,007 Apr 11, 2006 09:04 AM
Last Post: akb825
  Collision Checking Nick 8 5,380 Aug 24, 2004 11:12 AM
Last Post: Nick
  checking CPU and video card load NYGhost 2 4,407 Jul 1, 2004 10:01 PM
Last Post: SOUR-Monkey