mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-02 10:11:31 +00:00
- Applied some parts of Alexey's MacOS patch.
git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1245 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
050233af52
commit
790dfb2ced
13 changed files with 197 additions and 23 deletions
|
@ -342,7 +342,7 @@ void T_LoadScripts(MapData *map)
|
||||||
// the default translator is being used.
|
// the default translator is being used.
|
||||||
// Custom translators will not be patched.
|
// Custom translators will not be patched.
|
||||||
if ((gameinfo.gametype == GAME_Doom || gameinfo.gametype == GAME_Heretic) && level.info->Translator.IsEmpty() &&
|
if ((gameinfo.gametype == GAME_Doom || gameinfo.gametype == GAME_Heretic) && level.info->Translator.IsEmpty() &&
|
||||||
level.maptype == MAPTYPE_DOOM && SimpleLineTranslations[272 - 2*HasScripts].special == FS_Execute)
|
(level.maptype == MAPTYPE_DOOM) && SimpleLineTranslations[272 - 2*HasScripts].special == FS_Execute)
|
||||||
{
|
{
|
||||||
FLineTrans t = SimpleLineTranslations[270];
|
FLineTrans t = SimpleLineTranslations[270];
|
||||||
SimpleLineTranslations[270] = SimpleLineTranslations[272];
|
SimpleLineTranslations[270] = SimpleLineTranslations[272];
|
||||||
|
|
|
@ -44,21 +44,21 @@
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "gl/system/gl_cvars.h"
|
#include "gl/system/gl_cvars.h"
|
||||||
|
|
||||||
#ifdef unix
|
#if defined (unix) || defined (__APPLE__)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#define wglGetProcAddress(x) (*SDL_GL_GetProcAddress)(x)
|
#define wglGetProcAddress(x) (*SDL_GL_GetProcAddress)(x)
|
||||||
#endif
|
#endif
|
||||||
static void APIENTRY glBlendEquationDummy (GLenum mode);
|
static void APIENTRY glBlendEquationDummy (GLenum mode);
|
||||||
|
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static TArray<FString> m_Extensions;
|
static TArray<FString> m_Extensions;
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
HWND m_Window;
|
HWND m_Window;
|
||||||
HDC m_hDC;
|
HDC m_hDC;
|
||||||
HGLRC m_hRC;
|
HGLRC m_hRC;
|
||||||
|
@ -77,7 +77,7 @@ int occlusion_type=0;
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
static HWND InitDummy()
|
static HWND InitDummy()
|
||||||
{
|
{
|
||||||
HMODULE g_hInst = GetModuleHandle(NULL);
|
HMODULE g_hInst = GetModuleHandle(NULL);
|
||||||
|
@ -298,7 +298,7 @@ static void APIENTRY LoadExtensions()
|
||||||
if (strcmp(version, "3.0") >= 0) gl->flags|=RFL_GL_30;
|
if (strcmp(version, "3.0") >= 0) gl->flags|=RFL_GL_30;
|
||||||
|
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
PFNWGLSWAPINTERVALEXTPROC vs = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
PFNWGLSWAPINTERVALEXTPROC vs = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
||||||
if (vs) gl->SetVSync = vs;
|
if (vs) gl->SetVSync = vs;
|
||||||
#endif
|
#endif
|
||||||
|
@ -510,7 +510,7 @@ static void APIENTRY PrintStartupLog()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
static bool SetupPixelFormat(HDC hDC, bool allowsoftware, bool nostencil, int multisample)
|
static bool SetupPixelFormat(HDC hDC, bool allowsoftware, bool nostencil, int multisample)
|
||||||
{
|
{
|
||||||
int colorDepth;
|
int colorDepth;
|
||||||
|
@ -745,7 +745,7 @@ static bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
CVAR(Bool, gl_debug, false, 0)
|
CVAR(Bool, gl_debug, false, 0)
|
||||||
|
|
||||||
static bool APIENTRY InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample)
|
static bool APIENTRY InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample)
|
||||||
|
@ -806,7 +806,7 @@ static bool APIENTRY InitHardware (bool allowsoftware, bool nostencil, int multi
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
static void APIENTRY Shutdown()
|
static void APIENTRY Shutdown()
|
||||||
{
|
{
|
||||||
if (m_hRC)
|
if (m_hRC)
|
||||||
|
@ -853,17 +853,21 @@ static bool APIENTRY SetFullscreen(const char *devicename, int w, int h, int bit
|
||||||
|
|
||||||
static void APIENTRY iSwapBuffers()
|
static void APIENTRY iSwapBuffers()
|
||||||
{
|
{
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
SwapBuffers(m_hDC);
|
SwapBuffers(m_hDC);
|
||||||
#else
|
#else
|
||||||
SDL_GL_SwapBuffers ();
|
SDL_GL_SwapBuffers ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL APIENTRY SetVSync(int)
|
static BOOL APIENTRY SetVSync( int vsync )
|
||||||
{
|
{
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
return kCGLNoError == CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &vsync );
|
||||||
|
#else // !__APPLE__
|
||||||
// empty placeholder
|
// empty placeholder
|
||||||
return false;
|
return false;
|
||||||
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -982,11 +986,11 @@ void APIENTRY GetContext(RenderContext & gl)
|
||||||
gl.SetTextureMode = SetTextureMode;
|
gl.SetTextureMode = SetTextureMode;
|
||||||
gl.PrintStartupLog = PrintStartupLog;
|
gl.PrintStartupLog = PrintStartupLog;
|
||||||
gl.InitHardware = InitHardware;
|
gl.InitHardware = InitHardware;
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
gl.Shutdown = Shutdown;
|
gl.Shutdown = Shutdown;
|
||||||
#endif
|
#endif
|
||||||
gl.SwapBuffers = iSwapBuffers;
|
gl.SwapBuffers = iSwapBuffers;
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
gl.SetFullscreen = SetFullscreen;
|
gl.SetFullscreen = SetFullscreen;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1068,7 +1072,7 @@ void APIENTRY GetContext(RenderContext & gl)
|
||||||
gl.BlendEquation = glBlendEquationDummy;
|
gl.BlendEquation = glBlendEquationDummy;
|
||||||
gl.SetVSync = SetVSync;
|
gl.SetVSync = SetVSync;
|
||||||
|
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
ReadInitExtensions();
|
ReadInitExtensions();
|
||||||
//GL is not yet inited in UNIX version, read them later in LoadExtensions
|
//GL is not yet inited in UNIX version, read them later in LoadExtensions
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#ifndef R_RENDER
|
#ifndef R_RENDER
|
||||||
#define R_RENDER
|
#define R_RENDER
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#define APIENTRY
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
enum RenderFlags
|
enum RenderFlags
|
||||||
{
|
{
|
||||||
RFL_NPOT_TEXTURE=1,
|
RFL_NPOT_TEXTURE=1,
|
||||||
|
@ -54,7 +58,7 @@ struct RenderContext
|
||||||
void (APIENTRY * SetTextureMode) (int type);
|
void (APIENTRY * SetTextureMode) (int type);
|
||||||
void (APIENTRY * PrintStartupLog) ();
|
void (APIENTRY * PrintStartupLog) ();
|
||||||
BOOL (APIENTRY * SetVSync) (int on);
|
BOOL (APIENTRY * SetVSync) (int on);
|
||||||
#ifndef unix
|
#if !defined (unix) && !defined (__APPLE__)
|
||||||
bool (APIENTRY * InitHardware) (HWND, bool allowsoftware, bool nostencil, int multisample);
|
bool (APIENTRY * InitHardware) (HWND, bool allowsoftware, bool nostencil, int multisample);
|
||||||
void (APIENTRY * Shutdown) ();
|
void (APIENTRY * Shutdown) ();
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -47,7 +47,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#if !defined(__APPLE__)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -62,9 +64,15 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <OpenGL/OpenGL.h>
|
||||||
|
#else // !__APPLE__
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GL/glext.h>
|
#include <GL/glext.h>
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code!
|
#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code!
|
||||||
#include <GL/wglext.h>
|
#include <GL/wglext.h>
|
||||||
|
|
|
@ -50,6 +50,12 @@ inline long long GetClockCycle ()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
|
||||||
|
typedef cycle_t glcycle_t;
|
||||||
|
|
||||||
|
#else // !__APPLE__
|
||||||
|
|
||||||
class glcycle_t
|
class glcycle_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -93,6 +99,7 @@ private:
|
||||||
long long Counter;
|
long long Counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
extern glcycle_t RenderWall,SetupWall,ClipWall,SplitWall;
|
extern glcycle_t RenderWall,SetupWall,ClipWall,SplitWall;
|
||||||
extern glcycle_t RenderFlat,SetupFlat;
|
extern glcycle_t RenderFlat,SetupFlat;
|
||||||
|
|
|
@ -1078,7 +1078,7 @@ static FString GetCachePath()
|
||||||
FSRef folder;
|
FSRef folder;
|
||||||
|
|
||||||
if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
|
if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
|
||||||
noErr == FSRefMakePath(&folder, (UInt8*)path.GetChars(), PATH_MAX))
|
noErr == FSRefMakePath(&folder, (UInt8*)pathstr, PATH_MAX))
|
||||||
{
|
{
|
||||||
path = pathstr;
|
path = pathstr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#ifndef PR_SET_PTRACER
|
#ifndef PR_SET_PTRACER
|
||||||
#define PR_SET_PTRACER 0x59616d61
|
#define PR_SET_PTRACER 0x59616d61
|
||||||
#endif
|
#endif
|
||||||
|
#else if defined (__APPLE__)
|
||||||
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -251,10 +251,12 @@ void I_ShutdownJoysticks();
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
#if !defined (__APPLE__)
|
||||||
{
|
{
|
||||||
int s[4] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS };
|
int s[4] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS };
|
||||||
cc_install_handlers(argc, argv, 4, s, "zdoom-crash.log", DoomSpecificInfo);
|
cc_install_handlers(argc, argv, 4, s, "zdoom-crash.log", DoomSpecificInfo);
|
||||||
}
|
}
|
||||||
|
#endif // !__APPLE__
|
||||||
|
|
||||||
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
|
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
|
||||||
DOTVERSIONSTR_NOREV,SVN_REVISION_STRING,__DATE__);
|
DOTVERSIONSTR_NOREV,SVN_REVISION_STRING,__DATE__);
|
||||||
|
@ -280,6 +282,26 @@ int main (int argc, char **argv)
|
||||||
atterm (SDL_Quit);
|
atterm (SDL_Quit);
|
||||||
|
|
||||||
SDL_WM_SetCaption (GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL);
|
SDL_WM_SetCaption (GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
||||||
|
if ( NULL != videoInfo )
|
||||||
|
{
|
||||||
|
EXTERN_CVAR( Int, vid_defwidth )
|
||||||
|
EXTERN_CVAR( Int, vid_defheight )
|
||||||
|
EXTERN_CVAR( Int, vid_defbits )
|
||||||
|
EXTERN_CVAR( Bool, vid_vsync )
|
||||||
|
EXTERN_CVAR( Bool, fullscreen )
|
||||||
|
|
||||||
|
vid_defwidth = videoInfo->current_w;
|
||||||
|
vid_defheight = videoInfo->current_h;
|
||||||
|
vid_defbits = videoInfo->vfmt->BitsPerPixel;
|
||||||
|
vid_vsync = True;
|
||||||
|
fullscreen = True;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <mach/mach_init.h>
|
#include <mach/mach_init.h>
|
||||||
#include <mach/semaphore.h>
|
#include <mach/semaphore.h>
|
||||||
#include <mach/task.h>
|
#include <mach/task.h>
|
||||||
|
@ -381,9 +382,25 @@ void STACK_ARGS I_FatalError (const char *error, ...)
|
||||||
int index;
|
int index;
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start (argptr, error);
|
va_start (argptr, error);
|
||||||
index = vsprintf (errortext, error, argptr);
|
index = vsnprintf (errortext, MAX_ERRORTEXT, error, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// Close window or exit fullscreen and release mouse capture
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
const CFStringRef errorString = CFStringCreateWithCStringNoCopy( kCFAllocatorDefault,
|
||||||
|
errortext, kCFStringEncodingASCII, kCFAllocatorNull );
|
||||||
|
if ( NULL != errorString )
|
||||||
|
{
|
||||||
|
CFOptionFlags dummy;
|
||||||
|
|
||||||
|
CFUserNotificationDisplayAlert( 0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
|
||||||
|
CFSTR( "Error" ), errorString, CFSTR( "Exit" ), NULL, NULL, &dummy );
|
||||||
|
CFRelease( errorString );
|
||||||
|
}
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
// Record error to log (if logging)
|
// Record error to log (if logging)
|
||||||
if (Logfile)
|
if (Logfile)
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,6 +95,7 @@ static MiniModeInfo WinModes[] =
|
||||||
{ 1280, 720 }, // 16:9
|
{ 1280, 720 }, // 16:9
|
||||||
{ 1280, 800 }, // 16:10
|
{ 1280, 800 }, // 16:10
|
||||||
{ 1280, 960 },
|
{ 1280, 960 },
|
||||||
|
{ 1344, 756 }, // 16:9
|
||||||
{ 1360, 768 }, // 16:9
|
{ 1360, 768 }, // 16:9
|
||||||
{ 1400, 787 }, // 16:9
|
{ 1400, 787 }, // 16:9
|
||||||
{ 1400, 875 }, // 16:10
|
{ 1400, 875 }, // 16:10
|
||||||
|
@ -103,10 +104,11 @@ static MiniModeInfo WinModes[] =
|
||||||
{ 1600, 900 }, // 16:9
|
{ 1600, 900 }, // 16:9
|
||||||
{ 1600, 1000 }, // 16:10
|
{ 1600, 1000 }, // 16:10
|
||||||
{ 1600, 1200 },
|
{ 1600, 1200 },
|
||||||
{ 1680, 1050 },
|
{ 1680, 1050 }, // 16:10
|
||||||
{ 1920, 1080 },
|
{ 1920, 1080 }, // 16:9
|
||||||
{ 1920, 1200 },
|
{ 1920, 1200 }, // 16:10
|
||||||
{ 2054, 1536 }
|
{ 2054, 1536 },
|
||||||
|
{ 2560, 1440 } // 16:9
|
||||||
};
|
};
|
||||||
|
|
||||||
// CODE --------------------------------------------------------------------
|
// CODE --------------------------------------------------------------------
|
||||||
|
@ -297,14 +299,29 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen = SDL_SetVideoMode (width, height, vid_displaybits,
|
// Mac OS X version will crash when entering fullscreen mode with BPP <= 8
|
||||||
|
// Also it may crash with BPP == 16 on some configurations
|
||||||
|
// It seems 24 and 32 bits are safe values
|
||||||
|
// So value of vid_displaybits is ignored and hardcoded constant is used instead
|
||||||
|
|
||||||
|
Screen = SDL_SetVideoMode (width, height,
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
32,
|
||||||
|
#else // ! __APPLE__
|
||||||
|
vid_displaybits,
|
||||||
|
#endif // __APPLE__
|
||||||
SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT|
|
SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT|
|
||||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
(fullscreen ? SDL_FULLSCREEN : 0));
|
||||||
|
|
||||||
if (Screen == NULL)
|
if (Screen == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_supportsGamma = !!SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
m_supportsGamma = -1 != SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
// Need to set title here because a window is not created yet when calling the same function from main()
|
||||||
|
SDL_WM_SetCaption( GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")", NULL );
|
||||||
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLGLFB::~SDLGLFB ()
|
SDLGLFB::~SDLGLFB ()
|
||||||
|
@ -385,6 +402,14 @@ bool SDLGLFB::IsValid ()
|
||||||
return DFrameBuffer::IsValid() && Screen != NULL;
|
return DFrameBuffer::IsValid() && Screen != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLGLFB::SetVSync( bool vsync )
|
||||||
|
{
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
const GLint value = vsync ? 1 : 0;
|
||||||
|
CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void SDLGLFB::NewRefreshRate ()
|
void SDLGLFB::NewRefreshRate ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ public:
|
||||||
bool IsValid ();
|
bool IsValid ();
|
||||||
bool IsFullscreen ();
|
bool IsFullscreen ();
|
||||||
|
|
||||||
|
virtual void SetVSync( bool vsync );
|
||||||
|
|
||||||
void NewRefreshRate ();
|
void NewRefreshRate ();
|
||||||
|
|
||||||
friend class SDLGLVideo;
|
friend class SDLGLVideo;
|
||||||
|
|
|
@ -42,6 +42,15 @@
|
||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
|
||||||
|
mach_timebase_info_data_t cycle_t::s_info;
|
||||||
|
bool cycle_t::s_initialized;
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
|
||||||
FStat *FStat::FirstStat;
|
FStat *FStat::FirstStat;
|
||||||
|
|
||||||
FStat::FStat (const char *name)
|
FStat::FStat (const char *name)
|
||||||
|
|
73
src/stats.h
73
src/stats.h
|
@ -38,6 +38,77 @@
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
|
#if defined (__APPLE__)
|
||||||
|
|
||||||
|
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
|
||||||
|
|
||||||
|
class cycle_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cycle_t()
|
||||||
|
{
|
||||||
|
if ( !s_initialized )
|
||||||
|
{
|
||||||
|
mach_timebase_info( &s_info );
|
||||||
|
s_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
cycle_t &operator=( const cycle_t &other )
|
||||||
|
{
|
||||||
|
if ( &other != this )
|
||||||
|
{
|
||||||
|
m_seconds = other.m_seconds;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
m_seconds = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clock()
|
||||||
|
{
|
||||||
|
m_seconds -= Nanoseconds() * 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unclock()
|
||||||
|
{
|
||||||
|
m_seconds += Nanoseconds() * 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Time()
|
||||||
|
{
|
||||||
|
return m_seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
double TimeMS()
|
||||||
|
{
|
||||||
|
return m_seconds * 1e3;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
double m_seconds;
|
||||||
|
|
||||||
|
static mach_timebase_info_data_t s_info;
|
||||||
|
static bool s_initialized;
|
||||||
|
|
||||||
|
uint64_t Nanoseconds() const
|
||||||
|
{
|
||||||
|
return mach_absolute_time() * s_info.numer / s_info.denom;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#else // !__APPLE__
|
||||||
|
|
||||||
#ifdef NO_CLOCK_GETTIME
|
#ifdef NO_CLOCK_GETTIME
|
||||||
class cycle_t
|
class cycle_t
|
||||||
{
|
{
|
||||||
|
@ -100,6 +171,8 @@ private:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Windows
|
// Windows
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue