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-2013 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 #ifndef GL_GLEXT_PROTOTYPES 00037 # define GL_GLEXT_PROTOTYPES 00038 #endif 00039 00040 #if OGRE_NO_GLES3_SUPPORT == 0 00041 # include <GLES3/gles3w.h> 00042 #else 00043 # include <GLES2/gles2w.h> 00044 #endif 00045 00046 #if (OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS) 00047 # ifdef __OBJC__ 00048 # include <OpenGLES/EAGL.h> 00049 # if OGRE_NO_GLES3_SUPPORT == 0 00050 # define __gl_es20_h_ 00051 # define __gl_es20ext_h_ 00052 # ifndef GL_GLEXT_PROTOTYPES 00053 # define GL_GLEXT_PROTOTYPES 00054 # endif 00055 # endif 00056 # endif 00057 #elif (OGRE_PLATFORM == OGRE_PLATFORM_ANDROID) || (OGRE_PLATFORM == OGRE_PLATFORM_NACL) 00058 # ifndef GL_GLEXT_PROTOTYPES 00059 # define GL_GLEXT_PROTOTYPES 00060 # endif 00061 # if OGRE_NO_GLES3_SUPPORT == 0 00062 # include <GLES3/gl3platform.h> 00063 # include <GLES3/gl3.h> 00064 # else 00065 # include <GLES2/gl2platform.h> 00066 # include <GLES2/gl2.h> 00067 # include <GLES2/gl2ext.h> 00068 # endif 00069 # if (OGRE_PLATFORM == OGRE_PLATFORM_NACL) 00070 # include "ppapi/cpp/completion_callback.h" 00071 # include "ppapi/cpp/instance.h" 00072 # include "ppapi/c/ppp_graphics_3d.h" 00073 # include "ppapi/cpp/graphics_3d.h" 00074 # include "ppapi/cpp/graphics_3d_client.h" 00075 # include "ppapi/gles2/gl2ext_ppapi.h" 00076 # undef GL_OES_get_program_binary 00077 # undef GL_OES_mapbuffer 00078 # undef GL_OES_vertex_array_object 00079 # endif 00080 #else 00081 # if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) 00082 # if !defined( __MINGW32__ ) 00083 # define __PRETTY_FUNCTION__ __FUNCTION__ 00084 # ifndef WIN32_LEAN_AND_MEAN 00085 # define WIN32_LEAN_AND_MEAN 1 00086 # endif 00087 # ifndef NOMINMAX 00088 # define NOMINMAX // required to stop windows.h messing up std::min 00089 # endif 00090 # endif 00091 # endif 00092 # undef GL_GLEXT_PROTOTYPES 00093 # if OGRE_NO_GLES3_SUPPORT == 0 00094 # include <GLES3/gl3platform.h> 00095 # include <GLES3/gl3.h> 00096 # else 00097 # include <GLES2/gl2.h> 00098 # include <GLES2/gl2ext.h> 00099 # endif 00100 # include <EGL/egl.h> 00101 #endif 00102 00103 #if (OGRE_NO_ETC_CODEC == 0) 00104 # ifndef GL_OES_compressed_ETC1_RGB8_texture 00105 # define GL_OES_compressed_ETC1_RGB8_texture 1 00106 # define GL_ETC1_RGB8_OES 0x8D64 00107 # endif 00108 # define GL_COMPRESSED_RGB8_ETC2 0x9274 00109 # define GL_COMPRESSED_SRGB8_ETC2 0x9275 00110 # define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 00111 # define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 00112 # define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 00113 # define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 00114 #endif 00115 00116 #if (OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS) 00117 #define OGRE_IF_IOS_VERSION_IS_GREATER_THAN(vers) \ 00118 if(static_cast<EAGL2Support*>(dynamic_cast<GLES2RenderSystem*>(Root::getSingleton().getRenderSystem())->getGLSupportRef())->getCurrentOSVersion() >= vers) 00119 #else 00120 #define OGRE_IF_IOS_VERSION_IS_GREATER_THAN(vers) 00121 #endif 00122 00123 #define getGLES2SupportRef() dynamic_cast<GLES2RenderSystem*>(Root::getSingleton().getRenderSystem())->getGLSupportRef() 00124 00125 // Copy this definition from desktop GL. Used for polygon modes. 00126 #ifndef GL_FILL 00127 # define GL_FILL 0x1B02 00128 #endif 00129 00130 namespace Ogre { 00131 class GLES2GpuProgram; 00132 class GLES2Texture; 00133 typedef SharedPtr<GLES2GpuProgram> GLES2GpuProgramPtr; 00134 typedef SharedPtr<GLES2Texture> GLES2TexturePtr; 00135 }; 00136 00137 // Apple doesn't define this in their extension. We'll do it just for convenience. 00138 // Using the value from desktop GL 00139 #ifndef GL_SAMPLER_2D_SHADOW_EXT 00140 # define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 00141 #endif 00142 00143 #ifndef GL_EXT_texture_filter_anisotropic 00144 # define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE 00145 # define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF 00146 #endif 00147 00148 // Defines for extensions that were made core in OpenGL ES 3 00149 #if OGRE_NO_GLES3_SUPPORT == 0 00150 #ifndef GL_OES_mapbuffer 00151 #define GL_WRITE_ONLY_OES GL_MAP_WRITE_BIT 00152 #define glUnmapBufferOES glUnmapBuffer 00153 #endif 00154 00155 #ifndef GL_OES_texture_half_float 00156 #define GL_HALF_FLOAT_OES GL_HALF_FLOAT 00157 #endif 00158 00159 #ifndef GL_OES_rgb8_rgba8 00160 #define GL_RGB8_OES GL_RGB8 00161 #define GL_RGBA8_OES GL_RGBA8 00162 #endif 00163 00164 #ifndef GL_EXT_texture_rg 00165 #define GL_RG8_EXT GL_RG8 00166 #define GL_RED_EXT GL_RED 00167 #define GL_RG_EXT GL_RG 00168 #define GL_R8_EXT GL_R8 00169 #endif 00170 00171 #ifndef GL_EXT_texture_storage 00172 #define GL_R16F_EXT GL_R16F 00173 #define GL_R32F_EXT GL_R32F 00174 #define GL_RG16F_EXT GL_RG16F 00175 #define GL_RG32F_EXT GL_RG32F 00176 #define GL_RGB16F_EXT GL_RGB16F 00177 #define GL_RGB32F_EXT GL_RGB32F 00178 #define GL_RGBA16F_EXT GL_RGBA16F 00179 #define GL_RGBA32F_EXT GL_RGBA32F 00180 #define GL_DEPTH_COMPONENT32_OES GL_DEPTH_COMPONENT32F 00181 #endif 00182 00183 #ifndef GL_EXT_blend_minmax 00184 #define GL_MIN_EXT GL_MIN 00185 #define GL_MAX_EXT GL_MAX 00186 #endif 00187 00188 #ifndef GL_OES_depth24 00189 #define GL_DEPTH_COMPONENT24_OES GL_DEPTH_COMPONENT24 00190 #endif 00191 00192 #ifndef GL_OES_packed_depth_stencil 00193 #define GL_DEPTH24_STENCIL8_OES GL_DEPTH24_STENCIL8 00194 #endif 00195 00196 #ifndef GL_APPLE_texture_max_level 00197 #define GL_TEXTURE_MAX_LEVEL_APPLE GL_TEXTURE_MAX_LEVEL 00198 #endif 00199 00200 #ifndef GL_APPLE_framebuffer_multisample 00201 #define GL_MAX_SAMPLES_APPLE GL_MAX_SAMPLES 00202 #define glRenderbufferStorageMultisampleAPPLE glRenderbufferStorageMultisample 00203 #endif 00204 00205 #ifndef GL_EXT_occlusion_query_boolean 00206 #define GL_ANY_SAMPLES_PASSED_EXT GL_ANY_SAMPLES_PASSED 00207 #define GL_QUERY_RESULT_EXT GL_QUERY_RESULT 00208 #define GL_QUERY_RESULT_AVAILABLE_EXT GL_QUERY_RESULT_AVAILABLE 00209 #define glGenQueriesEXT glGenQueries 00210 #define glDeleteQueriesEXT glDeleteQueries 00211 #define glBeginQueryEXT glBeginQuery 00212 #define glEndQueryEXT glEndQuery 00213 #define glGetQueryObjectuivEXT glGetQueryObjectuiv 00214 #endif 00215 00216 #ifndef GL_EXT_map_buffer_range 00217 #define GL_MAP_WRITE_BIT_EXT GL_MAP_WRITE_BIT 00218 #define GL_MAP_FLUSH_EXPLICIT_BIT_EXT GL_MAP_FLUSH_EXPLICIT_BIT 00219 #define GL_MAP_INVALIDATE_RANGE_BIT_EXT GL_MAP_INVALIDATE_RANGE_BIT 00220 #define GL_MAP_UNSYNCHRONIZED_BIT_EXT GL_MAP_UNSYNCHRONIZED_BIT 00221 #define GL_MAP_READ_BIT_EXT GL_MAP_READ_BIT 00222 #define glMapBufferRangeEXT glMapBufferRange 00223 #define glFlushMappedBufferRangeEXT glFlushMappedBufferRange 00224 #endif 00225 00226 #ifndef GL_APPLE_sync 00227 #define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE GL_SYNC_GPU_COMMANDS_COMPLETE 00228 #define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE GL_SYNC_FLUSH_COMMANDS_BIT 00229 #define GL_TIMEOUT_IGNORED_APPLE GL_TIMEOUT_IGNORED 00230 #define GL_WAIT_FAILED_APPLE GL_WAIT_FAILED 00231 #define glFenceSyncAPPLE glFenceSync 00232 #define glClientWaitSyncAPPLE glClientWaitSync 00233 #define glDeleteSyncAPPLE glDeleteSync 00234 #endif 00235 00236 #define GL_PROGRAM_BINARY_LENGTH_OES GL_PROGRAM_BINARY_LENGTH 00237 #define glProgramBinaryOES glProgramBinary 00238 #define glGetProgramBinaryOES glGetProgramBinary 00239 00240 #define glDrawElementsInstancedEXT glDrawElementsInstanced 00241 #define glDrawArraysInstancedEXT glDrawArraysInstanced 00242 #define glVertexAttribDivisorEXT glVertexAttribDivisor 00243 #define glBindVertexArrayOES glBindVertexArray 00244 #define glGenVertexArraysOES glGenVertexArrays 00245 #define glDeleteVertexArraysOES glDeleteVertexArrays 00246 #endif 00247 00248 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) 00249 // an error in all windows gles sdks... 00250 # undef GL_OES_get_program_binary 00251 #endif 00252 00253 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(OGRE_STATIC_LIB) 00254 # ifdef OGRE_GLES2PLUGIN_EXPORTS 00255 # define _OgreGLES2Export __declspec(dllexport) 00256 # else 00257 # if defined( __MINGW32__ ) 00258 # define _OgreGLES2Export 00259 # else 00260 # define _OgreGLES2Export __declspec(dllimport) 00261 # endif 00262 # endif 00263 #elif defined ( OGRE_GCC_VISIBILITY ) 00264 # define _OgreGLES2Export __attribute__ ((visibility("default"))) 00265 #else 00266 # define _OgreGLES2Export 00267 #endif 00268 00269 #define DEBUG_(text) \ 00270 {\ 00271 fprintf(stderr, "%s:%d: %s\n", __FUNCTION__, __LINE__, text); \ 00272 } 00273 00274 #define ENABLE_GL_CHECK 0 00275 00276 #if ENABLE_GL_CHECK 00277 #define OGRE_CHECK_GL_ERROR(glFunc) \ 00278 { \ 00279 glFunc; \ 00280 int e = glGetError(); \ 00281 if (e != 0) \ 00282 { \ 00283 const char * errorString = ""; \ 00284 switch(e) \ 00285 { \ 00286 case GL_INVALID_ENUM: errorString = "GL_INVALID_ENUM"; break; \ 00287 case GL_INVALID_VALUE: errorString = "GL_INVALID_VALUE"; break; \ 00288 case GL_INVALID_OPERATION: errorString = "GL_INVALID_OPERATION"; break; \ 00289 case GL_OUT_OF_MEMORY: errorString = "GL_OUT_OF_MEMORY"; break; \ 00290 default: break; \ 00291 } \ 00292 char msgBuf[4096]; \ 00293 StringVector tokens = StringUtil::split(#glFunc, "("); \ 00294 sprintf(msgBuf, "OpenGL error 0x%04X %s in %s at line %i for %s\n", e, errorString, __PRETTY_FUNCTION__, __LINE__, tokens[0].c_str()); \ 00295 LogManager::getSingleton().logMessage(msgBuf); \ 00296 } \ 00297 } 00298 #else 00299 # define OGRE_CHECK_GL_ERROR(glFunc) { glFunc; } 00300 #endif 00301 00302 #if ENABLE_GL_CHECK 00303 #define EGL_CHECK_ERROR \ 00304 { \ 00305 int e = eglGetError(); \ 00306 if ((e != 0) && (e != EGL_SUCCESS))\ 00307 { \ 00308 char msgBuf[4096]; \ 00309 sprintf(msgBuf, "EGL error 0x%04X in %s at line %i\n", e, __PRETTY_FUNCTION__, __LINE__); \ 00310 LogManager::getSingleton().logMessage(msgBuf); \ 00311 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, msgBuf, __PRETTY_FUNCTION__); \ 00312 } \ 00313 } 00314 #else 00315 #define EGL_CHECK_ERROR {} 00316 #endif 00317 00318 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:42