1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the demonstration applications of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef GLEXTENSIONS_H
|
---|
43 | #define GLEXTENSIONS_H
|
---|
44 |
|
---|
45 | #include <QtOpenGL>
|
---|
46 |
|
---|
47 | /*
|
---|
48 | Functions resolved:
|
---|
49 |
|
---|
50 | glCreateShaderObjectARB
|
---|
51 | glShaderSourceARB
|
---|
52 | glCompileShaderARB
|
---|
53 | glGetObjectParameterivARB
|
---|
54 | glDeleteObjectARB
|
---|
55 | glGetInfoLogARB
|
---|
56 | glCreateProgramObjectARB
|
---|
57 | glAttachObjectARB
|
---|
58 | glDetachObjectARB
|
---|
59 | glLinkProgramARB
|
---|
60 | glUseProgramObjectARB
|
---|
61 | glGetUniformLocationARB
|
---|
62 | glUniform1iARB
|
---|
63 | glUniform1fARB
|
---|
64 | glUniform4fARB
|
---|
65 | glUniformMatrix4fvARB
|
---|
66 |
|
---|
67 | glGenFramebuffersEXT
|
---|
68 | glGenRenderbuffersEXT
|
---|
69 | glBindRenderbufferEXT
|
---|
70 | glRenderbufferStorageEXT
|
---|
71 | glDeleteFramebuffersEXT
|
---|
72 | glDeleteRenderbuffersEXT
|
---|
73 | glBindFramebufferEXT
|
---|
74 | glFramebufferTexture2DEXT
|
---|
75 | glFramebufferRenderbufferEXT
|
---|
76 | glCheckFramebufferStatusEXT
|
---|
77 |
|
---|
78 | glActiveTexture
|
---|
79 | glTexImage3D
|
---|
80 |
|
---|
81 | glGenBuffers
|
---|
82 | glBindBuffer
|
---|
83 | glBufferData
|
---|
84 | glDeleteBuffers
|
---|
85 | glMapBuffer
|
---|
86 | glUnmapBuffer
|
---|
87 | */
|
---|
88 |
|
---|
89 | #ifndef Q_WS_MAC
|
---|
90 | # ifndef APIENTRYP
|
---|
91 | # ifdef APIENTRY
|
---|
92 | # define APIENTRYP APIENTRY *
|
---|
93 | # else
|
---|
94 | # define APIENTRY
|
---|
95 | # define APIENTRYP *
|
---|
96 | # endif
|
---|
97 | # endif
|
---|
98 | #else
|
---|
99 | # define APIENTRY
|
---|
100 | # define APIENTRYP *
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | #ifndef GL_VERSION_1_2
|
---|
104 | #define GL_TEXTURE_3D 0x806F
|
---|
105 | #define GL_TEXTURE_WRAP_R 0x8072
|
---|
106 | #define GL_CLAMP_TO_EDGE 0x812F
|
---|
107 | #define GL_BGRA 0x80E1
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | #ifndef GL_VERSION_1_3
|
---|
111 | #define GL_TEXTURE0 0x84C0
|
---|
112 | #define GL_TEXTURE1 0x84C1
|
---|
113 | #define GL_TEXTURE2 0x84C2
|
---|
114 | #define GL_TEXTURE_CUBE_MAP 0x8513
|
---|
115 | #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
|
---|
116 | //#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
|
---|
117 | //#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
|
---|
118 | //#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
|
---|
119 | //#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
|
---|
120 | //#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
|
---|
121 | #endif
|
---|
122 |
|
---|
123 | #ifndef GL_VERSION_1_5
|
---|
124 | typedef ptrdiff_t GLsizeiptr;
|
---|
125 | #define GL_ARRAY_BUFFER 0x8892
|
---|
126 | #define GL_ELEMENT_ARRAY_BUFFER 0x8893
|
---|
127 | #define GL_READ_WRITE 0x88BA
|
---|
128 | #define GL_STATIC_DRAW 0x88E4
|
---|
129 | #endif
|
---|
130 |
|
---|
131 | #ifndef GL_EXT_framebuffer_object
|
---|
132 | #define GL_RENDERBUFFER_EXT 0x8D41
|
---|
133 | #define GL_FRAMEBUFFER_EXT 0x8D40
|
---|
134 | #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
|
---|
135 | #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
|
---|
136 | #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | #ifndef GL_ARB_vertex_shader
|
---|
140 | #define GL_VERTEX_SHADER_ARB 0x8B31
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | #ifndef GL_ARB_fragment_shader
|
---|
144 | #define GL_FRAGMENT_SHADER_ARB 0x8B30
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | #ifndef GL_ARB_shader_objects
|
---|
148 | typedef char GLcharARB;
|
---|
149 | typedef unsigned int GLhandleARB;
|
---|
150 | #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
|
---|
151 | #define GL_OBJECT_LINK_STATUS_ARB 0x8B82
|
---|
152 | #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | typedef GLhandleARB (APIENTRY *_glCreateShaderObjectARB) (GLenum);
|
---|
156 | typedef void (APIENTRY *_glShaderSourceARB) (GLhandleARB, GLuint, const GLcharARB**, GLint *);
|
---|
157 | typedef void (APIENTRY *_glCompileShaderARB) (GLhandleARB);
|
---|
158 | typedef void (APIENTRY *_glGetObjectParameterivARB) (GLhandleARB, GLenum, int *);
|
---|
159 | typedef void (APIENTRY *_glDeleteObjectARB) (GLhandleARB);
|
---|
160 | typedef void (APIENTRY *_glGetInfoLogARB) (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
|
---|
161 | typedef GLhandleARB (APIENTRY *_glCreateProgramObjectARB) ();
|
---|
162 | typedef void (APIENTRY *_glAttachObjectARB) (GLhandleARB, GLhandleARB);
|
---|
163 | typedef void (APIENTRY *_glDetachObjectARB) (GLhandleARB, GLhandleARB);
|
---|
164 | typedef void (APIENTRY *_glLinkProgramARB) (GLhandleARB);
|
---|
165 | typedef void (APIENTRY *_glUseProgramObjectARB) (GLhandleARB);
|
---|
166 | typedef GLint (APIENTRY *_glGetUniformLocationARB) (GLhandleARB, const GLcharARB *);
|
---|
167 | typedef void (APIENTRY *_glUniform1iARB) (GLint, GLint);
|
---|
168 | typedef void (APIENTRY *_glUniform1fARB) (GLint, GLfloat);
|
---|
169 | typedef void (APIENTRY *_glUniform4fARB) (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
|
---|
170 | typedef void (APIENTRY *_glUniformMatrix4fvARB) (GLint, GLuint, GLboolean, const GLfloat *);
|
---|
171 |
|
---|
172 | typedef void (APIENTRY *_glGenFramebuffersEXT) (GLsizei, GLuint *);
|
---|
173 | typedef void (APIENTRY *_glGenRenderbuffersEXT) (GLsizei, GLuint *);
|
---|
174 | typedef void (APIENTRY *_glBindRenderbufferEXT) (GLenum, GLuint);
|
---|
175 | typedef void (APIENTRY *_glRenderbufferStorageEXT) (GLenum, GLenum, GLsizei, GLsizei);
|
---|
176 | typedef void (APIENTRY *_glDeleteFramebuffersEXT) (GLsizei, const GLuint*);
|
---|
177 | typedef void (APIENTRY *_glDeleteRenderbuffersEXT) (GLsizei, const GLuint*);
|
---|
178 | typedef void (APIENTRY *_glBindFramebufferEXT) (GLenum, GLuint);
|
---|
179 | typedef void (APIENTRY *_glFramebufferTexture2DEXT) (GLenum, GLenum, GLenum, GLuint, GLint);
|
---|
180 | typedef void (APIENTRY *_glFramebufferRenderbufferEXT) (GLenum, GLenum, GLenum, GLuint);
|
---|
181 | typedef GLenum (APIENTRY *_glCheckFramebufferStatusEXT) (GLenum);
|
---|
182 |
|
---|
183 | typedef void (APIENTRY *_glActiveTexture) (GLenum);
|
---|
184 | typedef void (APIENTRY *_glTexImage3D) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
|
---|
185 |
|
---|
186 | typedef void (APIENTRY *_glGenBuffers) (GLsizei, GLuint *);
|
---|
187 | typedef void (APIENTRY *_glBindBuffer) (GLenum, GLuint);
|
---|
188 | typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptr, const GLvoid *, GLenum);
|
---|
189 | typedef void (APIENTRY *_glDeleteBuffers) (GLsizei, const GLuint *);
|
---|
190 | typedef void *(APIENTRY *_glMapBuffer) (GLenum, GLenum);
|
---|
191 | typedef GLboolean (APIENTRY *_glUnmapBuffer) (GLenum);
|
---|
192 |
|
---|
193 | struct GLExtensionFunctions
|
---|
194 | {
|
---|
195 | bool resolve(const QGLContext *context);
|
---|
196 |
|
---|
197 | bool glslSupported();
|
---|
198 | bool fboSupported();
|
---|
199 | bool openGL15Supported(); // the rest: multi-texture, 3D-texture, vertex buffer objects
|
---|
200 |
|
---|
201 | _glCreateShaderObjectARB CreateShaderObjectARB;
|
---|
202 | _glShaderSourceARB ShaderSourceARB;
|
---|
203 | _glCompileShaderARB CompileShaderARB;
|
---|
204 | _glGetObjectParameterivARB GetObjectParameterivARB;
|
---|
205 | _glDeleteObjectARB DeleteObjectARB;
|
---|
206 | _glGetInfoLogARB GetInfoLogARB;
|
---|
207 | _glCreateProgramObjectARB CreateProgramObjectARB;
|
---|
208 | _glAttachObjectARB AttachObjectARB;
|
---|
209 | _glDetachObjectARB DetachObjectARB;
|
---|
210 | _glLinkProgramARB LinkProgramARB;
|
---|
211 | _glUseProgramObjectARB UseProgramObjectARB;
|
---|
212 | _glGetUniformLocationARB GetUniformLocationARB;
|
---|
213 | _glUniform1iARB Uniform1iARB;
|
---|
214 | _glUniform1fARB Uniform1fARB;
|
---|
215 | _glUniform4fARB Uniform4fARB;
|
---|
216 | _glUniformMatrix4fvARB UniformMatrix4fvARB;
|
---|
217 |
|
---|
218 | _glGenFramebuffersEXT GenFramebuffersEXT;
|
---|
219 | _glGenRenderbuffersEXT GenRenderbuffersEXT;
|
---|
220 | _glBindRenderbufferEXT BindRenderbufferEXT;
|
---|
221 | _glRenderbufferStorageEXT RenderbufferStorageEXT;
|
---|
222 | _glDeleteFramebuffersEXT DeleteFramebuffersEXT;
|
---|
223 | _glDeleteRenderbuffersEXT DeleteRenderbuffersEXT;
|
---|
224 | _glBindFramebufferEXT BindFramebufferEXT;
|
---|
225 | _glFramebufferTexture2DEXT FramebufferTexture2DEXT;
|
---|
226 | _glFramebufferRenderbufferEXT FramebufferRenderbufferEXT;
|
---|
227 | _glCheckFramebufferStatusEXT CheckFramebufferStatusEXT;
|
---|
228 |
|
---|
229 | _glActiveTexture ActiveTexture;
|
---|
230 | _glTexImage3D TexImage3D;
|
---|
231 |
|
---|
232 | _glGenBuffers GenBuffers;
|
---|
233 | _glBindBuffer BindBuffer;
|
---|
234 | _glBufferData BufferData;
|
---|
235 | _glDeleteBuffers DeleteBuffers;
|
---|
236 | _glMapBuffer MapBuffer;
|
---|
237 | _glUnmapBuffer UnmapBuffer;
|
---|
238 | };
|
---|
239 |
|
---|
240 | inline GLExtensionFunctions &getGLExtensionFunctions()
|
---|
241 | {
|
---|
242 | static GLExtensionFunctions funcs;
|
---|
243 | return funcs;
|
---|
244 | }
|
---|
245 |
|
---|
246 | #define glCreateShaderObjectARB getGLExtensionFunctions().CreateShaderObjectARB
|
---|
247 | #define glShaderSourceARB getGLExtensionFunctions().ShaderSourceARB
|
---|
248 | #define glCompileShaderARB getGLExtensionFunctions().CompileShaderARB
|
---|
249 | #define glGetObjectParameterivARB getGLExtensionFunctions().GetObjectParameterivARB
|
---|
250 | #define glDeleteObjectARB getGLExtensionFunctions().DeleteObjectARB
|
---|
251 | #define glGetInfoLogARB getGLExtensionFunctions().GetInfoLogARB
|
---|
252 | #define glCreateProgramObjectARB getGLExtensionFunctions().CreateProgramObjectARB
|
---|
253 | #define glAttachObjectARB getGLExtensionFunctions().AttachObjectARB
|
---|
254 | #define glDetachObjectARB getGLExtensionFunctions().DetachObjectARB
|
---|
255 | #define glLinkProgramARB getGLExtensionFunctions().LinkProgramARB
|
---|
256 | #define glUseProgramObjectARB getGLExtensionFunctions().UseProgramObjectARB
|
---|
257 | #define glGetUniformLocationARB getGLExtensionFunctions().GetUniformLocationARB
|
---|
258 | #define glUniform1iARB getGLExtensionFunctions().Uniform1iARB
|
---|
259 | #define glUniform1fARB getGLExtensionFunctions().Uniform1fARB
|
---|
260 | #define glUniform4fARB getGLExtensionFunctions().Uniform4fARB
|
---|
261 | #define glUniformMatrix4fvARB getGLExtensionFunctions().UniformMatrix4fvARB
|
---|
262 |
|
---|
263 | #define glGenFramebuffersEXT getGLExtensionFunctions().GenFramebuffersEXT
|
---|
264 | #define glGenRenderbuffersEXT getGLExtensionFunctions().GenRenderbuffersEXT
|
---|
265 | #define glBindRenderbufferEXT getGLExtensionFunctions().BindRenderbufferEXT
|
---|
266 | #define glRenderbufferStorageEXT getGLExtensionFunctions().RenderbufferStorageEXT
|
---|
267 | #define glDeleteFramebuffersEXT getGLExtensionFunctions().DeleteFramebuffersEXT
|
---|
268 | #define glDeleteRenderbuffersEXT getGLExtensionFunctions().DeleteRenderbuffersEXT
|
---|
269 | #define glBindFramebufferEXT getGLExtensionFunctions().BindFramebufferEXT
|
---|
270 | #define glFramebufferTexture2DEXT getGLExtensionFunctions().FramebufferTexture2DEXT
|
---|
271 | #define glFramebufferRenderbufferEXT getGLExtensionFunctions().FramebufferRenderbufferEXT
|
---|
272 | #define glCheckFramebufferStatusEXT getGLExtensionFunctions().CheckFramebufferStatusEXT
|
---|
273 |
|
---|
274 | #define glActiveTexture getGLExtensionFunctions().ActiveTexture
|
---|
275 | #define glTexImage3D getGLExtensionFunctions().TexImage3D
|
---|
276 |
|
---|
277 | #define glGenBuffers getGLExtensionFunctions().GenBuffers
|
---|
278 | #define glBindBuffer getGLExtensionFunctions().BindBuffer
|
---|
279 | #define glBufferData getGLExtensionFunctions().BufferData
|
---|
280 | #define glDeleteBuffers getGLExtensionFunctions().DeleteBuffers
|
---|
281 | #define glMapBuffer getGLExtensionFunctions().MapBuffer
|
---|
282 | #define glUnmapBuffer getGLExtensionFunctions().UnmapBuffer
|
---|
283 |
|
---|
284 | #endif
|
---|