1 // 2 // Platform.hpp -- Platform specific hacks. 3 // Copyright (C) 2006-2009 Nick Gasson 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License along 16 // with this program; if not, write to the Free Software Foundation, Inc., 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 // 19 20 #ifndef INC_PLATFORM_HPP 21 #define INC_PLATFORM_HPP 22 23 #ifdef HAVE_CONFIG_H 24 #include "config.h" 25 #else 26 #define DATADIR "." 27 #endif 28 29 // Windows specific constants and includes 30 #ifdef WIN32 31 32 #define WIN32_LEAN_AND_MEAN 33 #include <windows.h> 34 35 #include "SDL.h" 36 37 #include <GL\gl.h> 38 #include <GL\glu.h> 39 40 #ifndef M_PI 41 #define M_PI 3.1415926535897932384626433832795 42 #endif 43 44 #include <boost/tr1/memory.hpp> 45 46 #define msleep(n) Sleep(n) 47 48 #define i18n(x) x 49 50 #define PATH_MAX 256 51 52 // Don't have these on Windows for some reason 53 #ifndef GL_BGRA 54 #define GL_BGRA 0 55 #endif 56 #ifndef GL_BGR 57 #define GL_BGR 0 58 #endif 59 60 // Define safe snprintf, etc. for MSCV8 61 #if (_MSC_VER >= 1400) 62 63 #define USE_FOPEN_S 64 65 #ifndef snprintf 66 #define snprintf sprintf_s 67 #endif 68 69 #undef vsnprintf 70 #define vsnprintf(b, l, s, a) vsnprintf_s(b, l, (l)-1, s, a) 71 72 #undef strncpy 73 #define strncpy strncpy_s 74 75 #else /* MSVC7 or earlier */ 76 77 #ifndef snprintf 78 #define snprintf _snprintf 79 #endif 80 81 #ifndef vsnprintf 82 #define vsnprintf _vsnprintf 83 #endif 84 85 #endif /* #if (_MSC_VER >= 1400) */ 86 87 #else /* #ifdef WIN32 */ 88 89 #include <sys/types.h> 90 #include <sys/stat.h> 91 #include <unistd.h> 92 93 #endif /* #ifdef WIN32 */ 94 95 // Mac OS X specifics */ 96 #ifdef MACOSX 97 98 #include <GL/gl.h> 99 #include <GL/glu.h> 100 101 #define msleep(n) usleep((n)*1000) 102 103 #define i18n(x) x 104 105 #include "SDL.h" 106 107 #endif /* #ifdef MACOSX */ 108 109 // Linux specifics */ 110 #ifdef LINUX 111 112 #include <GL/gl.h> 113 #include <GL/glu.h> 114 115 #include <libintl.h> 116 #define i18n(x) gettext(x) 117 118 #define msleep(n) usleep((n)*1000) 119 120 #include "SDL.h" 121 122 #endif /* #ifdef LINUX */ 123 124 #include <string> 125 126 using namespace std; 127 #ifndef _LIBCPP_VERSION 128 #endif 129 130 void RecreateScreens(); 131 string LocateResource(const string& file); 132 string GetConfigDir(); 133 134 #endif /* #ifdef INC_PLATFORM_HPP */ 135