• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!****************************************************************************
2 
3  @file         OGLES2/PVRTgles2Ext.h
4  @ingroup      API_OGLES2
5  @copyright    Copyright (c) Imagination Technologies Limited.
6  @brief        OpenGL ES 2.0 extensions
7 
8 ******************************************************************************/
9 
10 #ifndef _PVRTGLES2EXT_H_
11 #define _PVRTGLES2EXT_H_
12 
13 
14 /*!
15  @addtogroup   API_OGLES2
16  @{
17 */
18 
19 #ifdef __APPLE__
20 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE==1
21 #import <OpenGLES/ES2/gl.h>
22 #import <OpenGLES/ES2/glext.h>
23 // No binary shaders are allowed on the iphone and so this value is not defined
24 // Defining here allows for a more graceful fail of binary shader loading at runtime
25 // which can be recovered from instead of fail at compile time
26 #define GL_SGX_BINARY_IMG 0
27 #else
28 #include <EGL/egl.h>
29 #include <GLES2/gl2.h>
30 #include <GLES2/gl2ext.h>
31 #include <GLES2/gl2extimg.h>
32 #endif
33 #else
34 #if !defined(EGL_NOT_PRESENT)
35 #include <EGL/egl.h>
36 #endif
37 #include <GLES2/gl2.h>
38 #include <GLES2/gl2ext.h>
39 #include <GLES2/gl2extimg.h>
40 #endif
41 
42 #if defined(TARGET_OS_IPHONE)
43 // the extensions supported on the iPhone are treated as core functions of gl
44 // so use this macro to assign the function pointers in this class appropriately.
45 #define PVRGetProcAddress(x) ::x
46 #else
47 
48 #if defined(EGL_NOT_PRESENT)
49 
50 #if defined(__PALMPDK__)
51 #include "SDL.h"
52 
53 #define PVRGetProcAddress(x) SDL_GLES_GetProcAddress(#x)
54 #else
55 #define PVRGetProcAddress(x) NULL
56 #endif
57 
58 #else
59 #define PVRGetProcAddress(x) eglGetProcAddress(#x)
60 #endif
61 
62 #endif
63 
64 /****************************************************************************
65 ** Build options
66 ****************************************************************************/
67 
68 #define GL_PVRTGLESEXT_VERSION 2
69 
70 /**************************************************************************
71 ****************************** GL EXTENSIONS ******************************
72 **************************************************************************/
73 
74 /*!************************************************************************
75  @class CPVRTgles2Ext
76  @brief A class for initialising and managing OGLES2 extensions
77 **************************************************************************/
78 class CPVRTgles2Ext
79 {
80 
81 public:
82     // Type definitions for pointers to functions returned by eglGetProcAddress
83     typedef void (GL_APIENTRY *PFNGLMULTIDRAWELEMENTS) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); // glvoid
84     typedef void* (GL_APIENTRY *PFNGLMAPBUFFEROES)(GLenum target, GLenum access);
85     typedef GLboolean (GL_APIENTRY *PFNGLUNMAPBUFFEROES)(GLenum target);
86     typedef void (GL_APIENTRY *PFNGLGETBUFFERPOINTERVOES)(GLenum target, GLenum pname, void** params);
87 	typedef void (GL_APIENTRY * PFNGLMULTIDRAWARRAYS) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); // glvoid
88 	typedef void (GL_APIENTRY * PFNGLDISCARDFRAMEBUFFEREXT)(GLenum target, GLsizei numAttachments, const GLenum *attachments);
89 
90 	typedef void (GL_APIENTRY *PFNGLGENQUERIESEXT) (GLsizei n, GLuint *ids);
91 	typedef void (GL_APIENTRY *PFNGLDELETEQUERIESEXT) (GLsizei n, const GLuint *ids);
92 	typedef GLboolean (GL_APIENTRY *PFNGLISQUERYEXT) (GLuint id);
93 	typedef void (GL_APIENTRY *PFNGLBEGINQUERYEXT) (GLenum target, GLuint id);
94 	typedef void (GL_APIENTRY *PFNGLENDQUERYEXT) (GLenum target);
95 	typedef void (GL_APIENTRY *PFNGLGETQUERYIVEXT) (GLenum target, GLenum pname, GLint *params);
96 	typedef void (GL_APIENTRY *PFNGLGETQUERYOBJECTUIVEXT) (GLuint id, GLenum pname, GLuint *params);
97 
98 	typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOES) (GLuint vertexarray);
99 	typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOES) (GLsizei n, const GLuint *vertexarrays);
100 	typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOES) (GLsizei n, GLuint *vertexarrays);
101 	typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOES) (GLuint vertexarray);
102 
103 	typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
104 	typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
105 
106 	typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
107 
108 	typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
109 
110 	typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOES) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
111 	typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
112 	typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
113 	typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOES) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
114 	typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
115 	typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
116 
117 	typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXT) (GLsizei n, const GLenum *bufs);
118 
119 	// GL_EXT_multi_draw_arrays
120 	PFNGLMULTIDRAWELEMENTS				glMultiDrawElementsEXT;
121 	PFNGLMULTIDRAWARRAYS				glMultiDrawArraysEXT;
122 
123 	// GL_EXT_multi_draw_arrays
124     PFNGLMAPBUFFEROES                   glMapBufferOES;
125     PFNGLUNMAPBUFFEROES                 glUnmapBufferOES;
126     PFNGLGETBUFFERPOINTERVOES           glGetBufferPointervOES;
127 
128 	// GL_EXT_discard_framebuffer
129 	PFNGLDISCARDFRAMEBUFFEREXT			glDiscardFramebufferEXT;
130 
131 	// GL_EXT_occlusion_query_boolean
132 #if !defined(GL_EXT_occlusion_query_boolean)
133 	#define GL_ANY_SAMPLES_PASSED_EXT                               0x8C2F
134 	#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT                  0x8D6A
135 	#define GL_CURRENT_QUERY_EXT                                    0x8865
136 	#define GL_QUERY_RESULT_EXT                                     0x8866
137 	#define GL_QUERY_RESULT_AVAILABLE_EXT                           0x886
138 #endif
139 	PFNGLGENQUERIESEXT                  glGenQueriesEXT;
140 	PFNGLDELETEQUERIESEXT               glDeleteQueriesEXT;
141 	PFNGLISQUERYEXT                     glIsQueryEXT;
142 	PFNGLBEGINQUERYEXT                  glBeginQueryEXT;
143 	PFNGLENDQUERYEXT                    glEndQueryEXT;
144 	PFNGLGETQUERYIVEXT                  glGetQueryivEXT;
145 	PFNGLGETQUERYOBJECTUIVEXT           glGetQueryObjectuivEXT;
146 
147 	// GL_OES_vertex_array_object
148 #if !defined(GL_OES_vertex_array_object)
149 	#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
150 #endif
151 
152 	PFNGLBINDVERTEXARRAYOES glBindVertexArrayOES;
153 	PFNGLDELETEVERTEXARRAYSOES glDeleteVertexArraysOES;
154 	PFNGLGENVERTEXARRAYSOES glGenVertexArraysOES;
155 	PFNGLISVERTEXARRAYOES glIsVertexArrayOES;
156 
157 	// GL_IMG_multisampled_render_to_texture
158 #if !defined(GL_IMG_multisampled_render_to_texture)
159 	#define GL_RENDERBUFFER_SAMPLES_IMG                 0x9133
160 	#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG   0x9134
161 	#define GL_MAX_SAMPLES_IMG                          0x9135
162 	#define GL_TEXTURE_SAMPLES_IMG                      0x9136
163 #endif
164 
165 	PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG glRenderbufferStorageMultisampleIMG;
166 	PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG glFramebufferTexture2DMultisampleIMG;
167 
168 	// GL_EXT_multisampled_render_to_texture
169 #if !defined(GL_ANGLE_framebuffer_multisample)
170 	#define GL_RENDERBUFFER_SAMPLES_ANGLE               0x8CAB
171 	#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
172 	#define GL_MAX_SAMPLES_ANGLE                        0x8D57
173 #endif
174 
175 	PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC glRenderbufferStorageMultisampleANGLE;
176 
177 	// GL_NV_framebuffer_blit
178 #if !defined(GL_NV_framebuffer_blit)
179 	#define GL_READ_FRAMEBUFFER_NV            0x8CA8
180 	#define GL_DRAW_FRAMEBUFFER_NV            0x8CA9
181 	#define GL_DRAW_FRAMEBUFFER_BINDING_NV    0x8CA6
182 	#define GL_READ_FRAMEBUFFER_BINDING_NV    0x8CAA
183 #endif
184 
185 	PFNGLBLITFRAMEBUFFERNVPROC glBlitFramebufferNV;
186 
187 	// GL_OES_texture_3D
188 #if !defined(GL_OES_texture_3D)
189 	#define GL_TEXTURE_WRAP_R_OES                                   0x8072
190 	#define GL_TEXTURE_3D_OES                                       0x806F
191 	#define GL_TEXTURE_BINDING_3D_OES                               0x806A
192 	#define GL_MAX_3D_TEXTURE_SIZE_OES                              0x8073
193 	#define GL_SAMPLER_3D_OES                                       0x8B5F
194 	#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES        0x8CD4
195 #endif
196 
197 	PFNGLTEXIMAGE3DOES glTexImage3DOES;
198 	PFNGLTEXSUBIMAGE3DOES glTexSubImage3DOES;
199 	PFNGLCOPYTEXSUBIMAGE3DOES glCopyTexSubImage3DOES;
200 	PFNGLCOMPRESSEDTEXIMAGE3DOES glCompressedTexImage3DOES;
201 	PFNGLCOMPRESSEDTEXSUBIMAGE3DOES glCompressedTexSubImage3DOES;
202 	PFNGLFRAMEBUFFERTEXTURE3DOES glFramebufferTexture3DOES;
203 
204 	// GL_EXT_draw_buffers
205 #if !defined(GL_EXT_draw_buffers)
206 	#define GL_MAX_COLOR_ATTACHMENTS_EXT                            0x8CDF
207 	#define GL_MAX_DRAW_BUFFERS_EXT                                 0x8824
208 	#define GL_DRAW_BUFFER0_EXT                                     0x8825
209 	#define GL_DRAW_BUFFER1_EXT                                     0x8826
210 	#define GL_DRAW_BUFFER2_EXT                                     0x8827
211 	#define GL_DRAW_BUFFER3_EXT                                     0x8828
212 	#define GL_DRAW_BUFFER4_EXT                                     0x8829
213 	#define GL_DRAW_BUFFER5_EXT                                     0x882A
214 	#define GL_DRAW_BUFFER6_EXT                                     0x882B
215 	#define GL_DRAW_BUFFER7_EXT                                     0x882C
216 	#define GL_DRAW_BUFFER8_EXT                                     0x882D
217 	#define GL_DRAW_BUFFER9_EXT                                     0x882E
218 	#define GL_DRAW_BUFFER10_EXT                                    0x882F
219 	#define GL_DRAW_BUFFER11_EXT                                    0x8830
220 	#define GL_DRAW_BUFFER12_EXT                                    0x8831
221 	#define GL_DRAW_BUFFER13_EXT                                    0x8832
222 	#define GL_DRAW_BUFFER14_EXT                                    0x8833
223 	#define GL_DRAW_BUFFER15_EXT                                    0x8834
224 	#define GL_COLOR_ATTACHMENT0_EXT                                0x8CE0
225 	#define GL_COLOR_ATTACHMENT1_EXT                                0x8CE1
226 	#define GL_COLOR_ATTACHMENT2_EXT                                0x8CE2
227 	#define GL_COLOR_ATTACHMENT3_EXT                                0x8CE3
228 	#define GL_COLOR_ATTACHMENT4_EXT                                0x8CE4
229 	#define GL_COLOR_ATTACHMENT5_EXT                                0x8CE5
230 	#define GL_COLOR_ATTACHMENT6_EXT                                0x8CE6
231 	#define GL_COLOR_ATTACHMENT7_EXT                                0x8CE7
232 	#define GL_COLOR_ATTACHMENT8_EXT                                0x8CE8
233 	#define GL_COLOR_ATTACHMENT9_EXT                                0x8CE9
234 	#define GL_COLOR_ATTACHMENT10_EXT                               0x8CEA
235 	#define GL_COLOR_ATTACHMENT11_EXT                               0x8CEB
236 	#define GL_COLOR_ATTACHMENT12_EXT                               0x8CEC
237 	#define GL_COLOR_ATTACHMENT13_EXT                               0x8CED
238 	#define GL_COLOR_ATTACHMENT14_EXT                               0x8CEE
239 	#define GL_COLOR_ATTACHMENT15_EXT                               0x8CEF
240 #endif
241 
242 	PFNGLDRAWBUFFERSEXT                 glDrawBuffersEXT;
243 
244 public:
245 	/*!***********************************************************************
246 	@brief      		Initialises IMG extensions
247 	*************************************************************************/
248 	void LoadExtensions();
249 
250 	/*!***********************************************************************
251 	@brief		    Queries for support of an extension
252 	@param[in]		extension extension to query for
253 	@return			True if the extension is supported
254 	*************************************************************************/
255 	static bool IsGLExtensionSupported(const char * const extension);
256 };
257 
258 /*! @} */
259 
260 #endif /* _PVRTGLES2EXT_H_ */
261 
262 /*****************************************************************************
263  End of file (PVRTgles2Ext.h)
264 *****************************************************************************/
265 
266