Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: aglSetFullScreen with 0 refresh



The most recent agl reference is unclear on this. So...

First question, what OS are the folks who have this fail running on? I suspect Mac OS X v10.1.x as there was a change in Mac OS X v10.2 to try to never fail on a bad frequency (which the docs do say will happen previously)

From my comments in the code for Mac OS X v10.2+ (yes, I do actually comment my code sometimes =) ):

// You have to get an *exact* match, or else bail (previous versions of agl)
// ggs: we are relaxing the match requirements for frequency due to the variation in monitors
// We will:
// match highest if 0 requested
// match exact or closest otherwise
// if only freq provided by monitor is 0, we will match in any case

So, in the newer versions of the OS you should never fail no matter what frequency you pass in. In Mac OS X v10.1.x and earlier you must match the exact frequency, so for compatibility in these cases, I suggest you do something like the following to find a supported frequency (if you require this compatibility)...

(note, I just edited this by hand and it may have some syntax errors but I am sure you get the idea)

Inputs
dspy: CGDirectDisplayID // target display
freq: GLsizei // target freq

// ----------

CFIndex nModes;
int j, match = -1; // no match
int foundFreq = 0;
CFArrayRef dspyDicts;

// set dspy to display of interest, look in CGDirectDisplay.h as there are lots of ways to do this
// you likely want to get an active display (see comments in CGDirectDisplay.h)
// the following assumes dspy is valid

dspyDicts = CGDisplayAvailableModes(dspy);
if(dspyDicts == NULL) return; // bail no modes for display

nModes = CFArrayGetCount(dspyDicts);
for(j = 0; j < nModes; j++) {
int val;
CFDictionaryRef modeDict;

// frequency matching logic
CFNumberGetValue(CFDictionaryGetValue(modeDict, kCGDisplayRefreshRate), kCFNumberIntType, &val);
if (val != 0) { // found an freq
if (freq == 0) { // match highest
if (val <= foundFreq) continue; // current is lower than found so no match
} else { // match closest
if (abs (val - freq) > abs (foundFreq - freq)) continue; // current is further away than found
if ((abs (val - freq) == abs (foundFreq - freq)) && (val <= foundFreq)) continue; // equal delta and lower or equal freq
}
} else if (foundFreq != 0) continue; // already have an non-zero freq

match = j;
foundFreq = val; // record current freq
}

if (match > -1)
// we found a freq (could be zero)
else
// some weird is going on as we found no frequency information in any modes

In dim3, when it doesn't run on a machine it's almost always traced to aglSetFullScreen and the refresh rate. My configs default to 640x480 @ 60, but this doesn't work on some machines (emacs, for one).

Some users have found that changing the config to 0 (from 60) makes it work. The docs don't say what happens when you use 0, though it seems to work. I'd make this the default if I thought it was a supported "just pick the best one" option.

So, what's happening here?

--
Geoff Stahl
OpenGL Engineer
Apple
_______________________________________________
mac-opengl mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac-opengl
Do not post admin requests to the list. They will be ignored.

References: 
 >aglSetFullScreen with 0 refresh (From: Brian Barnes <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.