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 00029 #ifndef __GLES2Prerequisites_H__ 00030 #define __GLES2Prerequisites_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgreLogManager.h" 00034 #include "OgreMath.h" 00035 00036 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) 00037 # if !defined( __MINGW32__ ) 00038 # define __PRETTY_FUNCTION__ __FUNCTION__ 00039 # ifndef WIN32_LEAN_AND_MEAN 00040 # define WIN32_LEAN_AND_MEAN 1 00041 # endif 00042 # ifndef NOMINMAX 00043 # define NOMINMAX // required to stop windows.h messing up std::min 00044 # endif 00045 # endif 00046 #endif 00047 00048 #ifndef GL_GLEXT_PROTOTYPES 00049 # define GL_GLEXT_PROTOTYPES 00050 #endif 00051 00052 #if (OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS) 00053 # include <OpenGLES/ES2/gl.h> 00054 # include <OpenGLES/ES2/glext.h> 00055 # ifdef __OBJC__ 00056 # include <OpenGLES/EAGL.h> 00057 # endif 00058 #elif (OGRE_PLATFORM == OGRE_PLATFORM_ANDROID) || (OGRE_PLATFORM == OGRE_PLATFORM_NACL) 00059 # ifndef GL_GLEXT_PROTOTYPES 00060 # define GL_GLEXT_PROTOTYPES 00061 # endif 00062 # include <GLES2/gl2platform.h> 00063 # include <GLES2/gl2.h> 00064 # include <GLES2/gl2ext.h> 00065 # if (OGRE_PLATFORM == OGRE_PLATFORM_NACL) 00066 # include "ppapi/cpp/completion_callback.h" 00067 # include "ppapi/cpp/instance.h" 00068 # include "ppapi/c/ppp_graphics_3d.h" 00069 # include "ppapi/cpp/graphics_3d.h" 00070 # include "ppapi/cpp/graphics_3d_client.h" 00071 # include "ppapi/gles2/gl2ext_ppapi.h" 00072 # undef GL_OES_get_program_binary 00073 # undef GL_OES_mapbuffer 00074 # endif 00075 #else 00076 # include <GLES2/gl2.h> 00077 # include <GLES2/gl2ext.h> 00078 # include <EGL/egl.h> 00079 00080 // Function pointers for FBO extension methods 00081 // Declare them here since we don't have GLEW to do it for us 00082 00083 # ifndef GL_GLEXT_PROTOTYPES 00084 extern PFNGLMAPBUFFEROESPROC glMapBufferOES; 00085 extern PFNGLUNMAPBUFFEROESPROC glUnmapBufferOES; 00086 extern PFNGLDRAWBUFFERSARBPROC glDrawBuffersARB; 00087 extern PFNGLREADBUFFERNVPROC glReadBufferNV; 00088 extern PFNGLGETCOMPRESSEDTEXIMAGENVPROC glGetCompressedTexImageNV; 00089 extern PFNGLGETTEXIMAGENVPROC glGetTexImageNV; 00090 extern PFNGLGETTEXLEVELPARAMETERFVNVPROC glGetTexLevelParameterfvNV; 00091 extern PFNGLGETTEXLEVELPARAMETERiVNVPROC glGetTexLevelParameterivNV; 00092 # endif 00093 00094 // If we are going to use the PVRTC_CODEC make sure we 00095 // setup the needed constants 00096 #if (OGRE_NO_PVRTC_CODEC == 0) 00097 # ifndef GL_IMG_texture_compression_pvrtc 00098 # define GL_IMG_texture_compression_pvrtc 1 00099 # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 00100 # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 00101 # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 00102 # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 00103 # endif 00104 #endif 00105 00106 #endif 00107 00108 00109 // Define GL_NONE for convenience 00110 #define GL_NONE 0 00111 00112 #if !defined(GL_BGRA) && OGRE_PLATFORM != OGRE_PLATFORM_NACL 00113 # define GL_BGRA 0x80E1 00114 #endif 00115 00116 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) 00117 // an error in all windows gles sdks... 00118 # undef GL_OES_get_program_binary 00119 #endif 00120 00121 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(OGRE_STATIC_LIB) 00122 # ifdef OGRE_GLES2PLUGIN_EXPORTS 00123 # define _OgreGLES2Export __declspec(dllexport) 00124 # else 00125 # if defined( __MINGW32__ ) 00126 # define _OgreGLES2Export 00127 # else 00128 # define _OgreGLES2Export __declspec(dllimport) 00129 # endif 00130 # endif 00131 #elif defined ( OGRE_GCC_VISIBILITY ) 00132 # define _OgreGLES2Export __attribute__ ((visibility("default"))) 00133 #else 00134 # define _OgreGLES2Export 00135 #endif 00136 00137 #define DEBUG_(text) \ 00138 {\ 00139 fprintf(stderr, "%s:%d: %s\n", __FUNCTION__, __LINE__, text); \ 00140 } 00141 00142 #define ENABLE_GL_CHECK 0 00143 00144 #if ENABLE_GL_CHECK 00145 #define GL_CHECK_ERROR \ 00146 { \ 00147 int e = glGetError(); \ 00148 if (e != 0) \ 00149 { \ 00150 const char * errorString = ""; \ 00151 switch(e) \ 00152 { \ 00153 case GL_INVALID_ENUM: errorString = "GL_INVALID_ENUM"; break; \ 00154 case GL_INVALID_VALUE: errorString = "GL_INVALID_VALUE"; break; \ 00155 case GL_INVALID_OPERATION: errorString = "GL_INVALID_OPERATION"; break; \ 00156 case GL_OUT_OF_MEMORY: errorString = "GL_OUT_OF_MEMORY"; break; \ 00157 default: break; \ 00158 } \ 00159 char msgBuf[10000]; \ 00160 sprintf(msgBuf, "OpenGL ES2 error 0x%04X %s in %s at line %i\n", e, errorString, __PRETTY_FUNCTION__, __LINE__); \ 00161 LogManager::getSingleton().logMessage(msgBuf); \ 00162 } \ 00163 } 00164 #else 00165 #define GL_CHECK_ERROR {} 00166 #endif 00167 00168 #if ENABLE_GL_CHECK 00169 #define EGL_CHECK_ERROR \ 00170 { \ 00171 int e = eglGetError(); \ 00172 if ((e != 0) && (e != EGL_SUCCESS))\ 00173 { \ 00174 char msgBuf[10000]; \ 00175 sprintf(msgBuf, "EGL error 0x%04X in %s at line %i\n", e, __PRETTY_FUNCTION__, __LINE__); \ 00176 LogManager::getSingleton().logMessage(msgBuf); \ 00177 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, msgBuf, __PRETTY_FUNCTION__); \ 00178 } \ 00179 } 00180 #else 00181 #define EGL_CHECK_ERROR {} 00182 #endif 00183 00184 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:21