osx buildfix, add resolutions to ogl dialog

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5363 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2010-04-14 04:32:59 +00:00
parent ba89d91872
commit 0dc924efef

View File

@ -95,6 +95,10 @@ GFXDebuggerOGL *m_DebuggerFrame = NULL;
#include "VideoState.h" #include "VideoState.h"
#if defined(HAVE_COCOA) && HAVE_COCOA
#include <Cocoa/Cocoa.h>
#endif
SVideoInitialize g_VideoInitialize; SVideoInitialize g_VideoInitialize;
PLUGIN_GLOBALS* globals = NULL; PLUGIN_GLOBALS* globals = NULL;
@ -166,47 +170,34 @@ void DllDebugger(HWND _hParent, bool Show)
#endif #endif
} }
#ifdef _WIN32 // Search for avaliable resolutions
void AddResolutions() void AddResolutions()
{ {
// Search for avaliable resolutions #ifdef _WIN32
DWORD iModeNum = 0; DWORD iModeNum = 0;
DEVMODE dmi; DEVMODE dmi;
ZeroMemory(&dmi, sizeof(dmi)); ZeroMemory(&dmi, sizeof(dmi));
dmi.dmSize = sizeof(dmi); dmi.dmSize = sizeof(dmi);
std::vector<std::string> resos; std::vector<std::string> resos;
resos.reserve(20);
int i = 0;
while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0) while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0)
{ {
char szBuffer[100]; char res[100];
sprintf(szBuffer, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight); sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
std::string strBuffer(szBuffer); std::string strRes(res);
// Create a check loop to check every pointer of resolutions to see if // Only add unique resolutions
// the res is added or not if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
int b = 0;
bool resFound = false;
while (b < i && !resFound)
{ {
// Is the res already added? resos.push_back(strRes);
resFound = (resos[b] == strBuffer); m_ConfigFrame->AddFSReso(res);
b++;
}
// Add the resolution
if (!resFound && i < 100) // don't want to overflow resos array. not
// likely to happen, but you never know.
{
resos.push_back(strBuffer);
i++;
m_ConfigFrame->AddFSReso(szBuffer);
} }
ZeroMemory(&dmi, sizeof(dmi)); ZeroMemory(&dmi, sizeof(dmi));
} }
}
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_XRANDR) && HAVE_XRANDR #elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_XRANDR) \
void AddResolutions() { && HAVE_XRANDR && defined(HAVE_WX) && HAVE_WX
// Don't modify GLWin.dpy here. // Don't modify GLWin.dpy here.
// If the emulator is running that is bad. // If the emulator is running that is bad.
Display *dpy; Display *dpy;
@ -225,53 +216,41 @@ void AddResolutions() {
{ {
char temp[32]; char temp[32];
sprintf(temp,"%dx%d", sizes[i].width, sizes[i].height); sprintf(temp,"%dx%d", sizes[i].width, sizes[i].height);
#if defined(HAVE_WX) && HAVE_WX
m_ConfigFrame->AddFSReso(temp); m_ConfigFrame->AddFSReso(temp);
#endif
} }
} }
}
#elif defined(HAVE_COCOA) && HAVE_COCOA
void AddResolutions() {
CFArrayRef modes; #elif defined(HAVE_COCOA) && HAVE_COCOA && defined(HAVE_WX) && HAVE_WX
CFRange range;
CFDictionaryRef modesDict;
CFNumberRef modeValue;
int modeWidth; CGDisplayModeRef mode;
int modeHeight; CFArrayRef array;
int modeBpp; CFIndex n, i;
int modeIndex; int w, h;
int px = 0, py = 0; std::vector<std::string> resos;
modes = CGDisplayAvailableModes(CGMainDisplayID()); array = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
n = CFArrayGetCount(array);
range.location = 0; for (i = 0; i < n; i++)
range.length = CFArrayGetCount(modes); {
mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(array, i);
w = CGDisplayModeGetWidth(mode);
h = CGDisplayModeGetHeight(mode);
for (modeIndex=0; modeIndex<range.length; modeIndex++) { char res[32];
modesDict = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, modeIndex); sprintf(res,"%dx%d", w, h);
modeValue = (CFNumberRef) CFDictionaryGetValue(modesDict, kCGDisplayWidth); std::string strRes(res);
CFNumberGetValue(modeValue, kCFNumberLongType, &modeWidth); // Only add unique resolutions
modeValue = (CFNumberRef) CFDictionaryGetValue(modesDict, kCGDisplayHeight); if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
CFNumberGetValue(modeValue, kCFNumberLongType, &modeHeight); {
modeValue = (CFNumberRef) CFDictionaryGetValue(modesDict, kCGDisplayBitsPerPixel); resos.push_back(strRes);
CFNumberGetValue(modeValue, kCFNumberLongType, &modeBpp); m_ConfigFrame->AddFSReso(res);
if (px != modeWidth && py != modeHeight) {
char temp[32];
sprintf(temp,"%dx%d", modeWidth, modeHeight);
#if defined(HAVE_WX) && HAVE_WX
m_ConfigFrame->AddFSReso(temp);
#endif
px = modeWidth;
py = modeHeight;
} }
} }
} CFRelease(array);
#endif #endif
}
void DllConfig(HWND _hParent) void DllConfig(HWND _hParent)
{ {