OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLESPrerequisites.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
8 Copyright (c) 2000-2014 Torus Knot Software Ltd
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 
30 #ifndef __GLESPrerequisites_H__
31 #define __GLESPrerequisites_H__
32 
33 #include "OgrePrerequisites.h"
34 #include "OgreMath.h"
35 
36 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
37 # if !defined( __MINGW32__ )
38 # ifndef WIN32_LEAN_AND_MEAN
39 # define WIN32_LEAN_AND_MEAN 1
40 # endif
41 # ifndef NOMINMAX
42 # define NOMINMAX // required to stop windows.h messing up std::min
43 # endif
44 # endif
45 #endif
46 
47 #if (OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS)
48 # include <OpenGLES/ES1/gl.h>
49 # include <OpenGLES/ES1/glext.h>
50 # ifdef __OBJC__
51 # include <OpenGLES/EAGL.h>
52 # endif
53 # ifndef GL_GLEXT_PROTOTYPES
54 # define GL_GLEXT_PROTOTYPES
55 # endif
56 #elif (OGRE_PLATFORM == OGRE_PLATFORM_ANDROID)
57 # ifndef GL_GLEXT_PROTOTYPES
58 # define GL_GLEXT_PROTOTYPES
59 # endif
60 # include <GLES/glplatform.h>
61 # include <GLES/gl.h>
62 # include <GLES/glext.h>
63 # include <EGL/egl.h>
64 #else
65 # include <GLES/gl.h>
66 # include <GLES/glext.h>
67 # include <GLES/egl.h>
68 
69 // If we are going to use the PVRTC_CODEC make sure we
70 // setup the needed constants
71 #if OGRE_NO_PVRTC_CODEC == 0
72 # ifndef GL_IMG_texture_compression_pvrtc
73 # define GL_IMG_texture_compression_pvrtc 1
74 # define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
75 # define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
76 # define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
77 # define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
78 # endif
79 #endif
80 
81 /* GL_EXT_texture_compression_dxt1 */
82 #ifndef GL_EXT_texture_compression_dxt1
83 # define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
84 # define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
85 #endif
86 
87 // Function pointers for FBO extension methods
88 // Declare them here since we don't have GLEW to do it for us
89 
90 # ifndef GL_GLEXT_PROTOTYPES
91 extern PFNGLISRENDERBUFFEROESPROC glIsRenderbufferOES;
92 extern PFNGLBINDRENDERBUFFEROESPROC glBindRenderbufferOES;
93 extern PFNGLDELETERENDERBUFFERSOESPROC glDeleteRenderbuffersOES;
94 extern PFNGLGENRENDERBUFFERSOESPROC glGenRenderbuffersOES;
95 extern PFNGLRENDERBUFFERSTORAGEOESPROC glRenderbufferStorageOES;
96 extern PFNGLGETRENDERBUFFERPARAMETERIVOESPROC glGetRenderbufferParameterivOES;
97 extern PFNGLISFRAMEBUFFEROESPROC glIsFramebufferOES;
98 extern PFNGLBINDFRAMEBUFFEROESPROC glBindFramebufferOES;
99 extern PFNGLDELETEFRAMEBUFFERSOESPROC glDeleteFramebuffersOES;
100 extern PFNGLGENFRAMEBUFFERSOESPROC glGenFramebuffersOES;
101 extern PFNGLCHECKFRAMEBUFFERSTATUSOESPROC glCheckFramebufferStatusOES;
102 extern PFNGLFRAMEBUFFERRENDERBUFFEROESPROC glFramebufferRenderbufferOES;
103 extern PFNGLFRAMEBUFFERTEXTURE2DOESPROC glFramebufferTexture2DOES;
104 extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC glGetFramebufferAttachmentParameterivOES;
105 extern PFNGLGENERATEMIPMAPOESPROC glGenerateMipmapOES;
106 extern PFNGLBLENDEQUATIONOESPROC glBlendEquationOES;
107 extern PFNGLBLENDFUNCSEPARATEOESPROC glBlendFuncSeparateOES;
108 extern PFNGLBLENDEQUATIONSEPARATEOESPROC glBlendEquationSeparateOES;
109 extern PFNGLMAPBUFFEROESPROC glMapBufferOES;
110 extern PFNGLUNMAPBUFFEROESPROC glUnmapBufferOES;
111 # endif
112 
113 #endif
114 
115 // Define GL_NONE for convenience
116 #define GL_NONE 0
117 
118 #ifndef GL_BGRA
119 # define GL_BGRA 0x80E1
120 #endif
121 
122 // Used for polygon modes
123 #ifndef GL_FILL
124 # define GL_FILL 0x1B02
125 #endif
126 
127 namespace Ogre {
128  class GLESTexture;
130 };
131 
132 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(__MINGW32__) && !defined(OGRE_STATIC_LIB)
133 # ifdef OGRE_GLESPLUGIN_EXPORTS
134 # define _OgreGLESExport __declspec(dllexport)
135 # else
136 # if defined( __MINGW32__ )
137 # define _OgreGLESExport
138 # else
139 # define _OgreGLESExport __declspec(dllimport)
140 # endif
141 # endif
142 #elif defined ( OGRE_GCC_VISIBILITY )
143 # define _OgreGLESExport __attribute__ ((visibility("default")))
144 #else
145 # define _OgreGLESExport
146 #endif
147 
148 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
149 #define __PRETTY_FUNCTION__ __FUNCTION__
150 #endif
151 
152 
153 #define DEBUG_(text) \
154  {\
155  fprintf(stderr, "%s:%d: %s\n", __FUNCTION__, __LINE__, text); \
156  }
157 
158 #define ENABLE_GL_CHECK 0
159 
160 #if ENABLE_GL_CHECK
161 #define GL_CHECK_ERROR \
162  { \
163  int e = glGetError(); \
164  if (e != 0) \
165  { \
166  const char * errorString = ""; \
167  switch(e) \
168  { \
169  case GL_INVALID_ENUM: errorString = "GL_INVALID_ENUM"; break; \
170  case GL_INVALID_VALUE: errorString = "GL_INVALID_VALUE"; break; \
171  case GL_INVALID_OPERATION: errorString = "GL_INVALID_OPERATION"; break; \
172  case GL_OUT_OF_MEMORY: errorString = "GL_OUT_OF_MEMORY"; break; \
173  default: break; \
174  } \
175  char msgBuf[1024]; \
176  sprintf(msgBuf, "OpenGL ES error 0x%04X %s in %s at line %i in %s \n", e, errorString, __PRETTY_FUNCTION__, __LINE__, __FILE__); \
177  LogManager::getSingleton().logMessage(msgBuf); \
178  } \
179  }
180 #else
181  #define GL_CHECK_ERROR {}
182 #endif
183 
184 #define ENABLE_EGL_CHECK 1
185 
186 #if ENABLE_EGL_CHECK
187  #define EGL_CHECK_ERROR \
188  { \
189  int e = eglGetError(); \
190  if ((e != 0) && (e != EGL_SUCCESS))\
191  { \
192  char msgBuf[1024]; \
193  sprintf(msgBuf, "EGL error 0x%04X in %s at line %i in %s \n", e, __PRETTY_FUNCTION__, __LINE__, __FILE__);\
194  LogManager::getSingleton().logMessage(msgBuf);\
195  } \
196  }
197 #else
198  #define EGL_CHECK_ERROR {}
199 #endif
200 
201 #endif
SharedPtr< GLESTexture > GLESTexturePtr
#define glUnmapBufferOES
Reference-counted shared pointer, used for objects where implicit destruction is required.