Don't attempt to change the display modes unless it's needed. (It's most likely a no-op, but don't even bother.)
This commit is contained in:
@@ -188,18 +188,19 @@ CString LowLevelWindow_Cocoa::TryVideoMode( const VideoModeParams& p, bool& newD
|
|||||||
m_CurrentParams.PAL = p.PAL;
|
m_CurrentParams.PAL = p.PAL;
|
||||||
m_CurrentParams.fDisplayAspectRatio = p.fDisplayAspectRatio;
|
m_CurrentParams.fDisplayAspectRatio = p.fDisplayAspectRatio;
|
||||||
|
|
||||||
#define X(x) p.x == m_CurrentParams.x
|
#define X(x) p.x != m_CurrentParams.x
|
||||||
if( X(windowed) && X(bpp) && X(width) && X(height) && X(rate) && X(vsync) )
|
const bool bRebuildContext = X(bpp) || X(windowed) || !m_Context;
|
||||||
return 0;
|
const bool bChangeMode = X(bpp) || X(width) || X(height) || X(rate);
|
||||||
|
const bool bChangeVsync = X(vsync);
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
|
if( !bRebuildContext && !bChangeMode && !bChangeVsync )
|
||||||
|
return CString();
|
||||||
|
|
||||||
POOL;
|
POOL;
|
||||||
newDeviceOut = false;
|
newDeviceOut = false;
|
||||||
|
|
||||||
NSRect contentRect = { { 0, 0 }, { p.width, p.height } };
|
NSRect contentRect = { { 0, 0 }, { p.width, p.height } };
|
||||||
const bool bRebuildContext = p.bpp != m_CurrentParams.bpp ||
|
|
||||||
!m_Context || p.windowed != m_CurrentParams.windowed;
|
|
||||||
|
|
||||||
|
|
||||||
ASSERT( p.bpp == 16 || p.bpp == 32 );
|
ASSERT( p.bpp == 16 || p.bpp == 32 );
|
||||||
|
|
||||||
@@ -237,10 +238,11 @@ CString LowLevelWindow_Cocoa::TryVideoMode( const VideoModeParams& p, bool& newD
|
|||||||
|
|
||||||
return CString();
|
return CString();
|
||||||
}
|
}
|
||||||
|
if( bChangeMode )
|
||||||
|
{
|
||||||
int result = ChangeDisplayMode( p );
|
int result = ChangeDisplayMode( p );
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
{
|
|
||||||
return ssprintf( "Failed to switch to full screen:%d x %d @ %d. Error %d.",
|
return ssprintf( "Failed to switch to full screen:%d x %d @ %d. Error %d.",
|
||||||
p.width, p.height, p.rate, result );
|
p.width, p.height, p.rate, result );
|
||||||
}
|
}
|
||||||
@@ -266,10 +268,13 @@ CString LowLevelWindow_Cocoa::TryVideoMode( const VideoModeParams& p, bool& newD
|
|||||||
[m_Context update];
|
[m_Context update];
|
||||||
[m_Context makeCurrentContext];
|
[m_Context makeCurrentContext];
|
||||||
|
|
||||||
|
if( bChangeVsync )
|
||||||
|
{
|
||||||
long swap = p.vsync ? 1 : 0;
|
long swap = p.vsync ? 1 : 0;
|
||||||
|
|
||||||
[m_Context setValues:&swap forParameter:NSOpenGLCPSwapInterval];
|
[m_Context setValues:&swap forParameter:NSOpenGLCPSwapInterval];
|
||||||
m_CurrentParams.vsync = p.vsync;
|
m_CurrentParams.vsync = p.vsync;
|
||||||
|
}
|
||||||
|
|
||||||
return CString();
|
return CString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user