mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-09-11 13:52:31 +00:00
62 lines
1.6 KiB
C
62 lines
1.6 KiB
C
/*
|
|
sys_sdl1.c - SDL1 system utils
|
|
Copyright (C) 2018 a1batross
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <SDL.h>
|
|
#include "platform.h"
|
|
#include "platform_sdl1.h"
|
|
|
|
#if XASH_TIMER == TIMER_SDL
|
|
double Platform_DoubleTime( void )
|
|
{
|
|
static Uint64 g_PerformanceFrequency;
|
|
static Uint64 g_ClockStart;
|
|
Uint64 CurrentTime;
|
|
|
|
if( !g_PerformanceFrequency )
|
|
{
|
|
g_PerformanceFrequency = SDL_GetPerformanceFrequency();
|
|
g_ClockStart = SDL_GetPerformanceCounter();
|
|
}
|
|
CurrentTime = SDL_GetPerformanceCounter();
|
|
return (double)( CurrentTime - g_ClockStart ) / (double)( g_PerformanceFrequency );
|
|
}
|
|
|
|
void Platform_Sleep( int msec )
|
|
{
|
|
SDL_Delay( msec );
|
|
}
|
|
#endif // XASH_TIMER == TIMER_SDL
|
|
|
|
#if XASH_MESSAGEBOX == MSGBOX_SDL
|
|
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
|
|
{
|
|
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, title, message, parentMainWindow ? host.hWnd : NULL );
|
|
}
|
|
#endif // XASH_MESSAGEBOX == MSGBOX_SDL
|
|
|
|
void SDLash_Init( const char *basedir )
|
|
{
|
|
if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO ))
|
|
{
|
|
Sys_Warn( "SDL_Init failed: %s", SDL_GetError() );
|
|
host.type = HOST_DEDICATED;
|
|
}
|
|
}
|
|
|
|
void SDLash_Shutdown( void )
|
|
{
|
|
SDL_Quit();
|
|
}
|