/****************************/
/*		VIDEO MODE SAMPLE 	*/
/* (c)2004 Pangea Software  */
/* By Brian Greenstone      */
/****************************/


/****************************/
/*    PROTOTYPES            */
/****************************/


/**************************/
/*    EXTERNS             */
/**************************/

extern	Boolean						gPlayInWindow;
extern	short						gDesiredColorDepth, gDesiredRezH, gDesiredRezV;
extern	CGDirectDisplayID			gCGDisplayID;


/****************************/
/*    VARIABLES             */
/****************************/

CFBundleRef 		gBundle = nil;
IBNibRef 			gNibs = nil;


/******************** GET GAME NIB *********************/
//
// Our dialog resources are all stored in the Game.nib file.
// This code creates a reference to that .nib file so that we can
// easily get to the resources whenever we need to.
//

static void GetGameNib(void)
{
OSStatus	iErr;
			
	gBundle = CFBundleGetMainBundle();
	if (gBundle == nil)
		DoFatalAlert("\pCannot locate Main Bundle!");
		
	iErr = CreateNibReferenceWithCFBundle(gBundle, CFSTR("Game"), &gNibs);			// note:  we don't need the ".nib" extension in the filename
	if (iErr != noErr)
		DoFatalAlert("\pCreateNibReferenceWithCFBundle failed!");
}


/************************ MAIN **************************/

int main(void)
{
	GetGameNib();
	
			/* ASK USER FOR VIDEO SETTINGS */
			
	DoScreenModeDialog();

			
	if (gPlayInWindow)											// does the user simply want to play in a window?
	{
			/* JUST BRING UP A WINDOW */
	
		CreateGameWindow();	
		DoFatalAlert("\pHere's the game window!");			// bring up a message so we can see the fruits of our efforts
	}
	
	else	
	{
			/* SWITCH VIDEO MODE */

		SwitchDisplayMode(gDesiredRezH, gDesiredRezV, gDesiredColorDepth);
	
		CGDisplayRelease(gCGDisplayID);							// releasing the display allows us to do dialogs and things
		DoFatalAlert("\pHere's the new video mode!");			// bring up a message so we can see the fruits of our efforts
	}
}










