Extracted fullscreen and windowed modes handling to separate methods

This commit is contained in:
alexey.lysiuk 2014-08-10 11:12:35 +03:00
parent 406ee9234a
commit f8dfdbd4a4

View file

@ -878,7 +878,6 @@ void ProcessMouseWheelEvent(NSEvent* theEvent)
- (int)multisample;
- (void)setMultisample:(int)multisample;
- (void)initializeOpenGL;
- (void)changeVideoResolution:(bool)fullscreen width:(int)width height:(int)height;
- (void)processEvents:(NSTimer*)timer;
@ -1077,16 +1076,10 @@ static ApplicationDelegate* s_applicationDelegate;
m_openGLInitialized = true;
}
- (void)changeVideoResolution:(bool)fullscreen width:(int)width height:(int)height
{
[self initializeOpenGL];
CGLContextObj context = CGLGetCurrentContext();
NSView* view = [m_window contentView];
if (fullscreen)
- (void)fullscreenWithWidth:(int)width height:(int)height
{
NSScreen* screen = [m_window screen];
const NSRect screenFrame = [screen frame];
const NSRect displayRect = IsHiDPISupported()
? [screen convertRectToBacking:screenFrame]
@ -1112,7 +1105,8 @@ static ApplicationDelegate* s_applicationDelegate;
[m_window setFrame:displayRect display:YES];
[m_window setFrameOrigin:NSMakePoint(0.0f, 0.0f)];
}
else
- (void)windowedWithWidth:(int)width height:(int)height
{
s_frameBufferParameters.pixelScale = 1.0f;
@ -1124,7 +1118,7 @@ static ApplicationDelegate* s_applicationDelegate;
const NSSize windowPixelSize = NSMakeSize(width, height);
const NSSize windowSize = IsHiDPISupported()
? [view convertSizeFromBacking:windowPixelSize]
? [[m_window contentView] convertSizeFromBacking:windowPixelSize]
: windowPixelSize;
[m_window setLevel:NSNormalWindowLevel];
@ -1134,13 +1128,26 @@ static ApplicationDelegate* s_applicationDelegate;
[m_window center];
}
- (void)changeVideoResolution:(bool)fullscreen width:(int)width height:(int)height
{
[self initializeOpenGL];
if (fullscreen)
{
[self fullscreenWithWidth:width height:height];
}
else
{
[self windowedWithWidth:width height:height];
}
const NSSize viewSize = GetRealContentViewSize(m_window);
glViewport(0, 0, viewSize.width, viewSize.height);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
CGLFlushDrawable(context);
CGLFlushDrawable(CGLGetCurrentContext());
static NSString* const TITLE_STRING =
[NSString stringWithFormat:@"%s %s", GAMESIG, GetVersionString()];