mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
Added support for VSync option in Cocoa back-end
This commit is contained in:
parent
177112603d
commit
4fb1e7517c
1 changed files with 21 additions and 0 deletions
|
@ -15,6 +15,10 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#endif // __APPLE__
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
// TYPES -------------------------------------------------------------------
|
||||
|
@ -43,6 +47,8 @@ public:
|
|||
|
||||
friend class SDLVideo;
|
||||
|
||||
virtual void SetVSync (bool vsync);
|
||||
|
||||
private:
|
||||
PalEntry SourcePalette[256];
|
||||
BYTE GammaTable[3][256];
|
||||
|
@ -82,6 +88,7 @@ extern bool GUICapture;
|
|||
EXTERN_CVAR (Float, Gamma)
|
||||
EXTERN_CVAR (Int, vid_maxfps)
|
||||
EXTERN_CVAR (Bool, cl_capfps)
|
||||
EXTERN_CVAR (Bool, vid_vsync)
|
||||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
|
@ -326,6 +333,7 @@ SDLFB::SDLFB (int width, int height, bool fullscreen)
|
|||
}
|
||||
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
||||
UpdateColors ();
|
||||
SetVSync (vid_vsync);
|
||||
}
|
||||
|
||||
SDLFB::~SDLFB ()
|
||||
|
@ -535,6 +543,19 @@ bool SDLFB::IsFullscreen ()
|
|||
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)
|
||||
{
|
||||
FString out;
|
||||
|
|
Loading…
Reference in a new issue