int main(int argc, char *argv[]) { SDL_version compiled; if ( SDL_Init(0) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); exit(1); } #ifdef DEBUG fprintf(stderr, "SDL initialized\n"); #endif #if SDL_VERSION_ATLEAST(1, 2, 0) printf("Compiled with SDL 1.2 or newer\n"); #else printf("Compiled with SDL older than 1.2\n"); #endif SDL_VERSION(&compiled); printf("Compiled version: %d.%d.%d\n", compiled.major, compiled.minor, compiled.patch); printf("Linked version: %d.%d.%d\n", SDL_Linked_Version()->major, SDL_Linked_Version()->minor, SDL_Linked_Version()->patch); SDL_Quit(); return(0); }
void show_system_info() { #ifdef USE_SDL Log << "System information:\n"; const SDL_version *linked_version = SDL_Linked_Version(); SDL_version compiled_version; SDL_VERSION(&compiled_version); Log << "Compiled with SDL version: " << (int)compiled_version.major << "." << (int)compiled_version.minor << "." << (int)compiled_version.patch << "\n"; Log << "Running with SDL version: " << (int)linked_version->major << "." << (int)linked_version->minor << "." << (int)linked_version->patch << "\n"; if((compiled_version.major != linked_version->major)||(compiled_version.minor != linked_version->minor)||(compiled_version.patch != linked_version->patch)) { Log << "Warning: SDL version mismatch\n"; } Log << "\n"; const SDL_version *image_linked_version = IMG_Linked_Version(); SDL_version image_compiled_version; SDL_IMAGE_VERSION(&image_compiled_version); Log << "Compiled with SDL_image version: " << (int)image_compiled_version.major << "." << (int)image_compiled_version.minor << "." << (int)image_compiled_version.patch << "\n"; Log << "Running with SDL_image version: " << (int)image_linked_version->major << "." << (int)image_linked_version->minor << "." << (int)image_linked_version->patch << "\n"; if((image_compiled_version.major != image_linked_version->major)||(image_compiled_version.minor != image_linked_version->minor)||(image_compiled_version.patch != image_linked_version->patch)) { Log << "Warning: SDL_image version mismatch\n"; } Log << "\n"; #endif }
// // ISDL12VideoSubsystem::ISDL12VideoSubsystem // // Initializes SDL video and sets a few SDL configuration options. // ISDL12VideoSubsystem::ISDL12VideoSubsystem() : IVideoSubsystem() { const SDL_version* SDLVersion = SDL_Linked_Version(); if (SDLVersion->major != SDL_MAJOR_VERSION || SDLVersion->minor != SDL_MINOR_VERSION) { I_FatalError("SDL version conflict (%d.%d.%d vs %d.%d.%d dll)\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL, SDLVersion->major, SDLVersion->minor, SDLVersion->patch); return; } if (SDLVersion->patch != SDL_PATCHLEVEL) { Printf_Bold("SDL version warning (%d.%d.%d vs %d.%d.%d dll)\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL, SDLVersion->major, SDLVersion->minor, SDLVersion->patch); } if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) { I_FatalError("Could not initialize SDL video.\n"); return; } mVideoCapabilities = new ISDL12VideoCapabilities(); mWindow = new ISDL12Window(640, 480, 8, false, false); }
const char *vid_version(void) { static char SDLVersion[80]; SDL_version compiled, running; #if SDL_MAJOR_VERSION == 1 const SDL_version *ver = SDL_Linked_Version(); running.major = ver->major; running.minor = ver->minor; running.patch = ver->patch; #else SDL_GetVersion(&running); #endif SDL_VERSION(&compiled); if ((compiled.major == running.major) && (compiled.minor == running.minor) && (compiled.patch == running.patch)) sprintf(SDLVersion, "SDL Version %d.%d.%d", compiled.major, compiled.minor, compiled.patch); else sprintf(SDLVersion, "SDL Version (Compiled: %d.%d.%d, Runtime: %d.%d.%d)", compiled.major, compiled.minor, compiled.patch, running.major, running.minor, running.patch); return (const char *)SDLVersion; }
/* Show version info */ static void show_version (void) { const SDL_version *sdld; sdld = SDL_Linked_Version (); printf ("%s version %s (Development branch)\n", PACKAGE, VERSION); printf ("Compiled with SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); printf ("Dynamically linked SDL version is %d.%d.%d\n", sdld->major, sdld->minor, sdld->patch); #ifndef WIN32 printf ("Data directory is \"%s\"\n", PACKAGE_DATA_DIR); #endif printf ("\nCompiled in features:\n"); #if HAVE_LIBSDL_MIXER printf ("SDL_Mixer (sounds): enabled\n"); #else printf ("SDL_Mixer (sounds): disabled\n"); #endif #if HAVE_LIBSDL_GFX printf ("SDL_gfx (eyecandy): enabled\n"); #else printf ("SDL_gfx (eyecandy): disabled\n"); #endif #if HAVE_LIBSDL_TTF printf ("SDL_ttf (Truetype fonts): enabled\n"); #else printf ("SDL_ttf (Truetype fonts): disabled\n"); #endif exit (0); }
void kernel_PrintSDLVersions(void) { const SDL_version *v = NULL; SDL_version compiled_V; v = SDL_Linked_Version(); SDL_VERSION(&compiled_V); file_Log(ker_Log(), 1, "(Linked) SDL Version: %u.%u.%u\n", v->major, v->minor, v->patch); file_Log(ker_Log(), 1, "(Compiled) SDL Version: %u.%u.%u\n", compiled_V.major, compiled_V.minor, compiled_V.patch); v = TTF_Linked_Version(); SDL_TTF_VERSION(&compiled_V); file_Log(ker_Log(), 1, "(Linked) SDL TTF Version: %u.%u.%u\n", v->major, v->minor, v->patch); file_Log(ker_Log(), 1, "(Compiled) SDL TTF Version: %u.%u.%u\n", compiled_V.major, compiled_V.minor, compiled_V.patch); file_Log(ker_Log(), 1, "SDL_Init flags (%d) -\n", kernel_Main.SDL_Init_Flags); if(flag_Check(&kernel_Main.SDL_Init_Flags, SDL_INIT_VIDEO) == 1) file_Log(ker_Log(), 1, "\tSDL_INIT_VIDEO\n"); if(flag_Check(&kernel_Main.SDL_Init_Flags, SDL_INIT_AUDIO) == 1) file_Log(ker_Log(), 1, "\tSDL_INIT_AUDIO\n"); if(flag_Check(&kernel_Main.SDL_Init_Flags, SDL_INIT_JOYSTICK) == 1) file_Log(ker_Log(), 1, "\tSDL_INIT_JOYSTICK\n"); return; }
static void ShowUsage(char *prog) { printf("\nUsage is as follows:\n%s <options> filename\n\n",prog); puts(DriverUsage); #ifdef _S9XLUA_H puts ("--loadlua f Loads lua script from filename f."); #endif #ifdef CREATE_AVI puts ("--videolog c Calls mencoder to grab the video and audio streams to\n encode them. Check the documentation for more on this."); puts ("--mute {0|1} Mutes FCEUX while still passing the audio stream to\n mencoder during avi creation."); #endif puts(""); printf("Compiled with SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL ); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_version* v; SDL_GetVersion(v); #else const SDL_version* v = SDL_Linked_Version(); #endif printf("Linked with SDL version %d.%d.%d\n", v->major, v->minor, v->patch); #ifdef GTK printf("Compiled with GTK version %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION ); //printf("Linked with GTK version %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION ); #endif }
const char *vid_version(void) { static char SDLVersion[80]; const SDL_version *ver = SDL_Linked_Version(); sprintf(SDLVersion, "SDL Version %d.%d.%d", ver->major, ver->minor, ver->patch); return (const char *)SDLVersion; }
CHALManager::CHALManager() { m_Notifications = false; m_Context = NULL; m_DBusSystemConnection = NULL; const SDL_version *sdl_version = SDL_Linked_Version(); m_bMultipleJoysticksSupport = (sdl_version->major >= 1 && sdl_version->minor >= 3)?true:false; }
static PyObject* get_sdl_version (PyObject* self) { const SDL_version *v; v = SDL_Linked_Version (); return Py_BuildValue ("iii", v->major, v->minor, v->patch); }
int do_about(int sel) { char *path; #ifdef __GNUC__ { int major = __GNUC__; int minor = __GNUC_MINOR__; #ifdef __GNUC_PATCHLEVEL__ int patchlevel = __GNUC_PATCHLEVEL__; #else int patchlevel = 0; #endif #ifdef __clang__ major = __clang_major__; minor = __clang_minor__; patchlevel = __clang_patchlevel__; sprintf(gcc_version,"with llvm/clang %d.%d.%d",major,minor,patchlevel); #else sprintf(gcc_version,"with gcc %d.%d.%d",major,minor,patchlevel); #endif } #else sprintf(gcc_version,"with an unknown gcc ???"); #endif about_items[2].label = gcc_version; path = get_shared("bitmaps/raine_logo.png"); sprintf(about_cpu, "CPU: %s", raine_cpu_model); about_items[3].label = about_cpu; char about_sdl[80]; #if HAS_NEO char about_sound[80]; #endif const SDL_version *version = SDL_Linked_Version(); const SDL_version *img = IMG_Linked_Version(); const SDL_version *ttf = TTF_Linked_Version(); sprintf(about_sdl,"Linked with SDL-%d.%d.%d, SDL_image-%d.%d.%d, SDL_ttf-%d.%d.%d",version->major,version->minor,version->patch, img->major,img->minor,img->patch, ttf->major,ttf->minor,ttf->patch); about_items[4].label = about_sdl; #if HAS_NEO Sound_Version sound; Sound_GetLinkedVersion(&sound); sprintf(about_sound,"SDL_sound-%d.%d.%d", sound.major,sound.minor,sound.patch); about_items[5].label = about_sound; #endif #ifdef RDTSC_PROFILE if (cycles_per_second) { sprintf(about_cpu,"CPU: %s at %d MHz",raine_cpu_model,cycles_per_second/1000000); } #endif about_menu = new TAbout_menu(_("About..."),about_items, path); about_menu->execute(); delete about_menu; about_menu = NULL; return 0; }
void SDL_Version() { const SDL_version *version; version = SDL_Linked_Version(); ri.Con_Printf(PRINT_ALL, "Linked against SDL version %d.%d.%d\n" "Using SDL library version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL, version->major, version->minor, version->patch ); }
static void init_sdl() { const SDL_version *ver; if(!SDL_WasInit(SDL_INIT_EVERYTHING)) { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); if((ver = SDL_Linked_Version())) { printf("SDL %d.%d.%d initialized\n", ver->major, ver->minor, ver->patch); } } }
CAMLprim value sdl_version (value unit) { const SDL_version *v; value r; v = SDL_Linked_Version(); r = alloc_small(3, 0); Field(r, 0) = Val_int(v->major); Field(r, 1) = Val_int(v->minor); Field(r, 2) = Val_int(v->patch); return r; }
void TFB_PreInit (void) { log_add (log_Info, "Initializing base SDL functionality."); log_add (log_Info, "Using SDL version %d.%d.%d (compiled with " "%d.%d.%d)", SDL_Linked_Version ()->major, SDL_Linked_Version ()->minor, SDL_Linked_Version ()->patch, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); #if 0 if (SDL_Linked_Version ()->major != SDL_MAJOR_VERSION || SDL_Linked_Version ()->minor != SDL_MINOR_VERSION || SDL_Linked_Version ()->patch != SDL_PATCHLEVEL) { log_add (log_Warning, "The used SDL library is not the same version " "as the one used to compile The Ur-Quan Masters with! " "If you experience any crashes, this would be an excellent " "suspect."); } #endif if ((SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) == -1)) { log_add (log_Fatal, "Could not initialize SDL: %s.", SDL_GetError ()); exit (EXIT_FAILURE); } atexit (TFB_PreQuit); }
static void test_versions(void) { SDL_version compiled; const SDL_version *linked; SDL_VERSION(&compiled); linked = SDL_Linked_Version(); output_versions("SDL", &compiled, linked); SDL_MIXER_VERSION(&compiled); linked = Mix_Linked_Version(); output_versions("SDL_mixer", &compiled, linked); }
void GraphicsSDL::print_sdl_version() { SDL_version ver_current; #ifdef USE_SDL2 SDL_GetVersion(&ver_current); #else const SDL_version * constptr_ver_current = SDL_Linked_Version(); // dyn. linked version ver_current = *constptr_ver_current; #endif printf("[gfx] SDL %d.%d.%d loaded.\n", ver_current.major, ver_current.minor, ver_current.patch); }
static void Sys_CheckSDL (void) { const SDL_version *sdl_version = SDL_Linked_Version(); Sys_Printf("Found SDL version %i.%i.%i\n",sdl_version->major,sdl_version->minor,sdl_version->patch); if (SDL_VERSIONNUM(sdl_version->major,sdl_version->minor,sdl_version->patch) < SDL_REQUIREDVERSION) { /*reject running under older SDL versions */ Sys_Error("You need at least v%d.%d.%d of SDL to run this game.", SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z); } if (SDL_VERSIONNUM(sdl_version->major,sdl_version->minor,sdl_version->patch) >= SDL_NEW_VERSION_REJECT) { /*reject running under newer (1.3.x) SDL */ Sys_Error("Your version of SDL library is incompatible with me.\n" "You need a library version in the line of %d.%d.%d\n", SDL_MIN_X,SDL_MIN_Y,SDL_MIN_Z); } }
char * _mod_gles2_repr (lw6sys_context_t * sys_context, _mod_gles2_context_t * gles2_context, u_int32_t id) { char *ret = NULL; SDL_version version; memset (&version, 0, sizeof (SDL_version)); version = *SDL_Linked_Version (); ret = lw6sys_new_sprintf (sys_context, _x_ ("%u gles2 SDL version %u.%u.%u resolution %dx%d"), id, version.major, version.minor, version.patch, gles2_context->sdl_context.video_mode.width, gles2_context->sdl_context.video_mode.height); return ret; }
/** * @brief Prints the SDL version to console. */ static void print_SDLversion (void) { const SDL_version *linked; SDL_version compiled; SDL_VERSION(&compiled); linked = SDL_Linked_Version(); DEBUG("SDL: %d.%d.%d [compiled: %d.%d.%d]", linked->major, linked->minor, linked->patch, compiled.major, compiled.minor, compiled.patch); /* Check if major/minor version differ. */ if ((linked->major*100 + linked->minor) > compiled.major*100 + compiled.minor) WARN("SDL is newer than compiled version"); if ((linked->major*100 + linked->minor) < compiled.major*100 + compiled.minor) WARN("SDL is older than compiled version."); }
void Window::showDebugInfo() { // TODO: add information about versions added in compilation proces printf("Compiled with GCC version: %s\n", __VERSION__); const SDL_version* sdlVersion = SDL_Linked_Version(); printf("Running with SDL version: %u.%u.%u\n", sdlVersion->major, sdlVersion->minor, sdlVersion->patch); const SDL_version* imageVersion = IMG_Linked_Version(); printf("Running with SDL_image version: %u.%u.%u\n", imageVersion->major, imageVersion->minor, imageVersion->patch); const SDL_version* ttfVersion = TTF_Linked_Version(); printf("Running with SDL_ttf version: %u.%u.%u\n", ttfVersion->major, ttfVersion->minor, ttfVersion->patch); const SDL_version* mixerVersion = Mix_Linked_Version(); printf("Running with SDL_mixer version: %u.%u.%u\n", mixerVersion->major, mixerVersion->minor, mixerVersion->patch); }
static int CheckSDLVersions (void) /*compare compiled to linked*/ { SDL_version compiled; const SDL_version* linked; SDL_VERSION (&compiled); linked = SDL_Linked_Version (); /*only check the major and minor version numbers. we will relax any differences in 'patch' version.*/ if (compiled.major != linked->major || compiled.minor != linked->minor) { PyErr_Format(PyExc_RuntimeError, "SDL compiled with version %d.%d.%d, linked to %d.%d.%d", compiled.major, compiled.minor, compiled.patch, linked->major, linked->minor, linked->patch); return 0; } return 1; }
int32_t sdlayer_checkversion(void) { const SDL_version *linked = SDL_Linked_Version(); SDL_version compiled; SDL_VERSION(&compiled); initprintf("Initializing SDL system interface " "(compiled against SDL version %d.%d.%d, found version %d.%d.%d)\n", compiled.major, compiled.minor, compiled.patch, linked->major, linked->minor, linked->patch); if (SDL_VERSIONNUM(linked->major, linked->minor, linked->patch) < SDL_REQUIREDVERSION) { /*reject running under SDL versions older than what is stated in sdl_inc.h */ initprintf("You need at least v%d.%d.%d of SDL to run this game\n", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z); return -1; } return 0; }
int main(int /*argc*/, char* /*argv*/ []) { const SDL_version* sdlVersion = SDL_Linked_Version(); if ( sdlVersion->minor < 2 ) { printf( "ERROR: SDL version must be at least 1.2.0" ); exit( 254 ); } //Brainblast* bb = new Brainblast("/usr/share/games/brainblast/"); Brainblast* bb = new Brainblast("/home/danielb/git/brainblast/"); if( !bb->initGameKyra() ) { printf("=== ERROR: Could not init kyra. ===\n"); zap(bb); exit(254); } bb->handleEvents(); zap(bb); }
/* Implementation function. */ int sdlewInit(void) { /* Library paths. */ #ifdef _WIN32 /* Expected in c:/windows/system or similar, no path needed. */ const char *path = "SDL.dll"; #elif defined(__APPLE__) /* Default installation path. */ const char *path = "/usr/local/cuda/lib/libSDL.dylib"; #else const char *path = "libSDL.so"; #endif static int initialized = 0; static int result = 0; int error; if (initialized) { return result; } initialized = 1; error = atexit(sdlewExit); if (error) { result = SDLEW_ERROR_ATEXIT_FAILED; return result; } /* Load library. */ lib = dynamic_library_open(path); if (lib == NULL) { result = SDLEW_ERROR_OPEN_FAILED; return result; } #ifndef HAVE_MALLOC SDL_LIBRARY_FIND(SDL_malloc); #endif #ifndef HAVE_CALLOC SDL_LIBRARY_FIND(SDL_calloc); #endif #ifndef HAVE_REALLOC SDL_LIBRARY_FIND(SDL_realloc); #endif #ifndef HAVE_FREE SDL_LIBRARY_FIND(SDL_free); #endif #ifndef HAVE_GETENV SDL_LIBRARY_FIND(SDL_getenv); #endif #ifndef HAVE_PUTENV SDL_LIBRARY_FIND(SDL_putenv); #endif #ifndef HAVE_QSORT SDL_LIBRARY_FIND(SDL_qsort); #endif #ifndef HAVE_MEMSET SDL_LIBRARY_FIND(SDL_memset); #endif #ifndef HAVE_MEMCPY SDL_LIBRARY_FIND(SDL_memcpy); #endif SDL_LIBRARY_FIND(SDL_revcpy); #ifndef HAVE_MEMCMP SDL_LIBRARY_FIND(SDL_memcmp); #endif #ifndef HAVE_STRLEN SDL_LIBRARY_FIND(SDL_strlen); #endif #ifndef HAVE_STRLCPY SDL_LIBRARY_FIND(SDL_strlcpy); #endif #ifndef HAVE_STRLCAT SDL_LIBRARY_FIND(SDL_strlcat); #endif #ifndef HAVE_STRDUP SDL_LIBRARY_FIND(SDL_strdup); #endif #ifndef HAVE__STRREV SDL_LIBRARY_FIND(SDL_strrev); #endif #ifndef HAVE__STRUPR SDL_LIBRARY_FIND(SDL_strupr); #endif #ifndef HAVE__STRLWR SDL_LIBRARY_FIND(SDL_strlwr); #endif #ifndef HAVE_STRCHR SDL_LIBRARY_FIND(SDL_strchr); #endif #ifndef HAVE_STRRCHR SDL_LIBRARY_FIND(SDL_strrchr); #endif #ifndef HAVE_STRSTR SDL_LIBRARY_FIND(SDL_strstr); #endif #ifndef HAVE__LTOA SDL_LIBRARY_FIND(SDL_ltoa); #endif #ifndef HAVE__ULTOA SDL_LIBRARY_FIND(SDL_ultoa); #endif #ifndef HAVE_STRTOL SDL_LIBRARY_FIND(SDL_strtol); #endif #ifndef HAVE_STRTOLL SDL_LIBRARY_FIND(SDL_strtoll); #endif #ifndef HAVE_STRTOULL SDL_LIBRARY_FIND(SDL_strtoull); #endif #ifndef HAVE_STRTOD SDL_LIBRARY_FIND(SDL_strtod); #endif #ifndef HAVE_STRCMP SDL_LIBRARY_FIND(SDL_strcmp); #endif #ifndef HAVE_STRNCMP SDL_LIBRARY_FIND(SDL_strncmp); #endif #ifndef HAVE_STRCASECMP SDL_LIBRARY_FIND(SDL_strcasecmp); #endif #ifndef HAVE_STRNCASECMP SDL_LIBRARY_FIND(SDL_strncasecmp); #endif #ifndef HAVE_SSCANF SDL_LIBRARY_FIND(SDL_sscanf); #endif #ifndef HAVE_SNPRINTF SDL_LIBRARY_FIND(SDL_snprintf); #endif #ifndef HAVE_VSNPRINTF SDL_LIBRARY_FIND(SDL_vsnprintf); #endif #if !(defined(HAVE_ICONV) && defined(HAVE_ICONV_H)) SDL_LIBRARY_FIND(SDL_iconv_open); #endif #if !(defined(HAVE_ICONV) && defined(HAVE_ICONV_H)) SDL_LIBRARY_FIND(SDL_iconv_close); #endif SDL_LIBRARY_FIND(SDL_iconv); SDL_LIBRARY_FIND(SDL_iconv_string); SDL_LIBRARY_FIND(SDL_LoadObject); SDL_LIBRARY_FIND(SDL_LoadFunction); SDL_LIBRARY_FIND(SDL_UnloadObject); SDL_LIBRARY_FIND(SDL_CreateMutex); SDL_LIBRARY_FIND(SDL_mutexP); SDL_LIBRARY_FIND(SDL_mutexV); SDL_LIBRARY_FIND(SDL_DestroyMutex); SDL_LIBRARY_FIND(SDL_CreateSemaphore); SDL_LIBRARY_FIND(SDL_DestroySemaphore); SDL_LIBRARY_FIND(SDL_SemWait); SDL_LIBRARY_FIND(SDL_SemTryWait); SDL_LIBRARY_FIND(SDL_SemWaitTimeout); SDL_LIBRARY_FIND(SDL_SemPost); SDL_LIBRARY_FIND(SDL_SemValue); SDL_LIBRARY_FIND(SDL_CreateCond); SDL_LIBRARY_FIND(SDL_DestroyCond); SDL_LIBRARY_FIND(SDL_CondSignal); SDL_LIBRARY_FIND(SDL_CondBroadcast); SDL_LIBRARY_FIND(SDL_CondWait); SDL_LIBRARY_FIND(SDL_CondWaitTimeout); SDL_LIBRARY_FIND(SDL_PumpEvents); SDL_LIBRARY_FIND(SDL_PeepEvents); SDL_LIBRARY_FIND(SDL_PollEvent); SDL_LIBRARY_FIND(SDL_WaitEvent); SDL_LIBRARY_FIND(SDL_PushEvent); SDL_LIBRARY_FIND(SDL_SetEventFilter); SDL_LIBRARY_FIND(SDL_GetEventFilter); SDL_LIBRARY_FIND(SDL_EventState); SDL_LIBRARY_FIND(SDL_GetAppState); SDL_LIBRARY_FIND(SDL_GetMouseState); SDL_LIBRARY_FIND(SDL_GetRelativeMouseState); SDL_LIBRARY_FIND(SDL_WarpMouse); SDL_LIBRARY_FIND(SDL_CreateCursor); SDL_LIBRARY_FIND(SDL_SetCursor); SDL_LIBRARY_FIND(SDL_GetCursor); SDL_LIBRARY_FIND(SDL_FreeCursor); SDL_LIBRARY_FIND(SDL_ShowCursor); SDL_LIBRARY_FIND(SDL_CreateThread); SDL_LIBRARY_FIND(SDL_CreateThread); SDL_LIBRARY_FIND(SDL_ThreadID); SDL_LIBRARY_FIND(SDL_GetThreadID); SDL_LIBRARY_FIND(SDL_WaitThread); SDL_LIBRARY_FIND(SDL_KillThread); SDL_LIBRARY_FIND(SDL_EnableUNICODE); SDL_LIBRARY_FIND(SDL_EnableKeyRepeat); SDL_LIBRARY_FIND(SDL_GetKeyRepeat); SDL_LIBRARY_FIND(SDL_GetKeyState); SDL_LIBRARY_FIND(SDL_GetModState); SDL_LIBRARY_FIND(SDL_SetModState); SDL_LIBRARY_FIND(SDL_GetKeyName); SDL_LIBRARY_FIND(SDL_AudioInit); SDL_LIBRARY_FIND(SDL_AudioQuit); SDL_LIBRARY_FIND(SDL_AudioDriverName); SDL_LIBRARY_FIND(SDL_OpenAudio); SDL_LIBRARY_FIND(SDL_GetAudioStatus); SDL_LIBRARY_FIND(SDL_PauseAudio); SDL_LIBRARY_FIND(SDL_LoadWAV_RW); SDL_LIBRARY_FIND(SDL_FreeWAV); SDL_LIBRARY_FIND(SDL_BuildAudioCVT); SDL_LIBRARY_FIND(SDL_ConvertAudio); SDL_LIBRARY_FIND(SDL_MixAudio); SDL_LIBRARY_FIND(SDL_LockAudio); SDL_LIBRARY_FIND(SDL_UnlockAudio); SDL_LIBRARY_FIND(SDL_CloseAudio); SDL_LIBRARY_FIND(SDL_VideoInit); SDL_LIBRARY_FIND(SDL_VideoQuit); SDL_LIBRARY_FIND(SDL_VideoDriverName); SDL_LIBRARY_FIND(SDL_GetVideoSurface); SDL_LIBRARY_FIND(SDL_GetVideoInfo); SDL_LIBRARY_FIND(SDL_VideoModeOK); SDL_LIBRARY_FIND(SDL_SetVideoMode); SDL_LIBRARY_FIND(SDL_UpdateRects); SDL_LIBRARY_FIND(SDL_UpdateRect); SDL_LIBRARY_FIND(SDL_Flip); SDL_LIBRARY_FIND(SDL_SetGamma); SDL_LIBRARY_FIND(SDL_SetGammaRamp); SDL_LIBRARY_FIND(SDL_GetGammaRamp); SDL_LIBRARY_FIND(SDL_SetColors); SDL_LIBRARY_FIND(SDL_SetPalette); SDL_LIBRARY_FIND(SDL_MapRGB); SDL_LIBRARY_FIND(SDL_MapRGBA); SDL_LIBRARY_FIND(SDL_GetRGB); SDL_LIBRARY_FIND(SDL_GetRGBA); SDL_LIBRARY_FIND(SDL_CreateRGBSurface); SDL_LIBRARY_FIND(SDL_CreateRGBSurfaceFrom); SDL_LIBRARY_FIND(SDL_FreeSurface); SDL_LIBRARY_FIND(SDL_LockSurface); SDL_LIBRARY_FIND(SDL_UnlockSurface); SDL_LIBRARY_FIND(SDL_LoadBMP_RW); SDL_LIBRARY_FIND(SDL_SaveBMP_RW); SDL_LIBRARY_FIND(SDL_SetColorKey); SDL_LIBRARY_FIND(SDL_SetAlpha); SDL_LIBRARY_FIND(SDL_SetClipRect); SDL_LIBRARY_FIND(SDL_GetClipRect); SDL_LIBRARY_FIND(SDL_ConvertSurface); SDL_LIBRARY_FIND(SDL_UpperBlit); SDL_LIBRARY_FIND(SDL_LowerBlit); SDL_LIBRARY_FIND(SDL_FillRect); SDL_LIBRARY_FIND(SDL_DisplayFormat); SDL_LIBRARY_FIND(SDL_DisplayFormatAlpha); SDL_LIBRARY_FIND(SDL_CreateYUVOverlay); SDL_LIBRARY_FIND(SDL_LockYUVOverlay); SDL_LIBRARY_FIND(SDL_UnlockYUVOverlay); SDL_LIBRARY_FIND(SDL_DisplayYUVOverlay); SDL_LIBRARY_FIND(SDL_FreeYUVOverlay); SDL_LIBRARY_FIND(SDL_GL_LoadLibrary); SDL_LIBRARY_FIND(SDL_GL_GetProcAddress); SDL_LIBRARY_FIND(SDL_GL_SetAttribute); SDL_LIBRARY_FIND(SDL_GL_GetAttribute); SDL_LIBRARY_FIND(SDL_GL_SwapBuffers); SDL_LIBRARY_FIND(SDL_GL_UpdateRects); SDL_LIBRARY_FIND(SDL_GL_Lock); SDL_LIBRARY_FIND(SDL_GL_Unlock); SDL_LIBRARY_FIND(SDL_WM_SetCaption); SDL_LIBRARY_FIND(SDL_WM_GetCaption); SDL_LIBRARY_FIND(SDL_WM_SetIcon); SDL_LIBRARY_FIND(SDL_WM_IconifyWindow); SDL_LIBRARY_FIND(SDL_WM_ToggleFullScreen); SDL_LIBRARY_FIND(SDL_WM_GrabInput); SDL_LIBRARY_FIND(SDL_SoftStretch); SDL_LIBRARY_FIND(SDL_RWFromFile); SDL_LIBRARY_FIND(SDL_RWFromFP); SDL_LIBRARY_FIND(SDL_RWFromMem); SDL_LIBRARY_FIND(SDL_RWFromConstMem); SDL_LIBRARY_FIND(SDL_AllocRW); SDL_LIBRARY_FIND(SDL_FreeRW); SDL_LIBRARY_FIND(SDL_ReadLE16); SDL_LIBRARY_FIND(SDL_ReadBE16); SDL_LIBRARY_FIND(SDL_ReadLE32); SDL_LIBRARY_FIND(SDL_ReadBE32); SDL_LIBRARY_FIND(SDL_ReadLE64); SDL_LIBRARY_FIND(SDL_ReadBE64); SDL_LIBRARY_FIND(SDL_WriteLE16); SDL_LIBRARY_FIND(SDL_WriteBE16); SDL_LIBRARY_FIND(SDL_WriteLE32); SDL_LIBRARY_FIND(SDL_WriteBE32); SDL_LIBRARY_FIND(SDL_WriteLE64); SDL_LIBRARY_FIND(SDL_WriteBE64); SDL_LIBRARY_FIND(SDL_Init); SDL_LIBRARY_FIND(SDL_InitSubSystem); SDL_LIBRARY_FIND(SDL_QuitSubSystem); SDL_LIBRARY_FIND(SDL_WasInit); SDL_LIBRARY_FIND(SDL_Quit); SDL_LIBRARY_FIND(SDL_Linked_Version); SDL_LIBRARY_FIND(SDL_GetTicks); SDL_LIBRARY_FIND(SDL_Delay); SDL_LIBRARY_FIND(SDL_SetTimer); SDL_LIBRARY_FIND(SDL_AddTimer); SDL_LIBRARY_FIND(SDL_RemoveTimer); SDL_LIBRARY_FIND(SDL_NumJoysticks); SDL_LIBRARY_FIND(SDL_JoystickName); SDL_LIBRARY_FIND(SDL_JoystickOpen); SDL_LIBRARY_FIND(SDL_JoystickOpened); SDL_LIBRARY_FIND(SDL_JoystickIndex); SDL_LIBRARY_FIND(SDL_JoystickNumAxes); SDL_LIBRARY_FIND(SDL_JoystickNumBalls); SDL_LIBRARY_FIND(SDL_JoystickNumHats); SDL_LIBRARY_FIND(SDL_JoystickNumButtons); SDL_LIBRARY_FIND(SDL_JoystickUpdate); SDL_LIBRARY_FIND(SDL_JoystickEventState); SDL_LIBRARY_FIND(SDL_JoystickGetAxis); SDL_LIBRARY_FIND(SDL_JoystickGetHat); SDL_LIBRARY_FIND(SDL_JoystickGetBall); SDL_LIBRARY_FIND(SDL_JoystickGetButton); SDL_LIBRARY_FIND(SDL_JoystickClose); SDL_LIBRARY_FIND(SDL_CDNumDrives); SDL_LIBRARY_FIND(SDL_CDName); SDL_LIBRARY_FIND(SDL_CDOpen); SDL_LIBRARY_FIND(SDL_CDStatus); SDL_LIBRARY_FIND(SDL_CDPlayTracks); SDL_LIBRARY_FIND(SDL_CDPlay); SDL_LIBRARY_FIND(SDL_CDPause); SDL_LIBRARY_FIND(SDL_CDResume); SDL_LIBRARY_FIND(SDL_CDStop); SDL_LIBRARY_FIND(SDL_CDEject); SDL_LIBRARY_FIND(SDL_CDClose); SDL_LIBRARY_FIND(SDL_HasRDTSC); SDL_LIBRARY_FIND(SDL_HasMMX); SDL_LIBRARY_FIND(SDL_HasMMXExt); SDL_LIBRARY_FIND(SDL_Has3DNow); SDL_LIBRARY_FIND(SDL_Has3DNowExt); SDL_LIBRARY_FIND(SDL_HasSSE); SDL_LIBRARY_FIND(SDL_HasSSE2); SDL_LIBRARY_FIND(SDL_HasAltiVec); SDL_LIBRARY_FIND(SDL_SetError); SDL_LIBRARY_FIND(SDL_GetError); SDL_LIBRARY_FIND(SDL_ClearError); SDL_LIBRARY_FIND(SDL_Error); SDL_LIBRARY_FIND(SDL_GetWMInfo); result = SDLEW_SUCCESS; /* Currently we only support SDL-1.2 only. */ { const SDL_version *version = SDL_Linked_Version(); if(version->major > 1 || version->minor > 2) { result = SDLEW_ERROR_VERSION; } } return result; }
int main( int argc, char **argv ) { MemStartCheck(); { char* test = new char[16]; delete [] test; } SDL_Surface *surface = 0; // SDL initialization steps. if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK ) < 0 ) { fprintf( stderr, "SDL initialization failed: %s\n", SDL_GetError( ) ); exit( 1 ); } SDL_EnableKeyRepeat( 0, 0 ); SDL_EnableUNICODE( 1 ); const SDL_version* sversion = SDL_Linked_Version(); GLOUTPUT(( "SDL: major %d minor %d patch %d\n", sversion->major, sversion->minor, sversion->patch )); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8); if ( multisample ) { SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); } int videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */ videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */ if ( fullscreen ) videoFlags |= SDL_FULLSCREEN; else videoFlags |= SDL_RESIZABLE; #ifdef TEST_ROTATION screenWidth = SCREEN_WIDTH; screenHeight = SCREEN_HEIGHT; #else screenWidth = SCREEN_HEIGHT; screenHeight = SCREEN_WIDTH; #endif if ( argc == 3 ) { screenWidth = atoi( argv[1] ); screenHeight = atoi( argv[2] ); if ( screenWidth <= 0 ) screenWidth = IPOD_SCREEN_WIDTH; if ( screenHeight <= 0 ) screenHeight = IPOD_SCREEN_HEIGHT; } // Note that our output surface is rotated from the iPod. //surface = SDL_SetVideoMode( IPOD_SCREEN_HEIGHT, IPOD_SCREEN_WIDTH, 32, videoFlags ); surface = SDL_SetVideoMode( screenWidth, screenHeight, 32, videoFlags ); GLASSERT( surface ); int stencil = 0; int depth = 0; SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &stencil ); glGetIntegerv( GL_DEPTH_BITS, &depth ); GLOUTPUT(( "SDL surface created. w=%d h=%d bpp=%d stencil=%d depthBits=%d\n", surface->w, surface->h, surface->format->BitsPerPixel, stencil, depth )); /* Verify there is a surface */ if ( !surface ) { fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); exit( 1 ); } SDL_JoystickEventState(SDL_ENABLE); SDL_Joystick* joystick = SDL_JoystickOpen(0); if ( joystick ) { GLOUTPUT(( "Joystick '%s' open.\n", SDL_JoystickName(0) )); } int r = glewInit(); GLASSERT( r == GL_NO_ERROR ); // Calling this seems to confuse my ATI driver and cause lag / event back up? //#ifdef TEST_FULLSPEED // wglSwapIntervalEXT( 0 ); // vsync //#else // wglSwapIntervalEXT( 1 ); // vsync //#endif const unsigned char* vendor = glGetString( GL_VENDOR ); const unsigned char* renderer = glGetString( GL_RENDERER ); const unsigned char* version = glGetString( GL_VERSION ); GLOUTPUT(( "OpenGL vendor: '%s' Renderer: '%s' Version: '%s'\n", vendor, renderer, version )); Audio_Init(); bool done = false; bool zooming = false; SDL_Event event; float yRotation = 45.0f; grinliz::Vector2I mouseDown = { 0, 0 }; grinliz::Vector2I prevMouseDown = { 0, 0 }; U32 prevMouseDownTime = 0; int zoomX = 0; int zoomY = 0; void* game = 0; bool mapMakerMode = false; WIN32_FIND_DATA findFileData; HANDLE h; h = FindFirstFile( ".\\mods\\*.xwdb", &findFileData ); if ( h != INVALID_HANDLE_VALUE ) { BOOL findResult = TRUE; while( findResult && nModDB < GAME_MAX_MOD_DATABASES ) { grinliz::GLString* str = new grinliz::GLString( ".\\mods\\" ); str->append( findFileData.cFileName ); databases[nModDB++] = str; GameAddDatabase( str->c_str() ); findResult = FindNextFile( h, &findFileData ); } FindClose( h ); } if ( argc > 3 ) { // -- MapMaker -- // Engine::mapMakerMode = true; TileSetDesc desc; desc.set = "FARM"; desc.size = 16; desc.type = "TILE"; desc.variation = 0; if ( argc > 2 ) { desc.set = argv[2]; GLASSERT( strlen( desc.set ) == 4 ); } if ( argc > 3 ) { desc.size = atol( argv[3] ); GLASSERT( desc.size == 16 || desc.size == 32 || desc.size == 48 || desc.size == 64 ); } if ( argc > 4 ) { desc.type = argv[4]; GLASSERT( strlen( desc.type ) == 4 ); } if ( argc > 5 ) { desc.variation = atol( argv[5] ); GLASSERT( desc.variation >= 0 && desc.variation < 100 ); } game = new Game( screenWidth, screenHeight, rotation, ".\\resin\\", desc ); mapMakerMode = true; } else { game = NewGame( screenWidth, screenHeight, rotation, ".\\", tvMode ); } #if SEND_CRASH_LOGS // Can't call this until after the game is created! if ( !SettingsManager::Instance()->GetSuppressCrashLog() ) { // Check for a "didn't crash" file. FILE* fp = fopen( "UFO_Running.txt", "r" ); if ( fp ) { fseek( fp, 0, SEEK_END ); long len = ftell( fp ); if ( len > 1 ) { // Wasn't deleted. PostCurrentGame(); } fclose( fp ); } } { FILE* fp = fopen( "UFO_Running.txt", "w" ); if ( fp ) { fprintf( fp, "Game running." ); fclose( fp ); } } #endif #ifndef TEST_FULLSPEED SDL_TimerID timerID = SDL_AddTimer( TIME_BETWEEN_FRAMES, TimerCallback, 0 ); #endif bool L2Down = false; bool R2Down = false; grinliz::Vector2F joystickAxis[2] = { 0, 0 }; // ---- Main Loop --- // #ifdef TEST_FULLSPEED while ( !done ) { if ( SDL_PollEvent( &event ) ) #else while ( !done && SDL_WaitEvent( &event ) ) #endif { // The user event shouldn't be duplicated...if there are 2, pull out the dupe. if ( event.type == SDL_USEREVENT ) { SDL_Event e; while( true ) { int n = SDL_PeepEvents( &e, 1, SDL_PEEKEVENT, SDL_ALLEVENTS ); if ( n == 1 && e.type == SDL_USEREVENT ) { SDL_PeepEvents( &e, 1, SDL_GETEVENT, SDL_ALLEVENTS ); } else { break; } } } switch( event.type ) { case SDL_VIDEORESIZE: screenWidth = event.resize.w; screenHeight = event.resize.h; surface = SDL_SetVideoMode( screenWidth, screenHeight, 32, videoFlags ); GameDeviceLoss( game ); GameResize( game, event.resize.w, event.resize.h, rotation ); break; /* A: 0 Triggers: axis=2 X: 2 Y: 3 B: 1 L1: 4 R1: 5 */ case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: //GLOUTPUT(( "Button %d.\n", event.jbutton.button )); switch( event.jbutton.button ) { case 0: GameJoyButton( game, GAME_JOY_BUTTON_DOWN, event.type == SDL_JOYBUTTONDOWN ); break; case 1: GameJoyButton( game, GAME_JOY_BUTTON_RIGHT, event.type == SDL_JOYBUTTONDOWN ); break; case 2: GameJoyButton( game, GAME_JOY_BUTTON_LEFT, event.type == SDL_JOYBUTTONDOWN ); break; case 3: GameJoyButton( game, GAME_JOY_BUTTON_UP, event.type == SDL_JOYBUTTONDOWN ); break; case 4: GameJoyButton( game, GAME_JOY_L1, event.type == SDL_JOYBUTTONDOWN ); break; case 5: GameJoyButton( game, GAME_JOY_R1, event.type == SDL_JOYBUTTONDOWN ); break; } break; case SDL_JOYAXISMOTION: //GLOUTPUT(( "Axis %d to %d.\n", event.jaxis.axis, event.jaxis.value )); // axis2, posL, negR if ( event.jaxis.axis == 2 ) { int value = event.jaxis.value; static const int T = 10*1000; if ( value > 10 ) { if ( !L2Down && value > T ) { L2Down = true; GameJoyButton( game, GAME_JOY_L2, true ); } else if ( L2Down && value < T ) { L2Down = false; GameJoyButton( game, GAME_JOY_L2, false ); } } else if ( value < -10 ) { if ( !R2Down && value < -T ) { R2Down = true; GameJoyButton( game, GAME_JOY_R2, true ); } else if ( R2Down && value > -T ) { R2Down = false; GameJoyButton( game, GAME_JOY_R2, false ); } } } else { int value = event.jaxis.value; double normal = (double)value/32768.0f; int axis = -1; int stick = -1; switch( event.jaxis.axis ) { case 0: axis=0; stick=0; break; case 1: axis=1; stick=0; normal *= -1.0; break; case 3: axis=1; stick=1; normal *= -1.0f; break; case 4: axis=0; stick=1; break; default: break; } if ( axis >= 0 && stick >= 0 ) { joystickAxis[stick].X(axis) = (float)normal; } } break; case SDL_JOYHATMOTION: GameJoyDPad( game, event.jhat.value ); break; case SDL_KEYDOWN: { SDLMod sdlMod = SDL_GetModState(); if ( mapMakerMode && event.key.keysym.sym >= SDLK_0 && event.key.keysym.sym <= SDLK_9 ) { int index = 0; switch ( event.key.keysym.sym ) { case SDLK_1: index = 0; break; case SDLK_2: index = 1; break; case SDLK_3: index = 2; break; case SDLK_4: index = 3; break; case SDLK_5: index = 4; break; case SDLK_6: index = 5; break; case SDLK_7: index = 6; break; case SDLK_8: index = 7; break; case SDLK_9: index = 8; break; case SDLK_0: index = 9; break; }; const U8* light = ((Game*)game)->engine->GetMap()->DayTime() ? dayLight : nightLight; static const float INV = 1.0f/255.0f; U8 r = light[index*3+0]; U8 g = light[index*3+1]; U8 b = light[index*3+2]; if ( sdlMod & sdlMod & ( KMOD_LSHIFT | KMOD_RSHIFT ) ) { if ( index < 6 ) { // Average with shade. r = (light[index*3+0] + light[SHADE*3+0]) / 2; g = (light[index*3+1] + light[SHADE*3+1]) / 2; b = (light[index*3+2] + light[SHADE*3+2]) / 2; } else if ( index > 6 ) { // make darker (index 6 is the darkest. SHIFT does nothing.) int m = index-1; r = (light[index*3+0] + light[m*3+0]) / 2; g = (light[index*3+1] + light[m*3+1]) / 2; b = (light[index*3+2] + light[m*3+2]) / 2; } } ((Game*)game)->SetLightMap( (float)r * INV, (float)g * INV, (float)b * INV ); } switch ( event.key.keysym.sym ) { case SDLK_ESCAPE: { //int handled = GameHotKey( game, GAME_HK_BACK ); #ifdef DEBUG // only escape out in debug mode // if ( !handled ) done = true; #endif } break; case SDLK_F4: if ( sdlMod & ( KMOD_RALT | KMOD_LALT ) ) done = true; break; #ifdef SIM_GAMEPAD case SDLK_RIGHT: GameJoyDPad( game, GAME_JOY_DPAD_RIGHT ); break; case SDLK_LEFT: GameJoyDPad( game, GAME_JOY_DPAD_LEFT ); break; case SDLK_UP: GameJoyDPad( game, GAME_JOY_DPAD_UP ); break; case SDLK_DOWN: GameJoyDPad( game, GAME_JOY_DPAD_DOWN ); break; case SDLK_1: GameJoyButton( game, 1, true ); break; case SDLK_2: GameJoyButton( game, 2, true ); break; case SDLK_3: GameJoyButton( game, 3, true ); break; case SDLK_4: GameJoyButton( game, 4, true ); break; #else case SDLK_RIGHT: if ( !mapMakerMode ) { if ( sdlMod & (KMOD_RCTRL|KMOD_LCTRL) ) GameHotKey( game, GAME_HK_ROTATE_CW ); else GameHotKey( game, GAME_HK_NEXT_UNIT ); } break; case SDLK_LEFT: if ( !mapMakerMode ) { if ( sdlMod & (KMOD_RCTRL|KMOD_LCTRL) ) GameHotKey( game, GAME_HK_ROTATE_CCW ); else GameHotKey( game, GAME_HK_PREV_UNIT ); } break; #endif case SDLK_u: if ( mapMakerMode ) { ((Game*)game)->engine->camera.SetTilt( -90.0f ); ((Game*)game)->engine->camera.SetPosWC( 8.f, 90.f, 8.f ); ((Game*)game)->engine->camera.SetYRotation( 0.0f ); } else { GameHotKey( game, GAME_HK_TOGGLE_ROTATION_UI | GAME_HK_TOGGLE_NEXT_UI ); } break; case SDLK_o: if ( mapMakerMode ) { cameraIso = !cameraIso; ((Game*)game)->engine->CameraIso( cameraIso, true, (float)((Game*)game)->engine->GetMap()->Width(), (float)((Game*)game)->engine->GetMap()->Height() ); } break; case SDLK_s: if ( mapMakerMode ) { ((Game*)game)->SuppressText( true ); } GameDoTick( game, SDL_GetTicks() ); SDL_GL_SwapBuffers(); if ( mapMakerMode ) { ((Game*)game)->SuppressText( false ); } ScreenCapture( "cap" ); break; case SDLK_l: if ( mapMakerMode ) { const Surface* lightmap = ((Game*)game)->engine->GetMap()->GetLightMap(); SaveLightMap( lightmap ); } break; case SDLK_d: GameHotKey( game, GAME_HK_TOGGLE_DEBUG_TEXT ); break; case SDLK_DELETE: if ( mapMakerMode ) ((Game*)game)->DeleteAtSelection(); break; case SDLK_KP9: if ( mapMakerMode ) ((Game*)game)->RotateSelection( -1 ); break; case SDLK_r: case SDLK_KP7: if ( mapMakerMode ) ((Game*)game)->RotateSelection( 1 ); break; case SDLK_KP8: if ( mapMakerMode ) ((Game*)game)->DeltaCurrentMapItem(16); break; case SDLK_KP5: if ( mapMakerMode ) ((Game*)game)->DeltaCurrentMapItem(-16); break; case SDLK_KP6: if ( mapMakerMode ) ((Game*)game)->DeltaCurrentMapItem(1); break; case SDLK_KP4: if ( mapMakerMode ) ((Game*)game)->DeltaCurrentMapItem(-1); break; case SDLK_p: //if ( mapMakerMode ) { int pathing = (((Game*)game)->ShowingPathing() + 1) % 3; ((Game*)game)->ShowPathing( pathing ); } break; case SDLK_t: if ( mapMakerMode ) ((Game*)game)->engine->GetMap()->SetDayTime( !((Game*)game)->engine->GetMap()->DayTime() ); break; case SDLK_v: ((Game*)game)->ToggleTV(); break; case SDLK_m: if ( mapMakerMode ) ((Game*)game)->engine->EnableMetadata( !((Game*)game)->engine->IsMetadataEnabled() ); break; default: break; } /* GLOUTPUT(( "fov=%.1f rot=%.1f h=%.1f\n", game->engine.fov, game->engine.camera.Tilt(), game->engine.camera.PosWC().y )); */ } break; #ifdef SIM_GAMEPAD case SDL_KEYUP: { switch ( event.key.keysym.sym ) { case SDLK_1: GameJoyButton( game, 1, false ); break; case SDLK_2: GameJoyButton( game, 2, false ); break; case SDLK_3: GameJoyButton( game, 3, false ); break; case SDLK_4: GameJoyButton( game, 4, false ); break; } } break; #endif case SDL_MOUSEBUTTONDOWN: { int x, y; TransformXY( event.button.x, event.button.y, &x, &y ); mouseDown.Set( event.button.x, event.button.y ); if ( event.button.button == 1 ) { GameTap( game, GAME_TAP_DOWN, x, y ); } else if ( event.button.button == 3 ) { GameTap( game, GAME_TAP_CANCEL, x, y ); zooming = true; //GameCameraRotate( game, GAME_ROTATE_START, 0.0f ); SDL_GetRelativeMouseState( &zoomX, &zoomY ); } } break; case SDL_MOUSEBUTTONUP: { int x, y; TransformXY( event.button.x, event.button.y, &x, &y ); if ( event.button.button == 3 ) { zooming = false; } if ( event.button.button == 1 ) { GameTap( game, GAME_TAP_UP, x, y ); } } break; case SDL_MOUSEMOTION: { SDL_GetRelativeMouseState( &zoomX, &zoomY ); int state = SDL_GetMouseState(NULL, NULL); int x, y; TransformXY( event.button.x, event.button.y, &x, &y ); if ( state & SDL_BUTTON(1) ) { GameTap( game, GAME_TAP_MOVE, x, y ); } else if ( zooming && (state & SDL_BUTTON(3)) ) { float deltaZoom = 0.01f * (float)zoomY; GameZoom( game, GAME_ZOOM_DISTANCE, deltaZoom ); GameCameraRotate( game, (float)(zoomX)*0.5f ); } else if ( ( ( state & SDL_BUTTON(1) ) == 0 ) ) { ((Game*)game)->MouseMove( x, y ); } } break; case SDL_QUIT: { done = true; } break; case SDL_USEREVENT: { glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); for( int stick=0; stick<2; ++stick ) { if ( joystickAxis[stick].x || joystickAxis[stick].y ) { GameJoyStick( game, stick, joystickAxis[stick].x, joystickAxis[stick].y ); } } GameDoTick( game, SDL_GetTicks() ); SDL_GL_SwapBuffers(); int databaseID=0, size=0, offset=0; // FIXME: account for databaseID when looking up sound. while ( GamePopSound( game, &databaseID, &offset, &size ) ) { Audio_PlayWav( "./res/uforesource.db", offset, size ); } }; default: break; } #ifdef TEST_FULLSPEED } glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); GameDoTick( game, SDL_GetTicks() ); SDL_GL_SwapBuffers(); } #else }
// translated to utf8_main int main(int argc, char *argv[]) { int res = 0; #if defined(SDLMAME_X11) && !(SDLMAME_SDL2) XInitThreads(); #endif #if defined(SDLMAME_WIN32) #if !(SDLMAME_SDL2) /* Load SDL dynamic link library */ if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { fprintf(stderr, "WinMain() error: %s", SDL_GetError()); return(FALSE); } SDL_SetModuleHandle(GetModuleHandle(NULL)); #endif #endif // disable I/O buffering setvbuf(stdout, (char *) NULL, _IONBF, 0); setvbuf(stderr, (char *) NULL, _IONBF, 0); // FIXME: this should be done differently #ifdef SDLMAME_UNIX sdl_entered_debugger = 0; #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) FcInit(); #endif #endif #ifdef SDLMAME_OS2 MorphToPM(); #endif #if defined(SDLMAME_X11) && (SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2) if (SDL_Linked_Version()->patch < 10) /* workaround for SDL choosing a 32-bit ARGB visual */ { Display *display; if ((display = XOpenDisplay(NULL)) && (DefaultDepth(display, DefaultScreen(display)) >= 24)) { XVisualInfo vi; char buf[130]; if (XMatchVisualInfo(display, DefaultScreen(display), 24, TrueColor, &vi)) { snprintf(buf, sizeof(buf), "0x%lx", vi.visualid); osd_setenv(SDLENV_VISUALID, buf, 0); } } if (display) XCloseDisplay(display); } #endif { sdl_options options; sdl_osd_interface osd(options); osd.register_options(); cli_frontend frontend(options, osd); res = frontend.execute(argc, argv); } #ifdef SDLMAME_UNIX #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) && (!defined(SDLMAME_EMSCRIPTEN)) if (!sdl_entered_debugger) { FcFini(); } #endif #endif exit(res); }
int main(int argc, char **argv) { int res = 0; #else /* gee */ extern "C" DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); // translated to utf8_main int main(int argc, char *argv[]) { int res = 0; #if !(SDLMAME_SDL2) /* Load SDL dynamic link library */ if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { fprintf(stderr, "WinMain() error: %s", SDL_GetError()); return(FALSE); } SDL_SetModuleHandle(GetModuleHandle(NULL)); #endif #endif // disable I/O buffering setvbuf(stdout, (char *) NULL, _IONBF, 0); setvbuf(stderr, (char *) NULL, _IONBF, 0); #ifdef SDLMAME_UNIX #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) if (TTF_Init() == -1) { printf("SDL_ttf failed: %s\n", TTF_GetError()); } FcInit(); #endif #endif #ifdef SDLMAME_OS2 MorphToPM(); #endif #if defined(SDLMAME_X11) && (SDL_MAJOR_VERSION == 1) && (SDL_MINOR_VERSION == 2) if (SDL_Linked_Version()->patch < 10) /* workaround for SDL choosing a 32-bit ARGB visual */ { Display *display; if ((display = XOpenDisplay(NULL)) && (DefaultDepth(display, DefaultScreen(display)) >= 24)) { XVisualInfo vi; char buf[130]; if (XMatchVisualInfo(display, DefaultScreen(display), 24, TrueColor, &vi)) { snprintf(buf, sizeof(buf), "0x%lx", vi.visualid); osd_setenv(SDLENV_VISUALID, buf, 0); } } if (display) XCloseDisplay(display); } #endif { sdl_osd_interface osd; sdl_options options; cli_frontend frontend(options, osd); res = frontend.execute(argc, argv); } #ifdef MALLOC_DEBUG { void check_unfreed_mem(void); check_unfreed_mem(); } #endif // already called... //SDL_Quit(); #ifdef SDLMAME_UNIX #if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_HAIKU)) TTF_Quit(); FcFini(); #endif #endif exit(res); return res; }
AboutDialog::AboutDialog (wxWindow *parent) : wxDialog (parent, -1, _("About ..."), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { // sets the application icon SetTitle (_("About ...")); const SDL_version* sdlVersion = SDL_Linked_Version(); wxString stringSDLVersion; stringSDLVersion << (int)sdlVersion->major << wxT(".") << (int)sdlVersion->minor << wxT(".") << (int)sdlVersion->patch; // about info wxFlexGridSizer *aboutinfo = new wxFlexGridSizer (2, 3, 3); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Version: "))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT(APP_VERSION))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Written by: "))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT(APP_MAINT))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Licence type: "))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT(APP_LICENCE))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("wxWidgets: "))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxVERSION_STRING)); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("SDL: "))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, stringSDLVersion)); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Thanks to: "))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, _("Authors of Pan Docs"))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT(""))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT("bcrew1375 (Miracle GB)"))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT(""))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT("AntonioND (GiiBii)"))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT(""))); aboutinfo->Add (new wxStaticText(this, wxID_ANY, wxT("Shay Green (Gb_Snd_Emu)"))); // about icontitle//info wxBoxSizer *aboutpane = new wxBoxSizer (wxHORIZONTAL); aboutpane->Add (new wxStaticBitmap (this, wxID_ANY, wxBitmap (gb64_xpm)), 0, wxRIGHT, 10); aboutpane->Add (aboutinfo, 0, wxEXPAND); //aboutpane->Add (60, 0); // about complete wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL); totalpane->Add (0, 20); wxStaticText *appname = new wxStaticText (this, wxID_ANY, wxT(APP_NAME)); appname->SetFont (wxFont (24, wxDEFAULT, wxNORMAL, wxBOLD)); totalpane->Add (appname, 0, wxALIGN_CENTER); totalpane->Add (0, 10); totalpane->Add (aboutpane, 0, wxALIGN_CENTER | wxRIGHT | wxLEFT, 20); totalpane->Add (0, 10); wxHyperlinkCtrl *website = new wxHyperlinkCtrl (this, wxID_ANY, wxT(APP_WEBSITE), wxT(APP_WEBSITE)); totalpane->Add (website, 0, wxALIGN_CENTER); totalpane->Add (0, 10); wxButton *okButton = new wxButton (this, wxID_OK, _("OK")); okButton->SetDefault(); totalpane->Add (okButton, 0, wxALIGN_CENTER | wxALL, 10); SetSizerAndFit (totalpane); CentreOnParent(); ShowModal(); }
/* ================= main ================= */ int main(int argc, char **argv) { int i; char commandLine[MAX_STRING_CHARS] = { 0 }; #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version(); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if (SDL_VERSIONNUM(ver->major, ver->minor, ver->patch) < SDL_VERSIONNUM(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH)) { Sys_Dialog(DT_ERROR, va("SDL version " MINSDL_VERSION " or greater is required, " "but only version %d.%d.%d was found. You may be able to obtain a more recent copy " "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch), "SDL Library Too Old"); Sys_Exit(1); } #endif #ifdef __MORPHOS__ // don't let locales with decimal comma screw up the string to float conversions setlocale(LC_NUMERIC, "C"); DynLoadBase = OpenLibrary("dynload.library", 51); if (DynLoadBase && DynLoadBase->lib_Revision < 3) { CloseLibrary(DynLoadBase); DynLoadBase = NULL; } if (!DynLoadBase) { Sys_Dialog(DT_ERROR, "Unable to open dynload.library version 51.3 or newer", "dynload.library error"); Sys_Exit(1); } #endif Sys_PlatformInit(); // Set the initial time base Sys_Milliseconds(); Sys_ParseArgs(argc, argv); #if defined(__APPLE__) && !defined(DEDICATED) // argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS // But on OS X we want to pretend the binary path is the .app's parent // So that way the base folder is right next to the .app allowing { char parentdir[1024]; CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); if (!url) { Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath"); Sys_Exit(1); } CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024)) { Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath"); Sys_Exit(1); } Sys_SetBinaryPath(parentdir); CFRelease(url); CFRelease(url2); } #else Sys_SetBinaryPath(Sys_Dirname(argv[0])); #endif Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default // Concatenate the command line for passing to Com_Init for (i = 1; i < argc; i++) { const qboolean containsSpaces = (qboolean)(strchr(argv[i], ' ') != NULL); if (containsSpaces) { Q_strcat(commandLine, sizeof(commandLine), "\""); } Q_strcat(commandLine, sizeof(commandLine), argv[i]); if (containsSpaces) { Q_strcat(commandLine, sizeof(commandLine), "\""); } Q_strcat(commandLine, sizeof(commandLine), " "); } Com_Init(commandLine); NET_Init(); #ifdef FEATURE_CURSES if (nocurses) { CON_Init_tty(); } else { CON_Init(); } #else CON_Init(); #endif signal(SIGILL, Sys_SigHandler); signal(SIGFPE, Sys_SigHandler); signal(SIGSEGV, Sys_SigHandler); signal(SIGTERM, Sys_SigHandler); signal(SIGINT, Sys_SigHandler); while (1) { IN_Frame(); Com_Frame(); } return 0; }