|
@@ -35,13 +35,13 @@ osxOpenGLDevice::osxOpenGLDevice()
|
|
|
|
|
|
// pick a monitor to run on
|
|
// pick a monitor to run on
|
|
enumMonitors();
|
|
enumMonitors();
|
|
-
|
|
|
|
|
|
+
|
|
platState = [osxPlatState sharedPlatState];
|
|
platState = [osxPlatState sharedPlatState];
|
|
-
|
|
|
|
|
|
+
|
|
CGDirectDisplayID display = chooseMonitor();
|
|
CGDirectDisplayID display = chooseMonitor();
|
|
-
|
|
|
|
|
|
+
|
|
[platState setCgDisplay:display];
|
|
[platState setCgDisplay:display];
|
|
-
|
|
|
|
|
|
+
|
|
enumDisplayModes(display);
|
|
enumDisplayModes(display);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -51,28 +51,28 @@ bool osxOpenGLDevice::enumDisplayModes( CGDirectDisplayID display )
|
|
{
|
|
{
|
|
// Clear the resolution list.
|
|
// Clear the resolution list.
|
|
mResolutionList.clear();
|
|
mResolutionList.clear();
|
|
-
|
|
|
|
|
|
+
|
|
// Fetch a list of all available modes for the specified display.
|
|
// Fetch a list of all available modes for the specified display.
|
|
CFArrayRef modeArray = CGDisplayCopyAllDisplayModes(display, NULL);
|
|
CFArrayRef modeArray = CGDisplayCopyAllDisplayModes(display, NULL);
|
|
-
|
|
|
|
|
|
+
|
|
// Fetch the mode count.
|
|
// Fetch the mode count.
|
|
const S32 modeCount = (const S32)CFArrayGetCount(modeArray);
|
|
const S32 modeCount = (const S32)CFArrayGetCount(modeArray);
|
|
-
|
|
|
|
|
|
+
|
|
// Iterate the modes.
|
|
// Iterate the modes.
|
|
for( S32 modeIndex = 0; modeIndex < modeCount; modeIndex++ )
|
|
for( S32 modeIndex = 0; modeIndex < modeCount; modeIndex++ )
|
|
{
|
|
{
|
|
// Fetch the display mode.
|
|
// Fetch the display mode.
|
|
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeArray, modeIndex);
|
|
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modeArray, modeIndex);
|
|
-
|
|
|
|
|
|
+
|
|
// Get the mode width.
|
|
// Get the mode width.
|
|
const S32 width = (const S32)CGDisplayModeGetWidth(mode);
|
|
const S32 width = (const S32)CGDisplayModeGetWidth(mode);
|
|
-
|
|
|
|
|
|
+
|
|
// Get the mode height.
|
|
// Get the mode height.
|
|
const S32 height = (const S32)CGDisplayModeGetHeight(mode);
|
|
const S32 height = (const S32)CGDisplayModeGetHeight(mode);
|
|
-
|
|
|
|
|
|
+
|
|
// Get the pixel encoding.
|
|
// Get the pixel encoding.
|
|
CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
|
|
CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode);
|
|
-
|
|
|
|
|
|
+
|
|
// Is it a 32 bpp?
|
|
// Is it a 32 bpp?
|
|
S32 bitDepth;
|
|
S32 bitDepth;
|
|
if ( CFStringCompare( pixelEncoding, CFSTR(IO32BitDirectPixels), 0 ) == kCFCompareEqualTo )
|
|
if ( CFStringCompare( pixelEncoding, CFSTR(IO32BitDirectPixels), 0 ) == kCFCompareEqualTo )
|
|
@@ -110,7 +110,7 @@ bool osxOpenGLDevice::enumDisplayModes( CGDirectDisplayID display )
|
|
// Store the resolution.
|
|
// Store the resolution.
|
|
mResolutionList.push_back( Resolution( width, height, bitDepth ) );
|
|
mResolutionList.push_back( Resolution( width, height, bitDepth ) );
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -125,9 +125,9 @@ void osxOpenGLDevice::initDevice()
|
|
bool osxOpenGLDevice::cleanUpContext()
|
|
bool osxOpenGLDevice::cleanUpContext()
|
|
{
|
|
{
|
|
bool needResurrect = false;
|
|
bool needResurrect = false;
|
|
-
|
|
|
|
|
|
+
|
|
platState = [osxPlatState sharedPlatState];
|
|
platState = [osxPlatState sharedPlatState];
|
|
-
|
|
|
|
|
|
+
|
|
if ([[platState torqueView] contextInitialized])
|
|
if ([[platState torqueView] contextInitialized])
|
|
{
|
|
{
|
|
if (!Video::smNeedResurrect)
|
|
if (!Video::smNeedResurrect)
|
|
@@ -136,33 +136,33 @@ bool osxOpenGLDevice::cleanUpContext()
|
|
Game->textureKill();
|
|
Game->textureKill();
|
|
needResurrect = true;
|
|
needResurrect = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
[[platState torqueView] clearContext];
|
|
[[platState torqueView] clearContext];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// clear the Resolution state, so setScreenMode() will know not to early-out.
|
|
// clear the Resolution state, so setScreenMode() will know not to early-out.
|
|
smCurrentRes = Resolution(0, 0, 0);
|
|
smCurrentRes = Resolution(0, 0, 0);
|
|
-
|
|
|
|
|
|
+
|
|
return needResurrect;
|
|
return needResurrect;
|
|
}
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
-//
|
|
|
|
|
|
+//
|
|
bool osxOpenGLDevice::activate( U32 width, U32 height, U32 bpp, bool fullScreen )
|
|
bool osxOpenGLDevice::activate( U32 width, U32 height, U32 bpp, bool fullScreen )
|
|
{
|
|
{
|
|
Con::printf( " OpenGLDevice activating..." );
|
|
Con::printf( " OpenGLDevice activating..." );
|
|
-
|
|
|
|
|
|
+
|
|
// gets opengl rendering capabilities of the screen pointed to by platState.hDisplay
|
|
// gets opengl rendering capabilities of the screen pointed to by platState.hDisplay
|
|
// sets up dgl with the capabilities info, & reports opengl status.
|
|
// sets up dgl with the capabilities info, & reports opengl status.
|
|
getGLCapabilities();
|
|
getGLCapabilities();
|
|
-
|
|
|
|
|
|
+
|
|
// Create the window or capture fullscreen
|
|
// Create the window or capture fullscreen
|
|
if(!setScreenMode(width, height, bpp, fullScreen, true, false))
|
|
if(!setScreenMode(width, height, bpp, fullScreen, true, false))
|
|
return false;
|
|
return false;
|
|
-
|
|
|
|
|
|
+
|
|
// set the displayDevice pref to "OpenGL"
|
|
// set the displayDevice pref to "OpenGL"
|
|
Con::setVariable( "$pref::Video::displayDevice", mDeviceName );
|
|
Con::setVariable( "$pref::Video::displayDevice", mDeviceName );
|
|
-
|
|
|
|
|
|
+
|
|
// set vertical sync now because it doesnt need setting every time we setScreenMode()
|
|
// set vertical sync now because it doesnt need setting every time we setScreenMode()
|
|
setVerticalSync( !Con::getBoolVariable( "$pref::Video::disableVerticalSync" ));
|
|
setVerticalSync( !Con::getBoolVariable( "$pref::Video::disableVerticalSync" ));
|
|
|
|
|
|
@@ -182,22 +182,22 @@ void osxOpenGLDevice::shutdown()
|
|
NSOpenGLPixelFormat* osxOpenGLDevice::generateValidPixelFormat(bool fullscreen, U32 bpp, U32 samples)
|
|
NSOpenGLPixelFormat* osxOpenGLDevice::generateValidPixelFormat(bool fullscreen, U32 bpp, U32 samples)
|
|
{
|
|
{
|
|
AssertWarn(samples <= 6, "An unusual multisample depth was requested in findValidPixelFormat(). clamping to 0...6");
|
|
AssertWarn(samples <= 6, "An unusual multisample depth was requested in findValidPixelFormat(). clamping to 0...6");
|
|
-
|
|
|
|
|
|
+
|
|
samples = samples > 6 ? 6 : samples;
|
|
samples = samples > 6 ? 6 : samples;
|
|
-
|
|
|
|
|
|
+
|
|
int i = 0;
|
|
int i = 0;
|
|
NSOpenGLPixelFormatAttribute attr[64];
|
|
NSOpenGLPixelFormatAttribute attr[64];
|
|
-
|
|
|
|
|
|
+
|
|
attr[i++] = NSOpenGLPFADoubleBuffer;
|
|
attr[i++] = NSOpenGLPFADoubleBuffer;
|
|
attr[i++] = NSOpenGLPFANoRecovery;
|
|
attr[i++] = NSOpenGLPFANoRecovery;
|
|
attr[i++] = NSOpenGLPFAAccelerated;
|
|
attr[i++] = NSOpenGLPFAAccelerated;
|
|
-
|
|
|
|
|
|
+
|
|
if(bpp != 0)
|
|
if(bpp != 0)
|
|
{
|
|
{
|
|
// native pixel formats are argb 1555 & argb 8888.
|
|
// native pixel formats are argb 1555 & argb 8888.
|
|
U32 colorbits = 0;
|
|
U32 colorbits = 0;
|
|
U32 alphabits = 0;
|
|
U32 alphabits = 0;
|
|
-
|
|
|
|
|
|
+
|
|
if(bpp == 16)
|
|
if(bpp == 16)
|
|
{
|
|
{
|
|
colorbits = 5; // ARGB 1555
|
|
colorbits = 5; // ARGB 1555
|
|
@@ -205,7 +205,7 @@ NSOpenGLPixelFormat* osxOpenGLDevice::generateValidPixelFormat(bool fullscreen,
|
|
}
|
|
}
|
|
else if(bpp == 32)
|
|
else if(bpp == 32)
|
|
colorbits = alphabits = 8; // ARGB 8888
|
|
colorbits = alphabits = 8; // ARGB 8888
|
|
-
|
|
|
|
|
|
+
|
|
attr[i++] = NSOpenGLPFADepthSize;
|
|
attr[i++] = NSOpenGLPFADepthSize;
|
|
attr[i++] = (NSOpenGLPixelFormatAttribute)bpp;
|
|
attr[i++] = (NSOpenGLPixelFormatAttribute)bpp;
|
|
attr[i++] = NSOpenGLPFAColorSize;
|
|
attr[i++] = NSOpenGLPFAColorSize;
|
|
@@ -213,7 +213,7 @@ NSOpenGLPixelFormat* osxOpenGLDevice::generateValidPixelFormat(bool fullscreen,
|
|
attr[i++] = NSOpenGLPFAAlphaSize;
|
|
attr[i++] = NSOpenGLPFAAlphaSize;
|
|
attr[i++] = (NSOpenGLPixelFormatAttribute)alphabits;
|
|
attr[i++] = (NSOpenGLPixelFormatAttribute)alphabits;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (samples != 0)
|
|
if (samples != 0)
|
|
{
|
|
{
|
|
attr[i++] = NSOpenGLPFAMultisample;
|
|
attr[i++] = NSOpenGLPFAMultisample;
|
|
@@ -221,11 +221,11 @@ NSOpenGLPixelFormat* osxOpenGLDevice::generateValidPixelFormat(bool fullscreen,
|
|
attr[i++] = NSOpenGLPFASamples;
|
|
attr[i++] = NSOpenGLPFASamples;
|
|
attr[i++] = (NSOpenGLPixelFormatAttribute)samples;
|
|
attr[i++] = (NSOpenGLPixelFormatAttribute)samples;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
attr[i++] = 0;
|
|
attr[i++] = 0;
|
|
-
|
|
|
|
|
|
+
|
|
NSOpenGLPixelFormat* format = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
|
|
NSOpenGLPixelFormat* format = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
|
|
-
|
|
|
|
|
|
+
|
|
return format;
|
|
return format;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -238,93 +238,93 @@ bool osxOpenGLDevice::setScreenMode( U32 width, U32 height, U32 bpp, bool fullSc
|
|
fullScreen ? "fullscreen" : "windowed",
|
|
fullScreen ? "fullscreen" : "windowed",
|
|
forceIt ? "force it" : "dont force it",
|
|
forceIt ? "force it" : "dont force it",
|
|
repaint ? "repaint" : "dont repaint");
|
|
repaint ? "repaint" : "dont repaint");
|
|
-
|
|
|
|
|
|
+
|
|
bool needResurrect = cleanUpContext();
|
|
bool needResurrect = cleanUpContext();
|
|
-
|
|
|
|
|
|
+
|
|
// Get the global OSX platform state
|
|
// Get the global OSX platform state
|
|
osxPlatState * platState = [osxPlatState sharedPlatState];
|
|
osxPlatState * platState = [osxPlatState sharedPlatState];
|
|
-
|
|
|
|
|
|
+
|
|
// Validation, early outs
|
|
// Validation, early outs
|
|
// Sanity check. Some scripts are liable to pass in bad values.
|
|
// Sanity check. Some scripts are liable to pass in bad values.
|
|
if (!bpp)
|
|
if (!bpp)
|
|
bpp = [platState desktopBitsPixel];
|
|
bpp = [platState desktopBitsPixel];
|
|
-
|
|
|
|
|
|
+
|
|
if (bpp)
|
|
if (bpp)
|
|
bpp = bpp > 16 ? 32 : 16;
|
|
bpp = bpp > 16 ? 32 : 16;
|
|
-
|
|
|
|
|
|
+
|
|
Resolution newRes = Resolution(width, height, bpp);
|
|
Resolution newRes = Resolution(width, height, bpp);
|
|
-
|
|
|
|
|
|
+
|
|
// If no values changing and we're not forcing a change, kick out. prevents thrashing.
|
|
// If no values changing and we're not forcing a change, kick out. prevents thrashing.
|
|
if (!forceIt && smIsFullScreen == fullScreen && smCurrentRes == newRes)
|
|
if (!forceIt && smIsFullScreen == fullScreen && smCurrentRes == newRes)
|
|
return true;
|
|
return true;
|
|
-
|
|
|
|
|
|
+
|
|
// Create a pixel format to be used with the context
|
|
// Create a pixel format to be used with the context
|
|
NSOpenGLPixelFormat* pixelFormat = generateValidPixelFormat(fullScreen, bpp, 0);
|
|
NSOpenGLPixelFormat* pixelFormat = generateValidPixelFormat(fullScreen, bpp, 0);
|
|
-
|
|
|
|
|
|
+
|
|
if (!pixelFormat)
|
|
if (!pixelFormat)
|
|
{
|
|
{
|
|
Con::printf("osxOpenGLDevice::setScreenMode error: No OpenGL pixel format");
|
|
Con::printf("osxOpenGLDevice::setScreenMode error: No OpenGL pixel format");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
[platState setFullScreen:fullScreen];
|
|
[platState setFullScreen:fullScreen];
|
|
-
|
|
|
|
|
|
+
|
|
if (fullScreen)
|
|
if (fullScreen)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
NSRect mainDisplayRect = [[NSScreen mainScreen] frame];
|
|
NSRect mainDisplayRect = [[NSScreen mainScreen] frame];
|
|
-
|
|
|
|
|
|
+
|
|
newRes.w = mainDisplayRect.size.width;
|
|
newRes.w = mainDisplayRect.size.width;
|
|
newRes.h = mainDisplayRect.size.height;
|
|
newRes.h = mainDisplayRect.size.height;
|
|
-
|
|
|
|
|
|
+
|
|
[[platState window] setStyleMask:NSBorderlessWindowMask];
|
|
[[platState window] setStyleMask:NSBorderlessWindowMask];
|
|
-
|
|
|
|
|
|
+
|
|
[[platState window] setFrame:mainDisplayRect display:YES];
|
|
[[platState window] setFrame:mainDisplayRect display:YES];
|
|
-
|
|
|
|
|
|
+
|
|
[[platState window] setLevel:NSMainMenuWindowLevel+1];
|
|
[[platState window] setLevel:NSMainMenuWindowLevel+1];
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
|
[[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask] ;
|
|
[[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask] ;
|
|
-
|
|
|
|
|
|
+
|
|
// Calculate the actual center
|
|
// Calculate the actual center
|
|
CGFloat x = ([[NSScreen mainScreen] frame].size.width - width) / 2;
|
|
CGFloat x = ([[NSScreen mainScreen] frame].size.width - width) / 2;
|
|
CGFloat y = ([[NSScreen mainScreen] frame].size.height - height) / 2;
|
|
CGFloat y = ([[NSScreen mainScreen] frame].size.height - height) / 2;
|
|
-
|
|
|
|
|
|
+
|
|
// Create a rect to send to the window
|
|
// Create a rect to send to the window
|
|
NSRect newFrame = NSMakeRect(x, y, width, height);
|
|
NSRect newFrame = NSMakeRect(x, y, width, height);
|
|
-
|
|
|
|
|
|
+
|
|
// Send message to the window to resize/relocate
|
|
// Send message to the window to resize/relocate
|
|
[[platState window] setFrame:newFrame display:YES animate:NO];
|
|
[[platState window] setFrame:newFrame display:YES animate:NO];
|
|
#else
|
|
#else
|
|
[[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask];
|
|
[[platState window] setStyleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask];
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
[[platState torqueView] createContextWithPixelFormat:pixelFormat];
|
|
[[platState torqueView] createContextWithPixelFormat:pixelFormat];
|
|
-
|
|
|
|
|
|
+
|
|
[platState setWindowSize:newRes.w height:newRes.h];
|
|
[platState setWindowSize:newRes.w height:newRes.h];
|
|
-
|
|
|
|
|
|
+
|
|
// clear out garbage from the gl window.
|
|
// clear out garbage from the gl window.
|
|
glClearColor(0,0,0,1);
|
|
glClearColor(0,0,0,1);
|
|
glClear(GL_COLOR_BUFFER_BIT );
|
|
glClear(GL_COLOR_BUFFER_BIT );
|
|
-
|
|
|
|
|
|
+
|
|
// set opengl options & other options ---------------------------------------
|
|
// set opengl options & other options ---------------------------------------
|
|
// ensure data is packed tightly in memory. this defaults to 4.
|
|
// ensure data is packed tightly in memory. this defaults to 4.
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
-
|
|
|
|
|
|
+
|
|
// TODO: set gl arb multisample enable & hint
|
|
// TODO: set gl arb multisample enable & hint
|
|
//dglSetFSAASamples(gFSAASamples);
|
|
//dglSetFSAASamples(gFSAASamples);
|
|
-
|
|
|
|
|
|
+
|
|
// update smIsFullScreen and pref
|
|
// update smIsFullScreen and pref
|
|
smIsFullScreen = fullScreen;
|
|
smIsFullScreen = fullScreen;
|
|
-
|
|
|
|
|
|
+
|
|
Con::setBoolVariable( "$pref::Video::fullScreen", smIsFullScreen );
|
|
Con::setBoolVariable( "$pref::Video::fullScreen", smIsFullScreen );
|
|
-
|
|
|
|
|
|
+
|
|
// save resolution
|
|
// save resolution
|
|
smCurrentRes = newRes;
|
|
smCurrentRes = newRes;
|
|
-
|
|
|
|
|
|
+
|
|
// save resolution to prefs
|
|
// save resolution to prefs
|
|
char buf[32];
|
|
char buf[32];
|
|
if (fullScreen)
|
|
if (fullScreen)
|
|
@@ -337,17 +337,17 @@ bool osxOpenGLDevice::setScreenMode( U32 width, U32 height, U32 bpp, bool fullSc
|
|
dSprintf( buf, sizeof(buf), "%d %d", newRes.w, newRes.h);
|
|
dSprintf( buf, sizeof(buf), "%d %d", newRes.w, newRes.h);
|
|
Con::setVariable("$pref::Video::windowedRes", buf);
|
|
Con::setVariable("$pref::Video::windowedRes", buf);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (needResurrect)
|
|
if (needResurrect)
|
|
{
|
|
{
|
|
// Reload the textures gl names
|
|
// Reload the textures gl names
|
|
Con::printf( "Resurrecting the texture manager..." );
|
|
Con::printf( "Resurrecting the texture manager..." );
|
|
Game->textureResurrect();
|
|
Game->textureResurrect();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if( repaint )
|
|
if( repaint )
|
|
- Con::evaluate( "resetCanvas();" );
|
|
|
|
-
|
|
|
|
|
|
+ Video::resetCanvas();
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -357,12 +357,12 @@ void osxOpenGLDevice::swapBuffers()
|
|
{
|
|
{
|
|
if ([[platState torqueView] contextInitialized])
|
|
if ([[platState torqueView] contextInitialized])
|
|
[[platState torqueView] flushBuffer];
|
|
[[platState torqueView] flushBuffer];
|
|
-
|
|
|
|
|
|
+
|
|
#if defined(TORQUE_DEBUG)
|
|
#if defined(TORQUE_DEBUG)
|
|
if (gOutlineEnabled)
|
|
if (gOutlineEnabled)
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
@@ -374,20 +374,20 @@ const char* osxOpenGLDevice::getDriverInfo()
|
|
const char* rendererString = (const char*) glGetString( GL_RENDERER );
|
|
const char* rendererString = (const char*) glGetString( GL_RENDERER );
|
|
const char* versionString = (const char*) glGetString( GL_VERSION );
|
|
const char* versionString = (const char*) glGetString( GL_VERSION );
|
|
const char* extensionsString = (const char*) glGetString( GL_EXTENSIONS );
|
|
const char* extensionsString = (const char*) glGetString( GL_EXTENSIONS );
|
|
-
|
|
|
|
|
|
+
|
|
U32 bufferLen = ( vendorString ? dStrlen( vendorString ) : 0 )
|
|
U32 bufferLen = ( vendorString ? dStrlen( vendorString ) : 0 )
|
|
+ ( rendererString ? dStrlen( rendererString ) : 0 )
|
|
+ ( rendererString ? dStrlen( rendererString ) : 0 )
|
|
+ ( versionString ? dStrlen( versionString ) : 0 )
|
|
+ ( versionString ? dStrlen( versionString ) : 0 )
|
|
+ ( extensionsString ? dStrlen( extensionsString ) : 0 )
|
|
+ ( extensionsString ? dStrlen( extensionsString ) : 0 )
|
|
+ 4;
|
|
+ 4;
|
|
-
|
|
|
|
|
|
+
|
|
char* returnString = Con::getReturnBuffer( bufferLen );
|
|
char* returnString = Con::getReturnBuffer( bufferLen );
|
|
dSprintf( returnString, bufferLen, "%s\t%s\t%s\t%s",
|
|
dSprintf( returnString, bufferLen, "%s\t%s\t%s\t%s",
|
|
( vendorString ? vendorString : "" ),
|
|
( vendorString ? vendorString : "" ),
|
|
( rendererString ? rendererString : "" ),
|
|
( rendererString ? rendererString : "" ),
|
|
( versionString ? versionString : "" ),
|
|
( versionString ? versionString : "" ),
|
|
( extensionsString ? extensionsString : "" ) );
|
|
( extensionsString ? extensionsString : "" ) );
|
|
-
|
|
|
|
|
|
+
|
|
return( returnString );
|
|
return( returnString );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -413,7 +413,7 @@ bool osxOpenGLDevice::getVerticalSync()
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//Note that this returns the number of frames between Swaps.
|
|
//Note that this returns the number of frames between Swaps.
|
|
//The function returns 0 / false if SwapInterval has not been specified.
|
|
//The function returns 0 / false if SwapInterval has not been specified.
|
|
return getVerticalSync();
|
|
return getVerticalSync();
|
|
@@ -442,18 +442,18 @@ bool osxOpenGLDevice::enumMonitors()
|
|
{
|
|
{
|
|
mMonitorList.clear();
|
|
mMonitorList.clear();
|
|
nAllDevs = 0;
|
|
nAllDevs = 0;
|
|
-
|
|
|
|
|
|
+
|
|
CGDirectDisplayID _displayIDs[32];
|
|
CGDirectDisplayID _displayIDs[32];
|
|
uint32_t _displayCount;
|
|
uint32_t _displayCount;
|
|
-
|
|
|
|
|
|
+
|
|
CGGetActiveDisplayList (32, _displayIDs, &_displayCount);
|
|
CGGetActiveDisplayList (32, _displayIDs, &_displayCount);
|
|
-
|
|
|
|
|
|
+
|
|
for (int ii = 0 ; ii < _displayCount ; ii++)
|
|
for (int ii = 0 ; ii < _displayCount ; ii++)
|
|
{
|
|
{
|
|
mMonitorList.push_back(_displayIDs[ii]);
|
|
mMonitorList.push_back(_displayIDs[ii]);
|
|
allDevs[nAllDevs++] = _displayIDs[ii];
|
|
allDevs[nAllDevs++] = _displayIDs[ii];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -466,17 +466,17 @@ CGDirectDisplayID osxOpenGLDevice::chooseMonitor()
|
|
// TODO: choose monitor based on which one contains most of the window.
|
|
// TODO: choose monitor based on which one contains most of the window.
|
|
// NOTE: do not call cleanup before calling choose, or we won't have a window to consider.
|
|
// NOTE: do not call cleanup before calling choose, or we won't have a window to consider.
|
|
AssertFatal(!mMonitorList.empty(), "Cannot choose a monitor if the list is empty!");
|
|
AssertFatal(!mMonitorList.empty(), "Cannot choose a monitor if the list is empty!");
|
|
-
|
|
|
|
|
|
+
|
|
U32 monNum = Con::getIntVariable("$pref::Video::monitorNum", 0);
|
|
U32 monNum = Con::getIntVariable("$pref::Video::monitorNum", 0);
|
|
-
|
|
|
|
|
|
+
|
|
if (monNum >= mMonitorList.size())
|
|
if (monNum >= mMonitorList.size())
|
|
{
|
|
{
|
|
Con::errorf("invalid monitor number %i", monNum);
|
|
Con::errorf("invalid monitor number %i", monNum);
|
|
monNum = 0;
|
|
monNum = 0;
|
|
Con::setIntVariable("$pref::Video::monitorNum", 0);
|
|
Con::setIntVariable("$pref::Video::monitorNum", 0);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Con::printf("using display 0x%x", mMonitorList[monNum]);
|
|
Con::printf("using display 0x%x", mMonitorList[monNum]);
|
|
-
|
|
|
|
|
|
+
|
|
return mMonitorList[monNum];
|
|
return mMonitorList[monNum];
|
|
-}
|
|
|
|
|
|
+}
|