OgrePlatform.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef __Platform_H_
00029 #define __Platform_H_
00030 
00031 #include "OgreConfig.h"
00032 
00033 namespace Ogre {
00034 /* Initial platform/compiler-related stuff to set.
00035 */
00036 #define OGRE_PLATFORM_WIN32 1
00037 #define OGRE_PLATFORM_LINUX 2
00038 #define OGRE_PLATFORM_APPLE 3
00039 #define OGRE_PLATFORM_SYMBIAN 4
00040 #define OGRE_PLATFORM_APPLE_IOS 5
00041 #define OGRE_PLATFORM_ANDROID 6
00042 #define OGRE_PLATFORM_NACL 7
00043 
00044 #define OGRE_COMPILER_MSVC 1
00045 #define OGRE_COMPILER_GNUC 2
00046 #define OGRE_COMPILER_BORL 3
00047 #define OGRE_COMPILER_WINSCW 4
00048 #define OGRE_COMPILER_GCCE 5
00049 #define OGRE_COMPILER_CLANG 6
00050 
00051 #define OGRE_ENDIAN_LITTLE 1
00052 #define OGRE_ENDIAN_BIG 2
00053 
00054 #define OGRE_ARCHITECTURE_32 1
00055 #define OGRE_ARCHITECTURE_64 2
00056 
00057 /* Finds the compiler type and version.
00058 */
00059 #if defined( __GCCE__ )
00060 #   define OGRE_COMPILER OGRE_COMPILER_GCCE
00061 #   define OGRE_COMP_VER _MSC_VER
00062 //# include <staticlibinit_gcce.h> // This is a GCCE toolchain workaround needed when compiling with GCCE 
00063 #elif defined( __WINSCW__ )
00064 #   define OGRE_COMPILER OGRE_COMPILER_WINSCW
00065 #   define OGRE_COMP_VER _MSC_VER
00066 #elif defined( _MSC_VER )
00067 #   define OGRE_COMPILER OGRE_COMPILER_MSVC
00068 #   define OGRE_COMP_VER _MSC_VER
00069 #elif defined( __clang__ )
00070 #   define OGRE_COMPILER OGRE_COMPILER_CLANG
00071 #   define OGRE_COMP_VER (((__clang_major__)*100) + \
00072         (__clang_minor__*10) + \
00073         __clang_patchlevel__)
00074 #elif defined( __GNUC__ )
00075 #   define OGRE_COMPILER OGRE_COMPILER_GNUC
00076 #   define OGRE_COMP_VER (((__GNUC__)*100) + \
00077         (__GNUC_MINOR__*10) + \
00078         __GNUC_PATCHLEVEL__)
00079 #elif defined( __BORLANDC__ )
00080 #   define OGRE_COMPILER OGRE_COMPILER_BORL
00081 #   define OGRE_COMP_VER __BCPLUSPLUS__
00082 #   define __FUNCTION__ __FUNC__ 
00083 #else
00084 #   pragma error "No known compiler. Abort! Abort!"
00085 
00086 #endif
00087 
00088 /* See if we can use __forceinline or if we need to use __inline instead */
00089 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00090 #   if OGRE_COMP_VER >= 1200
00091 #       define FORCEINLINE __forceinline
00092 #   endif
00093 #elif defined(__MINGW32__)
00094 #   if !defined(FORCEINLINE)
00095 #       define FORCEINLINE __inline
00096 #   endif
00097 #else
00098 #   define FORCEINLINE __inline
00099 #endif
00100 
00101 /* Finds the current platform */
00102 
00103 #if defined( __SYMBIAN32__ ) 
00104 #   define OGRE_PLATFORM OGRE_PLATFORM_SYMBIAN
00105 #elif defined( __WIN32__ ) || defined( _WIN32 )
00106 #   define OGRE_PLATFORM OGRE_PLATFORM_WIN32
00107 #elif defined( __APPLE_CC__)
00108     // Device                                                     Simulator
00109     // Both requiring OS version 4.0 or greater
00110 #   if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
00111 #       define OGRE_PLATFORM OGRE_PLATFORM_APPLE_IOS
00112 #   else
00113 #       define OGRE_PLATFORM OGRE_PLATFORM_APPLE
00114 #   endif
00115 #elif defined(__ANDROID__)
00116 #   define OGRE_PLATFORM OGRE_PLATFORM_ANDROID
00117 #elif defined( __native_client__ ) 
00118 #   define OGRE_PLATFORM OGRE_PLATFORM_NACL
00119 #   ifndef OGRE_STATIC_LIB
00120 #       error OGRE must be built as static for NaCl (OGRE_STATIC=true in CMake)
00121 #   endif
00122 #   ifdef OGRE_BUILD_RENDERSYSTEM_D3D9
00123 #       error D3D9 is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_D3D9 false in CMake)
00124 #   endif
00125 #   ifdef OGRE_BUILD_RENDERSYSTEM_GL
00126 #       error OpenGL is not supported on NaCl (OGRE_BUILD_RENDERSYSTEM_GL=false in CMake)
00127 #   endif
00128 #   ifndef OGRE_BUILD_RENDERSYSTEM_GLES2
00129 #       error GLES2 render system is required for NaCl (OGRE_BUILD_RENDERSYSTEM_GLES2=false in CMake)
00130 #   endif
00131 #else
00132 #   define OGRE_PLATFORM OGRE_PLATFORM_LINUX
00133 #endif
00134 
00135     /* Find the arch type */
00136 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
00137 #   define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_64
00138 #else
00139 #   define OGRE_ARCH_TYPE OGRE_ARCHITECTURE_32
00140 #endif
00141 
00142 // For generating compiler warnings - should work on any compiler
00143 // As a side note, if you start your message with 'Warning: ', the MSVC
00144 // IDE actually does catch a warning :)
00145 #define OGRE_QUOTE_INPLACE(x) # x
00146 #define OGRE_QUOTE(x) OGRE_QUOTE_INPLACE(x)
00147 #define OGRE_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
00148 
00149 //----------------------------------------------------------------------------
00150 // Windows Settings
00151 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
00152 
00153 // If we're not including this from a client build, specify that the stuff
00154 // should get exported. Otherwise, import it.
00155 #   if defined( OGRE_STATIC_LIB )
00156         // Linux compilers don't have symbol import/export directives.
00157 #       define _OgreExport
00158 #       define _OgrePrivate
00159 #   else
00160 #       if defined( OGRE_NONCLIENT_BUILD )
00161 #           define _OgreExport __declspec( dllexport )
00162 #       else
00163 #           if defined( __MINGW32__ )
00164 #               define _OgreExport
00165 #           else
00166 #               define _OgreExport __declspec( dllimport )
00167 #           endif
00168 #       endif
00169 #       define _OgrePrivate
00170 #   endif
00171 // Win32 compilers use _DEBUG for specifying debug builds.
00172 // for MinGW, we set DEBUG
00173 #   if defined(_DEBUG) || defined(DEBUG)
00174 #       define OGRE_DEBUG_MODE 1
00175 #   else
00176 #       define OGRE_DEBUG_MODE 0
00177 #   endif
00178 
00179 // Disable unicode support on MingW for GCC 3, poorly supported in stdlibc++
00180 // STLPORT fixes this though so allow if found
00181 // MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLBOX_UNICODE__ in _mingw.h
00182 // GCC 4 is also fine
00183 #if defined(__MINGW32__)
00184 # if OGRE_COMP_VER < 400
00185 #  if !defined(_STLPORT_VERSION)
00186 #   include<_mingw.h>
00187 #   if defined(__MINGW32_TOOLBOX_UNICODE__) || OGRE_COMP_VER > 345
00188 #    define OGRE_UNICODE_SUPPORT 1
00189 #   else
00190 #    define OGRE_UNICODE_SUPPORT 0
00191 #   endif
00192 #  else
00193 #   define OGRE_UNICODE_SUPPORT 1
00194 #  endif
00195 # else
00196 #  define OGRE_UNICODE_SUPPORT 1
00197 # endif
00198 #else
00199 #  define OGRE_UNICODE_SUPPORT 1
00200 #endif
00201 
00202 #endif // OGRE_PLATFORM == OGRE_PLATFORM_WIN32
00203 
00204 //----------------------------------------------------------------------------
00205 // Symbian Settings
00206 #if OGRE_PLATFORM == OGRE_PLATFORM_SYMBIAN
00207 #   define _OgreExport 
00208 #   define OGRE_UNICODE_SUPPORT 1
00209 #   define OGRE_DEBUG_MODE 0
00210 #   define _OgrePrivate
00211 #     define CLOCKS_PER_SEC  1000
00212 //  pragma def were found here: http://www.inf.pucrs.br/~eduardob/disciplinas/SistEmbarcados/Mobile/Nokia/Tools/Carbide_vs/WINSCW/Help/PDF/C_Compilers_Reference_3.2.pdf
00213 #     pragma warn_unusedarg off
00214 #     pragma warn_emptydecl off
00215 #     pragma warn_possunwant off
00216 // A quick define to overcome different names for the same function
00217 #   define stricmp strcasecmp
00218 #   ifdef DEBUG
00219 #       define OGRE_DEBUG_MODE 1
00220 #   else
00221 #       define OGRE_DEBUG_MODE 0
00222 #   endif
00223 #endif
00224 //----------------------------------------------------------------------------
00225 // Android Settings
00226 /*
00227 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
00228 #   define _OgreExport 
00229 #   define OGRE_UNICODE_SUPPORT 1
00230 #   define OGRE_DEBUG_MODE 0
00231 #   define _OgrePrivate
00232 #     define CLOCKS_PER_SEC  1000
00233 //  pragma def were found here: http://www.inf.pucrs.br/~eduardob/disciplinas/SistEmbarcados/Mobile/Nokia/Tools/Carbide_vs/WINSCW/Help/PDF/C_Compilers_Reference_3.2.pdf
00234 #     pragma warn_unusedarg off
00235 #     pragma warn_emptydecl off
00236 #     pragma warn_possunwant off
00237 // A quick define to overcome different names for the same function
00238 #   define stricmp strcasecmp
00239 #   ifdef DEBUG
00240 #       define OGRE_DEBUG_MODE 1
00241 #   else
00242 #       define OGRE_DEBUG_MODE 0
00243 #   endif
00244 #endif
00245 */
00246 //----------------------------------------------------------------------------
00247 // Linux/Apple/iOs/Android/Symbian/NaCl Settings
00248 #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS || \
00249     OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_NACL
00250 
00251 // Enable GCC symbol visibility
00252 #   if defined( OGRE_GCC_VISIBILITY )
00253 #       define _OgreExport  __attribute__ ((visibility("default")))
00254 #       define _OgrePrivate __attribute__ ((visibility("hidden")))
00255 #   else
00256 #       define _OgreExport
00257 #       define _OgrePrivate
00258 #   endif
00259 
00260 // A quick define to overcome different names for the same function
00261 #   define stricmp strcasecmp
00262 
00263 #   ifdef DEBUG
00264 #       define OGRE_DEBUG_MODE 1
00265 #   else
00266 #       define OGRE_DEBUG_MODE 0
00267 #   endif
00268 
00269 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
00270     #define OGRE_PLATFORM_LIB "OgrePlatform.bundle"
00271 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
00272     #define OGRE_PLATFORM_LIB "OgrePlatform.a"
00273 #else //OGRE_PLATFORM_LINUX
00274     #define OGRE_PLATFORM_LIB "libOgrePlatform.so"
00275 #endif
00276 
00277 // Always enable unicode support for the moment
00278 // Perhaps disable in old versions of gcc if necessary
00279 #define OGRE_UNICODE_SUPPORT 1
00280 
00281 #endif
00282 
00283 //----------------------------------------------------------------------------
00284 // Endian Settings
00285 // check for BIG_ENDIAN config flag, set OGRE_ENDIAN correctly
00286 #ifdef OGRE_CONFIG_BIG_ENDIAN
00287 #    define OGRE_ENDIAN OGRE_ENDIAN_BIG
00288 #else
00289 #    define OGRE_ENDIAN OGRE_ENDIAN_LITTLE
00290 #endif
00291 
00292 // Integer formats of fixed bit width
00293 typedef unsigned int uint32;
00294 typedef unsigned short uint16;
00295 typedef unsigned char uint8;
00296 typedef int int32;
00297 typedef short int16;
00298 typedef char int8;
00299 // define uint64 type
00300 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
00301     typedef unsigned __int64 uint64;
00302     typedef __int64 int64;
00303 #else
00304     typedef unsigned long long uint64;
00305     typedef long long int64;
00306 #endif
00307 
00308 
00309 }
00310 
00311 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:25 2012