iDevGames Forums
RezLib on OSX - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: RezLib on OSX (/thread-7742.html)



RezLib on OSX - monteboyd - May 25, 2002 08:55 PM

The last thing I need to get working in my Snowboarding game before I announce a beta version is resolution switching. I'm using RezLib to do this and under OS9 it works fine but under OSX it gives me this error:

rlDirectDisplayAPINotAvailable

About which the docs say:

"RezLib could not run because the DirectDisplay API could not be loaded. The
CoreGraphics framework may not be installed or may be installed in the wrong place. Should only affect MacOS X and later systems."

Does anyone know how I could check if the CoreGraphics framework is installed properly?

Or does anyone know another reason I might be getting this error? I've never done anything but a standard install of OSX so maybe something else is causing it?


RezLib on OSX - Tobi - May 25, 2002 11:50 PM

I can't help you with your RezLib problem, but here's an alternative for the resolution switching under OS X:
Code:
CGDirectDisplayID    dispID;
int bitDepth=16;
int width=640;
int height=480;

CGGetActiveDisplayList(1, &dispID, NULL);
CGDisplaySwitchToMode(dispID, CGDisplayBestModeForParameters(dispID, bitDepth, width, height, NULL));
This stuff is inside the CoreGraphics framework which is in the Application Services framework.

Good luck,

-Tobi


RezLib on OSX - monteboyd - May 26, 2002 04:00 PM

Thanks for that Tobi, but my game is Carbon, and that code is OSX only. That's why RezLib is so useful, because it handles res switching on both 9 and X.

Maybe I should ask on the mac-game-dev list instead, Ian Ollman often responds there, and it is his library.


RezLib on OSX - Tobi - May 26, 2002 10:12 PM

That's not a problem. These functions are Carbon APIs. If you compiling with at least CW 6 they should work. In Project Builder it's no problem at all, but you can't compile programs that run under Classic so I guess you use some sort of CodeWarrior.
I guess you are compiling 2 different binaries: One for OS X (using Carbon) and one for Mac OS Classic.
But if you put everything into one binary, you could do a check if you run on OS X and switch the screen with these functions, and otherwise with RezLib. Just like this:

Code:
void ChangeScreenRes(int bitDepth, int width, int height)
{
#ifdef __APPLE_CC__
//Running on OS X

CGDirectDisplayID    dispID;

CGGetActiveDisplayList(1, &dispID, NULL);
CGDisplaySwitchToMode(dispID, CGDisplayBestModeForParameters(dispID, bitDepth, width, height, NULL));
#else
DoTheChangeWithRezLib(bitDepth, width, height);
#endif
}

Code should work, try it out.


RezLib on OSX - monteboyd - May 26, 2002 10:30 PM

I'm compiling one Carbon program using MPW on OS9. The reason I thought those functions were OSX only is because the header file which contains them says they are not available under Carbon, only OSX?


RezLib on OSX - monteboyd - May 27, 2002 06:11 AM

I now have my answer to this question, it seems I was using a very old version of RezLib and everything works fine with the latest version.

Thanks for the help anyway Tobi.