Added support for VSync option in Cocoa back-end

This commit is contained in:
alexey.lysiuk 2014-08-03 12:39:42 +03:00
parent 177112603d
commit 4fb1e7517c
1 changed files with 21 additions and 0 deletions

View File

@ -15,6 +15,10 @@
#include <SDL.h> #include <SDL.h>
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#endif // __APPLE__
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
// TYPES ------------------------------------------------------------------- // TYPES -------------------------------------------------------------------
@ -43,6 +47,8 @@ public:
friend class SDLVideo; friend class SDLVideo;
virtual void SetVSync (bool vsync);
private: private:
PalEntry SourcePalette[256]; PalEntry SourcePalette[256];
BYTE GammaTable[3][256]; BYTE GammaTable[3][256];
@ -82,6 +88,7 @@ extern bool GUICapture;
EXTERN_CVAR (Float, Gamma) EXTERN_CVAR (Float, Gamma)
EXTERN_CVAR (Int, vid_maxfps) EXTERN_CVAR (Int, vid_maxfps)
EXTERN_CVAR (Bool, cl_capfps) EXTERN_CVAR (Bool, cl_capfps)
EXTERN_CVAR (Bool, vid_vsync)
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
@ -326,6 +333,7 @@ SDLFB::SDLFB (int width, int height, bool fullscreen)
} }
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
UpdateColors (); UpdateColors ();
SetVSync (vid_vsync);
} }
SDLFB::~SDLFB () SDLFB::~SDLFB ()
@ -535,6 +543,19 @@ bool SDLFB::IsFullscreen ()
return (Screen->flags & SDL_FULLSCREEN) != 0; return (Screen->flags & SDL_FULLSCREEN) != 0;
} }
void SDLFB::SetVSync (bool vsync)
{
#ifdef __APPLE__
if (CGLContextObj context = CGLGetCurrentContext())
{
// Apply vsync for native backend only (where OpenGL context is set)
const GLint value = vsync ? 1 : 0;
CGLSetParameter(context, kCGLCPSwapInterval, &value);
}
#endif // __APPLE__
}
ADD_STAT (blit) ADD_STAT (blit)
{ {
FString out; FString out;