00001 #ifndef GSGL_PLATFORM_HARDWARE_H
00002 #define GSGL_PLATFORM_HARDWARE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "platform/platform.hpp"
00038 #include "data/string.hpp"
00039 #include "data/log.hpp"
00040
00041 #if defined(__APPLE__)
00042
00043 #include <OpenGL/GL.h>
00044 #include <OpenGL/GLU.h>
00045 #include <OpenGL/glext.h>
00046
00047 #include <AGL/agl.h>
00048 #include <Carbon/Carbon.h>
00049
00050 #include <SDL/SDL.h>
00051 #include <SDL/SDL_syswm.h>
00052 #include <SDL/SDL_thread.h>
00053 #include <SDL_ttf/SDL_ttf.h>
00054 #include <SDL_image/SDL_image.h>
00055
00056 #elif defined(WIN32)
00057
00058 #ifndef WINVER // Allow use of features specific to Windows XP or later.
00059 #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
00060 #endif
00061
00062 #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
00063 #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
00064 #endif
00065
00066 #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
00067 #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
00068 #endif
00069
00070 #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
00071 #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
00072 #endif
00073
00074 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
00075 #include <windows.h>
00076 #include <shlobj.h>
00077
00078 #include <GL/glew.h>
00079 #include <GL/GL.h>
00080 #include <GL/GLU.h>
00081
00082 #include <SDL.h>
00083 #include <SDL_syswm.h>
00084 #include <SDL_thread.h>
00085 #include <SDL_ttf.h>
00086 #include <SDL_image.h>
00087
00088 #endif
00089
00090
00091 #ifdef DEBUG
00092 #define CHECK_GL_ERRORS() \
00093 { \
00094 gsgl::string _gl_err_msg_; \
00095 char *_sdl_err_; \
00096 int _gl_err_code_; \
00097 glFlush(); \
00098 while ((_gl_err_code_ = glGetError()) != GL_NO_ERROR) \
00099 { \
00100 _gl_err_msg_ += gsgl::string::format(L"%d: %ls.\n", _gl_err_code_, gsgl::string((const char *)gluErrorString(_gl_err_code_)).w_string()); \
00101 } \
00102 _sdl_err_ = SDL_GetError(); \
00103 if (_sdl_err_ && *_sdl_err_) \
00104 _gl_err_msg_ += gsgl::string::format(L"%hs.\n", gsgl::string(_sdl_err_)); \
00105 if (_gl_err_msg_.size()) \
00106 { \
00107 dynamic_cast<gsgl::data::logger *>(gsgl::data::logger::global_instance())->print_line(gsgl::data::logger::LOG_LEVEL_BASIC, _gl_err_msg_.w_string()); \
00108 throw gsgl::opengl_exception(__FILE__, __LINE__, L"\n\nOpenGL errors: %ls", _gl_err_msg_.w_string()); \
00109 } \
00110 }
00111 #else
00112 #define CHECK_GL_ERRORS()
00113 #endif
00114
00115 #endif