mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-31 13:40:38 +00:00
Initial SDL setup
Use SDL_main on all platforms. Fix main() for non-const argv so it matches with the SDL prototype. Adapt win32 WinMain() to main() and get rid of the win32 special case in Common::Init().
This commit is contained in:
parent
efc71124b1
commit
005677494f
9 changed files with 38 additions and 30 deletions
|
@ -85,6 +85,9 @@ include_directories(${OPENAL_INCLUDE_DIR})
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
include_directories(${OPENGL_INCLUDE_DIR})
|
include_directories(${OPENGL_INCLUDE_DIR})
|
||||||
|
|
||||||
|
find_package(SDL REQUIRED)
|
||||||
|
include_directories(${SDL_INCLUDE_DIR})
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
add_definitions(-DXTHREADS)
|
add_definitions(-DXTHREADS)
|
||||||
|
@ -694,6 +697,7 @@ if (CORE)
|
||||||
${VORBIS_LIBRARIES}
|
${VORBIS_LIBRARIES}
|
||||||
${CURL_LIBRARY}
|
${CURL_LIBRARY}
|
||||||
${JPEG_LIBRARY}
|
${JPEG_LIBRARY}
|
||||||
|
${SDL_LIBRARY}
|
||||||
${sys_libs}
|
${sys_libs}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -716,6 +720,7 @@ if (DEDICATED)
|
||||||
${VORBIS_LIBRARIES}
|
${VORBIS_LIBRARIES}
|
||||||
${CURL_LIBRARY}
|
${CURL_LIBRARY}
|
||||||
${JPEG_LIBRARY}
|
${JPEG_LIBRARY}
|
||||||
|
${SDL_LIBRARY}
|
||||||
${sys_libs}
|
${sys_libs}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -287,7 +287,10 @@ BASECPPFLAGS.append( '-fvisibility=hidden' )
|
||||||
|
|
||||||
if ( "BSD" in g_os ):
|
if ( "BSD" in g_os ):
|
||||||
BASECPPFLAGS.append( '-I/usr/local/include' )
|
BASECPPFLAGS.append( '-I/usr/local/include' )
|
||||||
|
BASECPPFLAGS.append( '-I/usr/local/include/SDL' )
|
||||||
BASELINKFLAGS.append('-L/usr/local/lib')
|
BASELINKFLAGS.append('-L/usr/local/lib')
|
||||||
|
else:
|
||||||
|
BASECPPFLAGS.append( '-I/usr/include/SDL' )
|
||||||
|
|
||||||
BASECPPFLAGS.append( '-I.' )
|
BASECPPFLAGS.append( '-I.' )
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ class idCommonLocal : public idCommon {
|
||||||
public:
|
public:
|
||||||
idCommonLocal( void );
|
idCommonLocal( void );
|
||||||
|
|
||||||
virtual void Init( int argc, const char **argv, const char *cmdline );
|
virtual void Init( int argc, char **argv );
|
||||||
virtual void Shutdown( void );
|
virtual void Shutdown( void );
|
||||||
virtual void Quit( void );
|
virtual void Quit( void );
|
||||||
virtual bool IsInitialized( void ) const;
|
virtual bool IsInitialized( void ) const;
|
||||||
|
@ -181,7 +181,7 @@ private:
|
||||||
void InitRenderSystem( void );
|
void InitRenderSystem( void );
|
||||||
void InitSIMD( void );
|
void InitSIMD( void );
|
||||||
bool AddStartupCommands( void );
|
bool AddStartupCommands( void );
|
||||||
void ParseCommandLine( int argc, const char **argv );
|
void ParseCommandLine( int argc, char **argv );
|
||||||
void ClearCommandLine( void );
|
void ClearCommandLine( void );
|
||||||
bool SafeMode( void );
|
bool SafeMode( void );
|
||||||
void CheckToolMode( void );
|
void CheckToolMode( void );
|
||||||
|
@ -834,7 +834,7 @@ idCmdArgs com_consoleLines[MAX_CONSOLE_LINES];
|
||||||
idCommonLocal::ParseCommandLine
|
idCommonLocal::ParseCommandLine
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void idCommonLocal::ParseCommandLine( int argc, const char **argv ) {
|
void idCommonLocal::ParseCommandLine( int argc, char **argv ) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
com_numConsoleLines = 0;
|
com_numConsoleLines = 0;
|
||||||
|
@ -2782,7 +2782,7 @@ void idCommonLocal::SetMachineSpec( void ) {
|
||||||
idCommonLocal::Init
|
idCommonLocal::Init
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
void idCommonLocal::Init( int argc, const char **argv, const char *cmdline ) {
|
void idCommonLocal::Init( int argc, char **argv ) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// set interface pointers used by idLib
|
// set interface pointers used by idLib
|
||||||
|
@ -2798,12 +2798,6 @@ void idCommonLocal::Init( int argc, const char **argv, const char *cmdline ) {
|
||||||
ClearWarnings( GAME_NAME " initialization" );
|
ClearWarnings( GAME_NAME " initialization" );
|
||||||
|
|
||||||
// parse command line options
|
// parse command line options
|
||||||
idCmdArgs args;
|
|
||||||
if ( cmdline ) {
|
|
||||||
// tokenize if the OS doesn't do it for us
|
|
||||||
args.TokenizeString( cmdline, true );
|
|
||||||
argv = args.GetArgs( &argc );
|
|
||||||
}
|
|
||||||
ParseCommandLine( argc, argv );
|
ParseCommandLine( argc, argv );
|
||||||
|
|
||||||
// init console command system
|
// init console command system
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
// Initialize everything.
|
// Initialize everything.
|
||||||
// if the OS allows, pass argc/argv directly (without executable name)
|
// if the OS allows, pass argc/argv directly (without executable name)
|
||||||
// otherwise pass the command line in a single string (without executable name)
|
// otherwise pass the command line in a single string (without executable name)
|
||||||
virtual void Init( int argc, const char **argv, const char *cmdline ) = 0;
|
virtual void Init( int argc, char **argv ) = 0;
|
||||||
|
|
||||||
// Shuts down everything.
|
// Shuts down everything.
|
||||||
virtual void Shutdown( void ) = 0;
|
virtual void Shutdown( void ) = 0;
|
||||||
|
|
|
@ -37,6 +37,8 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#include <mcheck.h>
|
#include <mcheck.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <SDL_main.h>
|
||||||
|
|
||||||
#include "sys/platform.h"
|
#include "sys/platform.h"
|
||||||
#include "framework/Licensee.h"
|
#include "framework/Licensee.h"
|
||||||
#include "framework/FileSystem.h"
|
#include "framework/FileSystem.h"
|
||||||
|
@ -645,7 +647,7 @@ void abrt_func( mcheck_status status ) {
|
||||||
main
|
main
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, char **argv) {
|
||||||
#ifdef ID_MCHECK
|
#ifdef ID_MCHECK
|
||||||
// must have -lmcheck linkage
|
// must have -lmcheck linkage
|
||||||
mcheck( abrt_func );
|
mcheck( abrt_func );
|
||||||
|
@ -655,9 +657,9 @@ int main(int argc, const char **argv) {
|
||||||
Posix_EarlyInit( );
|
Posix_EarlyInit( );
|
||||||
|
|
||||||
if ( argc > 1 ) {
|
if ( argc > 1 ) {
|
||||||
common->Init( argc-1, &argv[1], NULL );
|
common->Init( argc-1, &argv[1] );
|
||||||
} else {
|
} else {
|
||||||
common->Init( 0, NULL, NULL );
|
common->Init( 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
Posix_LateInit( );
|
Posix_LateInit( );
|
||||||
|
|
|
@ -39,6 +39,8 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#import <ucontext.h>
|
#import <ucontext.h>
|
||||||
#import <mach/thread_status.h>
|
#import <mach/thread_status.h>
|
||||||
|
|
||||||
|
#import <SDL_main.h>
|
||||||
|
|
||||||
#import "sys/platform.h"
|
#import "sys/platform.h"
|
||||||
#import "idlib/Str.h"
|
#import "idlib/Str.h"
|
||||||
#import "framework/Licensee.h"
|
#import "framework/Licensee.h"
|
||||||
|
@ -243,7 +245,7 @@ extern void CL_Quit_f(void);
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
const char *argv[MAX_ARGC];
|
char *argv[MAX_ARGC];
|
||||||
NSProcessInfo *processInfo;
|
NSProcessInfo *processInfo;
|
||||||
NSArray *arguments;
|
NSArray *arguments;
|
||||||
unsigned int argumentIndex, argumentCount;
|
unsigned int argumentIndex, argumentCount;
|
||||||
|
@ -338,9 +340,9 @@ extern void CL_Quit_f(void);
|
||||||
// Finder passes the process serial number as only argument after the program path
|
// Finder passes the process serial number as only argument after the program path
|
||||||
// nuke it if we see it
|
// nuke it if we see it
|
||||||
if ( argc > 1 && strncmp( argv[ 1 ], "-psn", 4 ) ) {
|
if ( argc > 1 && strncmp( argv[ 1 ], "-psn", 4 ) ) {
|
||||||
common->Init( argc-1, &argv[1], NULL );
|
common->Init( argc-1, &argv[1] );
|
||||||
} else {
|
} else {
|
||||||
common->Init( 0, NULL, NULL );
|
common->Init( 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
Posix_LateInit( );
|
Posix_LateInit( );
|
||||||
|
@ -837,8 +839,8 @@ void OSX_GetVideoCard( int& outVendorId, int& outDeviceId )
|
||||||
main
|
main
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
int main( int argc, const char *argv[] ) {
|
int main( int argc, char *argv[] ) {
|
||||||
return NSApplicationMain( argc, argv );
|
return NSApplicationMain( argc, (const char **)argv );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FormatRegCode(const char* inRegCode, char* outRegCode)
|
bool FormatRegCode(const char* inRegCode, char* outRegCode)
|
||||||
|
|
|
@ -56,8 +56,8 @@ char *Sys_GetClipboardData( void ); // note that this isn't journaled...
|
||||||
void Sys_Print( const char *msg );
|
void Sys_Print( const char *msg );
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
return NSApplicationMain(argc, argv);
|
return NSApplicationMain(argc, (const char **)argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -240,7 +240,7 @@ if ( local_demo == 1 ):
|
||||||
if ( local_curl == 0 ):
|
if ( local_curl == 0 ):
|
||||||
local_env.Append( CPPDEFINES = [ 'ID_ENABLE_CURL=0' ] )
|
local_env.Append( CPPDEFINES = [ 'ID_ENABLE_CURL=0' ] )
|
||||||
|
|
||||||
local_env.Append( LIBS = [ 'pthread', 'jpeg', 'vorbisfile' ] )
|
local_env.Append( LIBS = [ 'SDL', 'SDLmain', 'pthread', 'jpeg', 'vorbisfile' ] )
|
||||||
|
|
||||||
if ( local_dedicated == 0 ):
|
if ( local_dedicated == 0 ):
|
||||||
local_env.Append( LIBS = [ 'GL' ] )
|
local_env.Append( LIBS = [ 'GL' ] )
|
||||||
|
|
|
@ -50,6 +50,8 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <SDL_main.h>
|
||||||
|
|
||||||
idCVar Win32Vars_t::sys_arch( "sys_arch", "", CVAR_SYSTEM | CVAR_INIT, "" );
|
idCVar Win32Vars_t::sys_arch( "sys_arch", "", CVAR_SYSTEM | CVAR_INIT, "" );
|
||||||
idCVar Win32Vars_t::sys_cpustring( "sys_cpustring", "detect", CVAR_SYSTEM | CVAR_INIT, "" );
|
idCVar Win32Vars_t::sys_cpustring( "sys_cpustring", "detect", CVAR_SYSTEM | CVAR_INIT, "" );
|
||||||
idCVar Win32Vars_t::in_mouse( "in_mouse", "1", CVAR_SYSTEM | CVAR_BOOL, "enable mouse input" );
|
idCVar Win32Vars_t::in_mouse( "in_mouse", "1", CVAR_SYSTEM | CVAR_BOOL, "enable mouse input" );
|
||||||
|
@ -66,8 +68,6 @@ idCVar Win32Vars_t::win_allowMultipleInstances( "win_allowMultipleInstances", "0
|
||||||
|
|
||||||
Win32Vars_t win32;
|
Win32Vars_t win32;
|
||||||
|
|
||||||
static char sys_cmdline[MAX_STRING_CHARS];
|
|
||||||
|
|
||||||
// not a hard limit, just what we keep track of for debugging
|
// not a hard limit, just what we keep track of for debugging
|
||||||
xthreadInfo *g_threads[MAX_THREADS];
|
xthreadInfo *g_threads[MAX_THREADS];
|
||||||
|
|
||||||
|
@ -1220,16 +1220,14 @@ int Sys_FPU_PrintStateFlags( char *ptr, int ctrl, int stat, int tags, int inof,
|
||||||
WinMain
|
WinMain
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
const HCURSOR hcurSave = ::SetCursor( LoadCursor( 0, IDC_WAIT ) );
|
const HCURSOR hcurSave = ::SetCursor( LoadCursor( 0, IDC_WAIT ) );
|
||||||
|
|
||||||
Sys_SetPhysicalWorkMemory( 192 << 20, 1024 << 20 );
|
Sys_SetPhysicalWorkMemory( 192 << 20, 1024 << 20 );
|
||||||
|
|
||||||
Sys_GetCurrentMemoryStatus( exeLaunchMemoryStats );
|
Sys_GetCurrentMemoryStatus( exeLaunchMemoryStats );
|
||||||
|
|
||||||
win32.hInstance = hInstance;
|
win32.hInstance = GetModuleHandle(NULL);
|
||||||
idStr::Copynz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );
|
|
||||||
|
|
||||||
// done before Com/Sys_Init since we need this for error output
|
// done before Com/Sys_Init since we need this for error output
|
||||||
Sys_CreateConsole();
|
Sys_CreateConsole();
|
||||||
|
@ -1252,7 +1250,11 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
|
||||||
// Sys_FPU_EnableExceptions( TEST_FPU_EXCEPTIONS );
|
// Sys_FPU_EnableExceptions( TEST_FPU_EXCEPTIONS );
|
||||||
Sys_FPU_SetPrecision( FPU_PRECISION_DOUBLE_EXTENDED );
|
Sys_FPU_SetPrecision( FPU_PRECISION_DOUBLE_EXTENDED );
|
||||||
|
|
||||||
common->Init( 0, NULL, lpCmdLine );
|
if ( argc > 1 ) {
|
||||||
|
common->Init( argc-1, &argv[1] );
|
||||||
|
} else {
|
||||||
|
common->Init( 0, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
#if TEST_FPU_EXCEPTIONS != 0
|
#if TEST_FPU_EXCEPTIONS != 0
|
||||||
common->Printf( Sys_FPU_GetState() );
|
common->Printf( Sys_FPU_GetState() );
|
||||||
|
@ -1281,7 +1283,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
|
||||||
::SetCursor( hcurSave );
|
::SetCursor( hcurSave );
|
||||||
|
|
||||||
// Launch the script debugger
|
// Launch the script debugger
|
||||||
if ( strstr( lpCmdLine, "+debugger" ) ) {
|
if ( strstr( GetCommandLine(), "+debugger" ) ) {
|
||||||
// DebuggerClientInit( lpCmdLine );
|
// DebuggerClientInit( lpCmdLine );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue