From bd74cf85a443c5db082a69e799a91141e9cd2cc3 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 23 Apr 2017 14:27:50 +0300 Subject: [PATCH] Added selection of frame buffer implementation in Cocoa backend Added vid_glswfb CVAR but set it to false by default for compatibility reasons --- src/posix/cocoa/i_video.mm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index e74161559..542d02fdd 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -116,6 +116,11 @@ DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen); +CUSTOM_CVAR(Bool, vid_glswfb, false, CVAR_NOINITCALL) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} + EXTERN_CVAR(Bool, ticker ) EXTERN_CVAR(Bool, vid_vsync) EXTERN_CVAR(Bool, vid_hidpi) @@ -551,9 +556,12 @@ CocoaVideo::CocoaVideo() // Create OpenGL pixel format - NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(OpenGLProfile::Core); + const OpenGLProfile defaultProfile = (1 == vid_renderer || vid_glswfb) + ? OpenGLProfile::Core + : OpenGLProfile::Legacy; + NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(defaultProfile); - if (nil == pixelFormat) + if (nil == pixelFormat && OpenGLProfile::Core == defaultProfile) { pixelFormat = CreatePixelFormat(OpenGLProfile::Legacy); @@ -647,10 +655,13 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c { fb = new OpenGLFrameBuffer(NULL, width, height, 32, 60, fullscreen); } + else if (vid_glswfb) + { + fb = CreateGLSWFrameBuffer(width, height, bgra, fullscreen); + } else { - //fb = new CocoaFrameBuffer(width, height, bgra, fullscreen); - fb = CreateGLSWFrameBuffer(width, height, bgra, fullscreen); + fb = new CocoaFrameBuffer(width, height, bgra, fullscreen); } fb->SetFlash(flashColor, flashAmount);