00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_HPP_)
00012 #define _XRB_HPP_
00013
00014
00015
00016
00017
00018 #if defined(HAVE_CONFIG_H)
00019 #include "config.h"
00020 #endif // defined(HAVE_CONFIG_H)
00021
00022
00023
00024
00025
00026 #ifdef __WIN32__
00027
00028 #define WIN32_LEAN_AND_MEAN
00029
00030 #ifndef NOMINMAX
00031 #define NOMINMAX
00032 #endif
00033 #include <windows.h>
00034 #endif
00035
00036 #if defined(__APPLE__)
00037
00038 #include "AvailabilityMacros.h"
00039 #ifdef MAC_OS_X_VERSION_10_3
00040 #include "targetconditionals.h"
00041 #if TARGET_OS_IPHONE
00042 #undef __IPHONEOS__
00043 #define __IPHONEOS__ 1
00044 #undef __MACOSX__
00045 #else
00046 #undef __MACOSX__
00047 #define __MACOSX__ 1
00048 #endif
00049 #else
00050 #undef __MACOSX__
00051 #define __MACOSX__ 1
00052 #endif
00053 #endif
00054
00055
00056 #define XRB_PLATFORM_SDL 0
00057 #define XRB_PLATFORM_IPHONE 1
00058
00059 #if __IPHONEOS__ == 1
00060 #define XRB_PLATFORM XRB_PLATFORM_IPHONE
00061 #else
00062 #define XRB_PLATFORM XRB_PLATFORM_SDL
00063 #endif
00064
00065
00066 #if !defined(NULL)
00067 #define NULL 0
00068 #endif
00069
00070
00071 #define GL_GLEXT_PROTOTYPES
00072
00073
00074
00075
00076
00077 #include "xrb_assert.hpp"
00078 #include "xrb_debug.hpp"
00079 #include "xrb_delete.hpp"
00080 #include "xrb_singleton.hpp"
00081 #include "xrb_types.hpp"
00082
00083 #if defined(WIN32)
00084 #if defined(DELETE)
00085 #undef DELETE
00086 #endif
00087 #if defined(ERROR)
00088 #undef ERROR
00089 #endif
00090 #endif // defined(WIN32)
00091
00097 namespace Xrb
00098 {
00099
00104 template <typename T>
00105 inline T Abs (T const &x)
00106 {
00107 return (x < static_cast<T>(0)) ? -x : x;
00108 }
00109
00113 template <typename T>
00114 inline T const &Min (T const &x, T const &y)
00115 {
00116 return (x < y) ? x : y;
00117 }
00118
00122 template <typename T>
00123 inline T const &Max (T const &x, T const &y)
00124 {
00125 return (x < y) ? y : x;
00126 }
00127
00131 template <typename T>
00132 inline bool Epsilon (T const x, T const y, T const epsilon)
00133 {
00134 return x - y >= -epsilon && x - y <= epsilon;
00135 }
00136
00140 template <typename CastToType, typename CastFromType>
00141 inline CastToType DStaticCast (CastFromType cast_from)
00142 {
00143 ASSERT1(cast_from == NULL || dynamic_cast<CastToType>(cast_from) != NULL);
00144 return static_cast<CastToType>(cast_from);
00145 }
00146
00153 template <typename ContainerType>
00154 inline void StlContainerEraseRBegin (ContainerType &container)
00155 {
00156 ASSERT1(!container.empty());
00157 container.erase(typename ContainerType::iterator((++container.rbegin()).base()));
00158 }
00159
00160 }
00161
00165 #define BOOL_TO_STRING(x) ((x) ? "true" : "false")
00166
00169 #define STRINGIFY(identifier) #identifier
00170
00173 #define FORMAT(x) static_cast<std::ostringstream &>(std::ostringstream().flush() << x).str()
00174
00175 #endif // !defined(_XRB_HPP_)
00176