diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8.1/source/Irrlicht/COpenGLExtensionHandler.cpp | 804 |
1 files changed, 804 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/source/Irrlicht/COpenGLExtensionHandler.cpp b/libraries/irrlicht-1.8.1/source/Irrlicht/COpenGLExtensionHandler.cpp new file mode 100644 index 0000000..ae64ffd --- /dev/null +++ b/libraries/irrlicht-1.8.1/source/Irrlicht/COpenGLExtensionHandler.cpp | |||
@@ -0,0 +1,804 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #include "IrrCompileConfig.h" | ||
6 | |||
7 | #ifdef _IRR_COMPILE_WITH_OPENGL_ | ||
8 | |||
9 | #include "COpenGLExtensionHandler.h" | ||
10 | #include "irrString.h" | ||
11 | #include "SMaterial.h" // for MATERIAL_MAX_TEXTURES | ||
12 | #include "fast_atof.h" | ||
13 | |||
14 | namespace irr | ||
15 | { | ||
16 | namespace video | ||
17 | { | ||
18 | |||
19 | COpenGLExtensionHandler::COpenGLExtensionHandler() : | ||
20 | StencilBuffer(false), MultiTextureExtension(false), | ||
21 | TextureCompressionExtension(false), | ||
22 | MaxSupportedTextures(1), MaxTextureUnits(1), MaxLights(1), | ||
23 | MaxAnisotropy(1), MaxUserClipPlanes(0), MaxAuxBuffers(0), | ||
24 | MaxMultipleRenderTargets(1), MaxIndices(65535), | ||
25 | MaxTextureSize(1), MaxGeometryVerticesOut(0), | ||
26 | MaxTextureLODBias(0.f), Version(0), ShaderLanguageVersion(0), | ||
27 | OcclusionQuerySupport(false) | ||
28 | #ifdef _IRR_OPENGL_USE_EXTPOINTER_ | ||
29 | ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), | ||
30 | pGlGenProgramsARB(0), pGlGenProgramsNV(0), | ||
31 | pGlBindProgramARB(0), pGlBindProgramNV(0), | ||
32 | pGlDeleteProgramsARB(0), pGlDeleteProgramsNV(0), | ||
33 | pGlProgramStringARB(0), pGlLoadProgramNV(0), | ||
34 | pGlProgramLocalParameter4fvARB(0), | ||
35 | pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), | ||
36 | pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), | ||
37 | pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), | ||
38 | pGlCreateProgram(0), pGlUseProgram(0), | ||
39 | pGlDeleteProgram(0), pGlDeleteShader(0), | ||
40 | pGlGetAttachedObjectsARB(0), pGlGetAttachedShaders(0), | ||
41 | pGlCreateShader(0), pGlShaderSource(0), pGlCompileShader(0), | ||
42 | pGlAttachShader(0), pGlLinkProgram(0), | ||
43 | pGlGetInfoLogARB(0), pGlGetShaderInfoLog(0), pGlGetProgramInfoLog(0), | ||
44 | pGlGetObjectParameterivARB(0), pGlGetShaderiv(0), pGlGetProgramiv(0), | ||
45 | pGlGetUniformLocationARB(0), pGlGetUniformLocation(0), | ||
46 | pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), | ||
47 | pGlUniform1ivARB(0), pGlUniform2ivARB(0), pGlUniform3ivARB(0), pGlUniform4ivARB(0), | ||
48 | pGlUniformMatrix2fvARB(0), pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), | ||
49 | pGlGetActiveUniformARB(0), pGlGetActiveUniform(0), | ||
50 | pGlPointParameterfARB(0), pGlPointParameterfvARB(0), | ||
51 | pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), | ||
52 | pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), | ||
53 | pGlCompressedTexImage2D(0), | ||
54 | // ARB framebuffer object | ||
55 | pGlBindFramebuffer(0), pGlDeleteFramebuffers(0), pGlGenFramebuffers(0), | ||
56 | pGlCheckFramebufferStatus(0), pGlFramebufferTexture2D(0), | ||
57 | pGlBindRenderbuffer(0), pGlDeleteRenderbuffers(0), pGlGenRenderbuffers(0), | ||
58 | pGlRenderbufferStorage(0), pGlFramebufferRenderbuffer(0), pGlGenerateMipmap(0), | ||
59 | // EXT framebuffer object | ||
60 | pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), | ||
61 | pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), | ||
62 | pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), | ||
63 | pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), pGlGenerateMipmapEXT(0), | ||
64 | // MRTs | ||
65 | pGlDrawBuffersARB(0), pGlDrawBuffersATI(0), | ||
66 | pGlGenBuffersARB(0), pGlBindBufferARB(0), pGlBufferDataARB(0), pGlDeleteBuffersARB(0), | ||
67 | pGlBufferSubDataARB(0), pGlGetBufferSubDataARB(0), pGlMapBufferARB(0), pGlUnmapBufferARB(0), | ||
68 | pGlIsBufferARB(0), pGlGetBufferParameterivARB(0), pGlGetBufferPointervARB(0), | ||
69 | pGlProvokingVertexARB(0), pGlProvokingVertexEXT(0), | ||
70 | pGlColorMaskIndexedEXT(0), pGlEnableIndexedEXT(0), pGlDisableIndexedEXT(0), | ||
71 | pGlBlendFuncIndexedAMD(0), pGlBlendFunciARB(0), | ||
72 | pGlBlendEquationIndexedAMD(0), pGlBlendEquationiARB(0), | ||
73 | pGlProgramParameteriARB(0), pGlProgramParameteriEXT(0), | ||
74 | pGlGenQueriesARB(0), pGlDeleteQueriesARB(0), pGlIsQueryARB(0), | ||
75 | pGlBeginQueryARB(0), pGlEndQueryARB(0), pGlGetQueryivARB(0), | ||
76 | pGlGetQueryObjectivARB(0), pGlGetQueryObjectuivARB(0), | ||
77 | pGlGenOcclusionQueriesNV(0), pGlDeleteOcclusionQueriesNV(0), | ||
78 | pGlIsOcclusionQueryNV(0), pGlBeginOcclusionQueryNV(0), | ||
79 | pGlEndOcclusionQueryNV(0), pGlGetOcclusionQueryivNV(0), | ||
80 | pGlGetOcclusionQueryuivNV(0), | ||
81 | pGlBlendEquationEXT(0), pGlBlendEquation(0) | ||
82 | #if defined(GLX_SGI_swap_control) | ||
83 | ,pGlxSwapIntervalSGI(0) | ||
84 | #endif | ||
85 | #if defined(GLX_EXT_swap_control) | ||
86 | ,pGlxSwapIntervalEXT(0) | ||
87 | #endif | ||
88 | #if defined(WGL_EXT_swap_control) | ||
89 | ,pWglSwapIntervalEXT(0) | ||
90 | #endif | ||
91 | #if defined(GLX_MESA_swap_control) | ||
92 | ,pGlxSwapIntervalMESA(0) | ||
93 | #endif | ||
94 | #endif // _IRR_OPENGL_USE_EXTPOINTER_ | ||
95 | { | ||
96 | for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i) | ||
97 | FeatureAvailable[i]=false; | ||
98 | DimAliasedLine[0]=1.f; | ||
99 | DimAliasedLine[1]=1.f; | ||
100 | DimAliasedPoint[0]=1.f; | ||
101 | DimAliasedPoint[1]=1.f; | ||
102 | DimSmoothedLine[0]=1.f; | ||
103 | DimSmoothedLine[1]=1.f; | ||
104 | DimSmoothedPoint[0]=1.f; | ||
105 | DimSmoothedPoint[1]=1.f; | ||
106 | } | ||
107 | |||
108 | |||
109 | void COpenGLExtensionHandler::dump() const | ||
110 | { | ||
111 | for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i) | ||
112 | os::Printer::log(OpenGLFeatureStrings[i], FeatureAvailable[i]?" true":" false"); | ||
113 | } | ||
114 | |||
115 | |||
116 | void COpenGLExtensionHandler::dumpFramebufferFormats() const | ||
117 | { | ||
118 | #ifdef _IRR_WINDOWS_API_ | ||
119 | HDC hdc=wglGetCurrentDC(); | ||
120 | core::stringc wglExtensions; | ||
121 | #ifdef WGL_ARB_extensions_string | ||
122 | PFNWGLGETEXTENSIONSSTRINGARBPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); | ||
123 | if (irrGetExtensionsString) | ||
124 | wglExtensions = irrGetExtensionsString(hdc); | ||
125 | #elif defined(WGL_EXT_extensions_string) | ||
126 | PFNWGLGETEXTENSIONSSTRINGEXTPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT"); | ||
127 | if (irrGetExtensionsString) | ||
128 | wglExtensions = irrGetExtensionsString(hdc); | ||
129 | #endif | ||
130 | const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1); | ||
131 | const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) || | ||
132 | (wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1) ); | ||
133 | #ifdef _DEBUG | ||
134 | os::Printer::log("WGL_extensions", wglExtensions); | ||
135 | #endif | ||
136 | |||
137 | #ifdef WGL_ARB_pixel_format | ||
138 | PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); | ||
139 | if (pixel_format_supported && wglChoosePixelFormat_ARB) | ||
140 | { | ||
141 | // This value determines the number of samples used for antialiasing | ||
142 | // My experience is that 8 does not show a big | ||
143 | // improvement over 4, but 4 shows a big improvement | ||
144 | // over 2. | ||
145 | |||
146 | PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribiv_ARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB"); | ||
147 | if (wglGetPixelFormatAttribiv_ARB) | ||
148 | { | ||
149 | int vals[128]; | ||
150 | int atts[] = { | ||
151 | WGL_NUMBER_PIXEL_FORMATS_ARB, | ||
152 | WGL_DRAW_TO_BITMAP_ARB, | ||
153 | WGL_ACCELERATION_ARB, | ||
154 | WGL_NEED_PALETTE_ARB, | ||
155 | WGL_NEED_SYSTEM_PALETTE_ARB, | ||
156 | WGL_SWAP_LAYER_BUFFERS_ARB, | ||
157 | WGL_SWAP_METHOD_ARB, | ||
158 | WGL_NUMBER_OVERLAYS_ARB, | ||
159 | WGL_NUMBER_UNDERLAYS_ARB, | ||
160 | WGL_TRANSPARENT_ARB, | ||
161 | WGL_TRANSPARENT_RED_VALUE_ARB, | ||
162 | WGL_TRANSPARENT_GREEN_VALUE_ARB, | ||
163 | WGL_TRANSPARENT_BLUE_VALUE_ARB, | ||
164 | WGL_TRANSPARENT_ALPHA_VALUE_ARB, | ||
165 | WGL_TRANSPARENT_INDEX_VALUE_ARB, | ||
166 | WGL_SHARE_DEPTH_ARB, | ||
167 | WGL_SHARE_STENCIL_ARB, | ||
168 | WGL_SHARE_ACCUM_ARB, | ||
169 | WGL_SUPPORT_GDI_ARB, | ||
170 | WGL_SUPPORT_OPENGL_ARB, | ||
171 | WGL_DOUBLE_BUFFER_ARB, | ||
172 | WGL_STEREO_ARB, | ||
173 | WGL_PIXEL_TYPE_ARB, | ||
174 | WGL_COLOR_BITS_ARB, | ||
175 | WGL_RED_BITS_ARB, | ||
176 | WGL_RED_SHIFT_ARB, | ||
177 | WGL_GREEN_BITS_ARB, | ||
178 | WGL_GREEN_SHIFT_ARB, | ||
179 | WGL_BLUE_BITS_ARB, | ||
180 | WGL_BLUE_SHIFT_ARB, | ||
181 | WGL_ALPHA_BITS_ARB, | ||
182 | WGL_ALPHA_SHIFT_ARB, | ||
183 | WGL_ACCUM_BITS_ARB, | ||
184 | WGL_ACCUM_RED_BITS_ARB, | ||
185 | WGL_ACCUM_GREEN_BITS_ARB, | ||
186 | WGL_ACCUM_BLUE_BITS_ARB, | ||
187 | WGL_ACCUM_ALPHA_BITS_ARB, | ||
188 | WGL_DEPTH_BITS_ARB, | ||
189 | WGL_STENCIL_BITS_ARB, | ||
190 | WGL_AUX_BUFFERS_ARB | ||
191 | #ifdef WGL_ARB_render_texture | ||
192 | ,WGL_BIND_TO_TEXTURE_RGB_ARB //40 | ||
193 | ,WGL_BIND_TO_TEXTURE_RGBA_ARB | ||
194 | #endif | ||
195 | #ifdef WGL_ARB_pbuffer | ||
196 | ,WGL_DRAW_TO_PBUFFER_ARB //42 | ||
197 | ,WGL_MAX_PBUFFER_PIXELS_ARB | ||
198 | ,WGL_MAX_PBUFFER_WIDTH_ARB | ||
199 | ,WGL_MAX_PBUFFER_HEIGHT_ARB | ||
200 | #endif | ||
201 | #ifdef WGL_ARB_framebuffer_sRGB | ||
202 | ,WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB //46 | ||
203 | #endif | ||
204 | #ifdef WGL_ARB_multisample | ||
205 | ,WGL_SAMPLES_ARB //47 | ||
206 | ,WGL_SAMPLE_BUFFERS_ARB | ||
207 | #endif | ||
208 | #ifdef WGL_EXT_depth_float | ||
209 | ,WGL_DEPTH_FLOAT_EXT //49 | ||
210 | #endif | ||
211 | ,0,0,0,0 | ||
212 | }; | ||
213 | size_t nums = sizeof(atts)/sizeof(int); | ||
214 | const bool depth_float_supported= (wglExtensions.find("WGL_EXT_depth_float") != -1); | ||
215 | if (!depth_float_supported) | ||
216 | { | ||
217 | memmove(&atts[49], &atts[50], (nums-50)*sizeof(int)); | ||
218 | nums -= 1; | ||
219 | } | ||
220 | if (!multi_sample_supported) | ||
221 | { | ||
222 | memmove(&atts[47], &atts[49], (nums-49)*sizeof(int)); | ||
223 | nums -= 2; | ||
224 | } | ||
225 | const bool framebuffer_sRGB_supported= (wglExtensions.find("WGL_ARB_framebuffer_sRGB") != -1); | ||
226 | if (!framebuffer_sRGB_supported) | ||
227 | { | ||
228 | memmove(&atts[46], &atts[47], (nums-47)*sizeof(int)); | ||
229 | nums -= 1; | ||
230 | } | ||
231 | const bool pbuffer_supported = (wglExtensions.find("WGL_ARB_pbuffer") != -1); | ||
232 | if (!pbuffer_supported) | ||
233 | { | ||
234 | memmove(&atts[42], &atts[46], (nums-46)*sizeof(int)); | ||
235 | nums -= 4; | ||
236 | } | ||
237 | const bool render_texture_supported = (wglExtensions.find("WGL_ARB_render_texture") != -1); | ||
238 | if (!render_texture_supported) | ||
239 | { | ||
240 | memmove(&atts[40], &atts[42], (nums-42)*sizeof(int)); | ||
241 | nums -= 2; | ||
242 | } | ||
243 | wglGetPixelFormatAttribiv_ARB(hdc,0,0,1,atts,vals); | ||
244 | const int count = vals[0]; | ||
245 | atts[0]=WGL_DRAW_TO_WINDOW_ARB; | ||
246 | for (int i=1; i<count; ++i) | ||
247 | { | ||
248 | memset(vals,0,sizeof(vals)); | ||
249 | #define tmplog(x,y) os::Printer::log(x, core::stringc(y).c_str()) | ||
250 | const BOOL res = wglGetPixelFormatAttribiv_ARB(hdc,i,0,nums,atts,vals); | ||
251 | if (FALSE==res) | ||
252 | continue; | ||
253 | tmplog("Pixel format ",i); | ||
254 | u32 j=0; | ||
255 | tmplog("Draw to window " , vals[j]); | ||
256 | tmplog("Draw to bitmap " , vals[++j]); | ||
257 | ++j; | ||
258 | tmplog("Acceleration " , (vals[j]==WGL_NO_ACCELERATION_ARB?"No": | ||
259 | vals[j]==WGL_GENERIC_ACCELERATION_ARB?"Generic":vals[j]==WGL_FULL_ACCELERATION_ARB?"Full":"ERROR")); | ||
260 | tmplog("Need palette " , vals[++j]); | ||
261 | tmplog("Need system palette " , vals[++j]); | ||
262 | tmplog("Swap layer buffers " , vals[++j]); | ||
263 | ++j; | ||
264 | tmplog("Swap method " , (vals[j]==WGL_SWAP_EXCHANGE_ARB?"Exchange": | ||
265 | vals[j]==WGL_SWAP_COPY_ARB?"Copy":vals[j]==WGL_SWAP_UNDEFINED_ARB?"Undefined":"ERROR")); | ||
266 | tmplog("Number of overlays " , vals[++j]); | ||
267 | tmplog("Number of underlays " , vals[++j]); | ||
268 | tmplog("Transparent " , vals[++j]); | ||
269 | tmplog("Transparent red value " , vals[++j]); | ||
270 | tmplog("Transparent green value " , vals[++j]); | ||
271 | tmplog("Transparent blue value " , vals[++j]); | ||
272 | tmplog("Transparent alpha value " , vals[++j]); | ||
273 | tmplog("Transparent index value " , vals[++j]); | ||
274 | tmplog("Share depth " , vals[++j]); | ||
275 | tmplog("Share stencil " , vals[++j]); | ||
276 | tmplog("Share accum " , vals[++j]); | ||
277 | tmplog("Support GDI " , vals[++j]); | ||
278 | tmplog("Support OpenGL " , vals[++j]); | ||
279 | tmplog("Double Buffer " , vals[++j]); | ||
280 | tmplog("Stereo Buffer " , vals[++j]); | ||
281 | tmplog("Pixel type " , vals[++j]); | ||
282 | tmplog("Color bits" , vals[++j]); | ||
283 | tmplog("Red bits " , vals[++j]); | ||
284 | tmplog("Red shift " , vals[++j]); | ||
285 | tmplog("Green bits " , vals[++j]); | ||
286 | tmplog("Green shift " , vals[++j]); | ||
287 | tmplog("Blue bits " , vals[++j]); | ||
288 | tmplog("Blue shift " , vals[++j]); | ||
289 | tmplog("Alpha bits " , vals[++j]); | ||
290 | tmplog("Alpha Shift " , vals[++j]); | ||
291 | tmplog("Accum bits " , vals[++j]); | ||
292 | tmplog("Accum red bits " , vals[++j]); | ||
293 | tmplog("Accum green bits " , vals[++j]); | ||
294 | tmplog("Accum blue bits " , vals[++j]); | ||
295 | tmplog("Accum alpha bits " , vals[++j]); | ||
296 | tmplog("Depth bits " , vals[++j]); | ||
297 | tmplog("Stencil bits " , vals[++j]); | ||
298 | tmplog("Aux buffers " , vals[++j]); | ||
299 | if (render_texture_supported) | ||
300 | { | ||
301 | tmplog("Bind to texture RGB" , vals[++j]); | ||
302 | tmplog("Bind to texture RGBA" , vals[++j]); | ||
303 | } | ||
304 | if (pbuffer_supported) | ||
305 | { | ||
306 | tmplog("Draw to pbuffer" , vals[++j]); | ||
307 | tmplog("Max pbuffer pixels " , vals[++j]); | ||
308 | tmplog("Max pbuffer width" , vals[++j]); | ||
309 | tmplog("Max pbuffer height" , vals[++j]); | ||
310 | } | ||
311 | if (framebuffer_sRGB_supported) | ||
312 | tmplog("Framebuffer sRBG capable" , vals[++j]); | ||
313 | if (multi_sample_supported) | ||
314 | { | ||
315 | tmplog("Samples " , vals[++j]); | ||
316 | tmplog("Sample buffers " , vals[++j]); | ||
317 | } | ||
318 | if (depth_float_supported) | ||
319 | tmplog("Depth float" , vals[++j]); | ||
320 | #undef tmplog | ||
321 | } | ||
322 | } | ||
323 | } | ||
324 | #endif | ||
325 | #elif defined(IRR_LINUX_DEVICE) | ||
326 | #endif | ||
327 | } | ||
328 | |||
329 | |||
330 | void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) | ||
331 | { | ||
332 | const f32 ogl_ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION))); | ||
333 | Version = static_cast<u16>(core::floor32(ogl_ver)*100+core::round32(core::fract(ogl_ver)*10.0f)); | ||
334 | if ( Version >= 102) | ||
335 | os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); | ||
336 | else | ||
337 | os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); | ||
338 | |||
339 | { | ||
340 | const char* t = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); | ||
341 | size_t len = 0; | ||
342 | c8 *str = 0; | ||
343 | if (t) | ||
344 | { | ||
345 | len = strlen(t); | ||
346 | str = new c8[len+1]; | ||
347 | } | ||
348 | c8* p = str; | ||
349 | |||
350 | for (size_t i=0; i<len; ++i) | ||
351 | { | ||
352 | str[i] = static_cast<char>(t[i]); | ||
353 | |||
354 | if (str[i] == ' ') | ||
355 | { | ||
356 | str[i] = 0; | ||
357 | for (u32 j=0; j<IRR_OpenGL_Feature_Count; ++j) | ||
358 | { | ||
359 | if (!strcmp(OpenGLFeatureStrings[j], p)) | ||
360 | { | ||
361 | FeatureAvailable[j] = true; | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | |||
366 | p = p + strlen(p) + 1; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | delete [] str; | ||
371 | } | ||
372 | |||
373 | MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture]; | ||
374 | TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression]; | ||
375 | StencilBuffer=stencilBuffer; | ||
376 | |||
377 | #ifdef _IRR_OPENGL_USE_EXTPOINTER_ | ||
378 | #ifdef _IRR_WINDOWS_API_ | ||
379 | #define IRR_OGL_LOAD_EXTENSION(x) wglGetProcAddress(reinterpret_cast<const char*>(x)) | ||
380 | #elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_) && !defined(_IRR_COMPILE_WITH_X11_DEVICE_) | ||
381 | #define IRR_OGL_LOAD_EXTENSION(x) SDL_GL_GetProcAddress(reinterpret_cast<const char*>(x)) | ||
382 | #else | ||
383 | // Accessing the correct function is quite complex | ||
384 | // All libraries should support the ARB version, however | ||
385 | // since GLX 1.4 the non-ARB version is the official one | ||
386 | // So we have to check the runtime environment and | ||
387 | // choose the proper symbol | ||
388 | // In case you still have problems please enable the | ||
389 | // next line by uncommenting it | ||
390 | // #define _IRR_GETPROCADDRESS_WORKAROUND_ | ||
391 | |||
392 | #ifndef _IRR_GETPROCADDRESS_WORKAROUND_ | ||
393 | __GLXextFuncPtr (*IRR_OGL_LOAD_EXTENSION_FUNCP)(const GLubyte*)=0; | ||
394 | #ifdef GLX_VERSION_1_4 | ||
395 | int major=0,minor=0; | ||
396 | if (glXGetCurrentDisplay()) | ||
397 | glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); | ||
398 | if ((major>1) || (minor>3)) | ||
399 | IRR_OGL_LOAD_EXTENSION_FUNCP=glXGetProcAddress; | ||
400 | else | ||
401 | #endif | ||
402 | IRR_OGL_LOAD_EXTENSION_FUNCP=glXGetProcAddressARB; | ||
403 | #define IRR_OGL_LOAD_EXTENSION(X) IRR_OGL_LOAD_EXTENSION_FUNCP(reinterpret_cast<const GLubyte*>(X)) | ||
404 | #else | ||
405 | #define IRR_OGL_LOAD_EXTENSION(X) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(X)) | ||
406 | #endif // workaround | ||
407 | #endif // Windows, SDL, or Linux | ||
408 | |||
409 | // get multitexturing function pointers | ||
410 | pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) IRR_OGL_LOAD_EXTENSION("glActiveTextureARB"); | ||
411 | pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) IRR_OGL_LOAD_EXTENSION("glClientActiveTextureARB"); | ||
412 | |||
413 | // get fragment and vertex program function pointers | ||
414 | pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) IRR_OGL_LOAD_EXTENSION("glGenProgramsARB"); | ||
415 | pGlGenProgramsNV = (PFNGLGENPROGRAMSNVPROC) IRR_OGL_LOAD_EXTENSION("glGenProgramsNV"); | ||
416 | pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) IRR_OGL_LOAD_EXTENSION("glBindProgramARB"); | ||
417 | pGlBindProgramNV = (PFNGLBINDPROGRAMNVPROC) IRR_OGL_LOAD_EXTENSION("glBindProgramNV"); | ||
418 | pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) IRR_OGL_LOAD_EXTENSION("glProgramStringARB"); | ||
419 | pGlLoadProgramNV = (PFNGLLOADPROGRAMNVPROC) IRR_OGL_LOAD_EXTENSION("glLoadProgramNV"); | ||
420 | pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) IRR_OGL_LOAD_EXTENSION("glDeleteProgramsARB"); | ||
421 | pGlDeleteProgramsNV = (PFNGLDELETEPROGRAMSNVPROC) IRR_OGL_LOAD_EXTENSION("glDeleteProgramsNV"); | ||
422 | pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) IRR_OGL_LOAD_EXTENSION("glProgramLocalParameter4fvARB"); | ||
423 | pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) IRR_OGL_LOAD_EXTENSION("glCreateShaderObjectARB"); | ||
424 | pGlCreateShader = (PFNGLCREATESHADERPROC) IRR_OGL_LOAD_EXTENSION("glCreateShader"); | ||
425 | pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) IRR_OGL_LOAD_EXTENSION("glShaderSourceARB"); | ||
426 | pGlShaderSource = (PFNGLSHADERSOURCEPROC) IRR_OGL_LOAD_EXTENSION("glShaderSource"); | ||
427 | pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) IRR_OGL_LOAD_EXTENSION("glCompileShaderARB"); | ||
428 | pGlCompileShader = (PFNGLCOMPILESHADERPROC) IRR_OGL_LOAD_EXTENSION("glCompileShader"); | ||
429 | pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) IRR_OGL_LOAD_EXTENSION("glCreateProgramObjectARB"); | ||
430 | pGlCreateProgram = (PFNGLCREATEPROGRAMPROC) IRR_OGL_LOAD_EXTENSION("glCreateProgram"); | ||
431 | pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) IRR_OGL_LOAD_EXTENSION("glAttachObjectARB"); | ||
432 | pGlAttachShader = (PFNGLATTACHSHADERPROC) IRR_OGL_LOAD_EXTENSION("glAttachShader"); | ||
433 | pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) IRR_OGL_LOAD_EXTENSION("glLinkProgramARB"); | ||
434 | pGlLinkProgram = (PFNGLLINKPROGRAMPROC) IRR_OGL_LOAD_EXTENSION("glLinkProgram"); | ||
435 | pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) IRR_OGL_LOAD_EXTENSION("glUseProgramObjectARB"); | ||
436 | pGlUseProgram = (PFNGLUSEPROGRAMPROC) IRR_OGL_LOAD_EXTENSION("glUseProgram"); | ||
437 | pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) IRR_OGL_LOAD_EXTENSION("glDeleteObjectARB"); | ||
438 | pGlDeleteProgram = (PFNGLDELETEPROGRAMPROC) IRR_OGL_LOAD_EXTENSION("glDeleteProgram"); | ||
439 | pGlDeleteShader = (PFNGLDELETESHADERPROC) IRR_OGL_LOAD_EXTENSION("glDeleteShader"); | ||
440 | pGlGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) IRR_OGL_LOAD_EXTENSION("glGetAttachedShaders"); | ||
441 | pGlGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) IRR_OGL_LOAD_EXTENSION("glGetAttachedObjectsARB"); | ||
442 | pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) IRR_OGL_LOAD_EXTENSION("glGetInfoLogARB"); | ||
443 | pGlGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog"); | ||
444 | pGlGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); | ||
445 | pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) IRR_OGL_LOAD_EXTENSION("glGetObjectParameterivARB"); | ||
446 | pGlGetShaderiv = (PFNGLGETSHADERIVPROC) IRR_OGL_LOAD_EXTENSION("glGetShaderiv"); | ||
447 | pGlGetProgramiv = (PFNGLGETPROGRAMIVPROC) IRR_OGL_LOAD_EXTENSION("glGetProgramiv"); | ||
448 | pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) IRR_OGL_LOAD_EXTENSION("glGetUniformLocationARB"); | ||
449 | pGlGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) IRR_OGL_LOAD_EXTENSION("glGetUniformLocation"); | ||
450 | pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform1fvARB"); | ||
451 | pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform2fvARB"); | ||
452 | pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform3fvARB"); | ||
453 | pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform4fvARB"); | ||
454 | pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform1ivARB"); | ||
455 | pGlUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform2ivARB"); | ||
456 | pGlUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform3ivARB"); | ||
457 | pGlUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform4ivARB"); | ||
458 | pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix2fvARB"); | ||
459 | pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix3fvARB"); | ||
460 | pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fvARB"); | ||
461 | pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) IRR_OGL_LOAD_EXTENSION("glGetActiveUniformARB"); | ||
462 | pGlGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) IRR_OGL_LOAD_EXTENSION("glGetActiveUniform"); | ||
463 | |||
464 | // get point parameter extension | ||
465 | pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) IRR_OGL_LOAD_EXTENSION("glPointParameterfARB"); | ||
466 | pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) IRR_OGL_LOAD_EXTENSION("glPointParameterfvARB"); | ||
467 | |||
468 | // get stencil extension | ||
469 | pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) IRR_OGL_LOAD_EXTENSION("glStencilFuncSeparate"); | ||
470 | pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) IRR_OGL_LOAD_EXTENSION("glStencilOpSeparate"); | ||
471 | pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) IRR_OGL_LOAD_EXTENSION("glStencilFuncSeparateATI"); | ||
472 | pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) IRR_OGL_LOAD_EXTENSION("glStencilOpSeparateATI"); | ||
473 | |||
474 | // compressed textures | ||
475 | pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) IRR_OGL_LOAD_EXTENSION("glCompressedTexImage2D"); | ||
476 | |||
477 | // ARB FrameBufferObjects | ||
478 | pGlBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) IRR_OGL_LOAD_EXTENSION("glBindFramebuffer"); | ||
479 | pGlDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) IRR_OGL_LOAD_EXTENSION("glDeleteFramebuffers"); | ||
480 | pGlGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) IRR_OGL_LOAD_EXTENSION("glGenFramebuffers"); | ||
481 | pGlCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatus"); | ||
482 | pGlFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) IRR_OGL_LOAD_EXTENSION("glFramebufferTexture2D"); | ||
483 | pGlBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) IRR_OGL_LOAD_EXTENSION("glBindRenderbuffer"); | ||
484 | pGlDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) IRR_OGL_LOAD_EXTENSION("glDeleteRenderbuffers"); | ||
485 | pGlGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) IRR_OGL_LOAD_EXTENSION("glGenRenderbuffers"); | ||
486 | pGlRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) IRR_OGL_LOAD_EXTENSION("glRenderbufferStorage"); | ||
487 | pGlFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) IRR_OGL_LOAD_EXTENSION("glFramebufferRenderbuffer"); | ||
488 | pGlGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) IRR_OGL_LOAD_EXTENSION("glGenerateMipmap"); | ||
489 | |||
490 | // EXT FrameBufferObjects | ||
491 | pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) IRR_OGL_LOAD_EXTENSION("glBindFramebufferEXT"); | ||
492 | pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) IRR_OGL_LOAD_EXTENSION("glDeleteFramebuffersEXT"); | ||
493 | pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) IRR_OGL_LOAD_EXTENSION("glGenFramebuffersEXT"); | ||
494 | pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) IRR_OGL_LOAD_EXTENSION("glCheckFramebufferStatusEXT"); | ||
495 | pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) IRR_OGL_LOAD_EXTENSION("glFramebufferTexture2DEXT"); | ||
496 | pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) IRR_OGL_LOAD_EXTENSION("glBindRenderbufferEXT"); | ||
497 | pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) IRR_OGL_LOAD_EXTENSION("glDeleteRenderbuffersEXT"); | ||
498 | pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) IRR_OGL_LOAD_EXTENSION("glGenRenderbuffersEXT"); | ||
499 | pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) IRR_OGL_LOAD_EXTENSION("glRenderbufferStorageEXT"); | ||
500 | pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) IRR_OGL_LOAD_EXTENSION("glFramebufferRenderbufferEXT"); | ||
501 | pGlGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) IRR_OGL_LOAD_EXTENSION("glGenerateMipmapEXT"); | ||
502 | pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) IRR_OGL_LOAD_EXTENSION("glDrawBuffersARB"); | ||
503 | pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC) IRR_OGL_LOAD_EXTENSION("glDrawBuffersATI"); | ||
504 | |||
505 | // get vertex buffer extension | ||
506 | pGlGenBuffersARB = (PFNGLGENBUFFERSARBPROC) IRR_OGL_LOAD_EXTENSION("glGenBuffersARB"); | ||
507 | pGlBindBufferARB = (PFNGLBINDBUFFERARBPROC) IRR_OGL_LOAD_EXTENSION("glBindBufferARB"); | ||
508 | pGlBufferDataARB = (PFNGLBUFFERDATAARBPROC) IRR_OGL_LOAD_EXTENSION("glBufferDataARB"); | ||
509 | pGlDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) IRR_OGL_LOAD_EXTENSION("glDeleteBuffersARB"); | ||
510 | pGlBufferSubDataARB= (PFNGLBUFFERSUBDATAARBPROC) IRR_OGL_LOAD_EXTENSION("glBufferSubDataARB"); | ||
511 | pGlGetBufferSubDataARB= (PFNGLGETBUFFERSUBDATAARBPROC)IRR_OGL_LOAD_EXTENSION("glGetBufferSubDataARB"); | ||
512 | pGlMapBufferARB= (PFNGLMAPBUFFERARBPROC) IRR_OGL_LOAD_EXTENSION("glMapBufferARB"); | ||
513 | pGlUnmapBufferARB= (PFNGLUNMAPBUFFERARBPROC) IRR_OGL_LOAD_EXTENSION("glUnmapBufferARB"); | ||
514 | pGlIsBufferARB= (PFNGLISBUFFERARBPROC) IRR_OGL_LOAD_EXTENSION("glIsBufferARB"); | ||
515 | pGlGetBufferParameterivARB= (PFNGLGETBUFFERPARAMETERIVARBPROC) IRR_OGL_LOAD_EXTENSION("glGetBufferParameterivARB"); | ||
516 | pGlGetBufferPointervARB= (PFNGLGETBUFFERPOINTERVARBPROC) IRR_OGL_LOAD_EXTENSION("glGetBufferPointervARB"); | ||
517 | pGlProvokingVertexARB= (PFNGLPROVOKINGVERTEXPROC) IRR_OGL_LOAD_EXTENSION("glProvokingVertex"); | ||
518 | pGlProvokingVertexEXT= (PFNGLPROVOKINGVERTEXEXTPROC) IRR_OGL_LOAD_EXTENSION("glProvokingVertexEXT"); | ||
519 | pGlColorMaskIndexedEXT= (PFNGLCOLORMASKINDEXEDEXTPROC) IRR_OGL_LOAD_EXTENSION("glColorMaskIndexedEXT"); | ||
520 | pGlEnableIndexedEXT= (PFNGLENABLEINDEXEDEXTPROC) IRR_OGL_LOAD_EXTENSION("glEnableIndexedEXT"); | ||
521 | pGlDisableIndexedEXT= (PFNGLDISABLEINDEXEDEXTPROC) IRR_OGL_LOAD_EXTENSION("glDisableIndexedEXT"); | ||
522 | pGlBlendFuncIndexedAMD= (PFNGLBLENDFUNCINDEXEDAMDPROC) IRR_OGL_LOAD_EXTENSION("glBlendFuncIndexedAMD"); | ||
523 | pGlBlendFunciARB= (PFNGLBLENDFUNCIPROC) IRR_OGL_LOAD_EXTENSION("glBlendFunciARB"); | ||
524 | pGlBlendEquationIndexedAMD= (PFNGLBLENDEQUATIONINDEXEDAMDPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationIndexedAMD"); | ||
525 | pGlBlendEquationiARB= (PFNGLBLENDEQUATIONIPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationiARB"); | ||
526 | pGlProgramParameteriARB= (PFNGLPROGRAMPARAMETERIARBPROC) IRR_OGL_LOAD_EXTENSION("glProgramParameteriARB"); | ||
527 | pGlProgramParameteriEXT= (PFNGLPROGRAMPARAMETERIEXTPROC) IRR_OGL_LOAD_EXTENSION("glProgramParameteriEXT"); | ||
528 | |||
529 | // occlusion query | ||
530 | pGlGenQueriesARB = (PFNGLGENQUERIESARBPROC) IRR_OGL_LOAD_EXTENSION("glGenQueriesARB"); | ||
531 | pGlDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) IRR_OGL_LOAD_EXTENSION("glDeleteQueriesARB"); | ||
532 | pGlIsQueryARB = (PFNGLISQUERYARBPROC) IRR_OGL_LOAD_EXTENSION("glIsQueryARB"); | ||
533 | pGlBeginQueryARB = (PFNGLBEGINQUERYARBPROC) IRR_OGL_LOAD_EXTENSION("glBeginQueryARB"); | ||
534 | pGlEndQueryARB = (PFNGLENDQUERYARBPROC) IRR_OGL_LOAD_EXTENSION("glEndQueryARB"); | ||
535 | pGlGetQueryivARB = (PFNGLGETQUERYIVARBPROC) IRR_OGL_LOAD_EXTENSION("glGetQueryivARB"); | ||
536 | pGlGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) IRR_OGL_LOAD_EXTENSION("glGetQueryObjectivARB"); | ||
537 | pGlGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) IRR_OGL_LOAD_EXTENSION("glGetQueryObjectuivARB"); | ||
538 | pGlGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC) IRR_OGL_LOAD_EXTENSION("glGenOcclusionQueriesNV"); | ||
539 | pGlDeleteOcclusionQueriesNV = (PFNGLDELETEOCCLUSIONQUERIESNVPROC) IRR_OGL_LOAD_EXTENSION("glDeleteOcclusionQueriesNV"); | ||
540 | pGlIsOcclusionQueryNV = (PFNGLISOCCLUSIONQUERYNVPROC) IRR_OGL_LOAD_EXTENSION("glIsOcclusionQueryNV"); | ||
541 | pGlBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC) IRR_OGL_LOAD_EXTENSION("glBeginOcclusionQueryNV"); | ||
542 | pGlEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC) IRR_OGL_LOAD_EXTENSION("glEndOcclusionQueryNV"); | ||
543 | pGlGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC) IRR_OGL_LOAD_EXTENSION("glGetOcclusionQueryivNV"); | ||
544 | pGlGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC) IRR_OGL_LOAD_EXTENSION("glGetOcclusionQueryuivNV"); | ||
545 | |||
546 | // blend equation | ||
547 | pGlBlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationEXT"); | ||
548 | pGlBlendEquation = (PFNGLBLENDEQUATIONPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquation"); | ||
549 | |||
550 | // get vsync extension | ||
551 | #if defined(WGL_EXT_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||
552 | pWglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) IRR_OGL_LOAD_EXTENSION("wglSwapIntervalEXT"); | ||
553 | #endif | ||
554 | #if defined(GLX_SGI_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||
555 | pGlxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalSGI"); | ||
556 | #endif | ||
557 | #if defined(GLX_EXT_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||
558 | pGlxSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalEXT"); | ||
559 | #endif | ||
560 | #if defined(GLX_MESA_swap_control) && !defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | ||
561 | pGlxSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)IRR_OGL_LOAD_EXTENSION("glXSwapIntervalMESA"); | ||
562 | #endif | ||
563 | #endif // use extension pointer | ||
564 | |||
565 | GLint num=0; | ||
566 | // set some properties | ||
567 | #if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3) | ||
568 | if (Version>102 || FeatureAvailable[IRR_ARB_multitexture]) | ||
569 | { | ||
570 | #if defined(GL_MAX_TEXTURE_UNITS) | ||
571 | glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num); | ||
572 | #elif defined(GL_MAX_TEXTURE_UNITS_ARB) | ||
573 | glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num); | ||
574 | #endif | ||
575 | MaxSupportedTextures=static_cast<u8>(num); | ||
576 | } | ||
577 | #endif | ||
578 | #if defined(GL_ARB_vertex_shader) || defined(GL_VERSION_2_0) | ||
579 | if (Version>=200 || FeatureAvailable[IRR_ARB_vertex_shader]) | ||
580 | { | ||
581 | num=0; | ||
582 | #if defined(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) | ||
583 | glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num); | ||
584 | #elif defined(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB) | ||
585 | glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &num); | ||
586 | #endif | ||
587 | MaxSupportedTextures=core::max_(MaxSupportedTextures,static_cast<u8>(num)); | ||
588 | } | ||
589 | #endif | ||
590 | glGetIntegerv(GL_MAX_LIGHTS, &num); | ||
591 | MaxLights=static_cast<u8>(num); | ||
592 | #ifdef GL_EXT_texture_filter_anisotropic | ||
593 | if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic]) | ||
594 | { | ||
595 | glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &num); | ||
596 | MaxAnisotropy=static_cast<u8>(num); | ||
597 | } | ||
598 | #endif | ||
599 | #ifdef GL_VERSION_1_2 | ||
600 | if (Version>101) | ||
601 | { | ||
602 | glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &num); | ||
603 | MaxIndices=num; | ||
604 | } | ||
605 | #endif | ||
606 | glGetIntegerv(GL_MAX_TEXTURE_SIZE, &num); | ||
607 | MaxTextureSize=static_cast<u32>(num); | ||
608 | if (queryFeature(EVDF_GEOMETRY_SHADER)) | ||
609 | { | ||
610 | #if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4) | ||
611 | glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &num); | ||
612 | MaxGeometryVerticesOut=static_cast<u32>(num); | ||
613 | #elif defined(GL_NV_geometry_program4) | ||
614 | extGlGetProgramiv(GEOMETRY_PROGRAM_NV, GL_MAX_PROGRAM_OUTPUT_VERTICES_NV, &num); | ||
615 | MaxGeometryVerticesOut=static_cast<u32>(num); | ||
616 | #endif | ||
617 | } | ||
618 | #ifdef GL_EXT_texture_lod_bias | ||
619 | if (FeatureAvailable[IRR_EXT_texture_lod_bias]) | ||
620 | glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias); | ||
621 | #endif | ||
622 | glGetIntegerv(GL_MAX_CLIP_PLANES, &num); | ||
623 | MaxUserClipPlanes=static_cast<u8>(num); | ||
624 | glGetIntegerv(GL_AUX_BUFFERS, &num); | ||
625 | MaxAuxBuffers=static_cast<u8>(num); | ||
626 | #ifdef GL_ARB_draw_buffers | ||
627 | if (FeatureAvailable[IRR_ARB_draw_buffers]) | ||
628 | { | ||
629 | glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &num); | ||
630 | MaxMultipleRenderTargets = static_cast<u8>(num); | ||
631 | } | ||
632 | #endif | ||
633 | #if defined(GL_ATI_draw_buffers) | ||
634 | #ifdef GL_ARB_draw_buffers | ||
635 | else | ||
636 | #endif | ||
637 | if (FeatureAvailable[IRR_ATI_draw_buffers]) | ||
638 | { | ||
639 | glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, &num); | ||
640 | MaxMultipleRenderTargets = static_cast<u8>(num); | ||
641 | } | ||
642 | #endif | ||
643 | glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); | ||
644 | glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); | ||
645 | glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine); | ||
646 | glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint); | ||
647 | #if defined(GL_ARB_shading_language_100) || defined (GL_VERSION_2_0) | ||
648 | if (FeatureAvailable[IRR_ARB_shading_language_100] || Version>=200) | ||
649 | { | ||
650 | glGetError(); // clean error buffer | ||
651 | #ifdef GL_SHADING_LANGUAGE_VERSION | ||
652 | const GLubyte* shaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION); | ||
653 | #else | ||
654 | const GLubyte* shaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION_ARB); | ||
655 | #endif | ||
656 | if (glGetError() == GL_INVALID_ENUM) | ||
657 | ShaderLanguageVersion = 100; | ||
658 | else | ||
659 | { | ||
660 | const f32 sl_ver = core::fast_atof(reinterpret_cast<const c8*>(shaderVersion)); | ||
661 | ShaderLanguageVersion = static_cast<u16>(core::floor32(sl_ver)*100+core::round32(core::fract(sl_ver)*10.0f)); | ||
662 | } | ||
663 | } | ||
664 | #endif | ||
665 | |||
666 | #ifdef _IRR_OPENGL_USE_EXTPOINTER_ | ||
667 | if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) | ||
668 | { | ||
669 | MultiTextureExtension = false; | ||
670 | os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); | ||
671 | } | ||
672 | else | ||
673 | #endif | ||
674 | MaxTextureUnits = core::min_(MaxSupportedTextures, static_cast<u8>(MATERIAL_MAX_TEXTURES)); | ||
675 | if (MaxTextureUnits < 2) | ||
676 | { | ||
677 | MultiTextureExtension = false; | ||
678 | os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); | ||
679 | } | ||
680 | |||
681 | #ifdef GL_ARB_occlusion_query | ||
682 | if (FeatureAvailable[IRR_ARB_occlusion_query]) | ||
683 | { | ||
684 | extGlGetQueryiv(GL_SAMPLES_PASSED_ARB,GL_QUERY_COUNTER_BITS_ARB, | ||
685 | &num); | ||
686 | OcclusionQuerySupport=(num>0); | ||
687 | } | ||
688 | else | ||
689 | #endif | ||
690 | #ifdef GL_NV_occlusion_query | ||
691 | if (FeatureAvailable[IRR_NV_occlusion_query]) | ||
692 | { | ||
693 | glGetIntegerv(GL_PIXEL_COUNTER_BITS_NV, &num); | ||
694 | OcclusionQuerySupport=(num>0); | ||
695 | } | ||
696 | else | ||
697 | #endif | ||
698 | OcclusionQuerySupport=false; | ||
699 | |||
700 | #ifdef _DEBUG | ||
701 | if (FeatureAvailable[IRR_NVX_gpu_memory_info]) | ||
702 | { | ||
703 | // undocumented flags, so use the RAW values | ||
704 | GLint val; | ||
705 | glGetIntegerv(0x9047, &val); | ||
706 | os::Printer::log("Dedicated video memory (kB)", core::stringc(val)); | ||
707 | glGetIntegerv(0x9048, &val); | ||
708 | os::Printer::log("Total video memory (kB)", core::stringc(val)); | ||
709 | glGetIntegerv(0x9049, &val); | ||
710 | os::Printer::log("Available video memory (kB)", core::stringc(val)); | ||
711 | } | ||
712 | #ifdef GL_ATI_meminfo | ||
713 | if (FeatureAvailable[IRR_ATI_meminfo]) | ||
714 | { | ||
715 | GLint val[4]; | ||
716 | glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, val); | ||
717 | os::Printer::log("Free texture memory (kB)", core::stringc(val[0])); | ||
718 | glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, val); | ||
719 | os::Printer::log("Free VBO memory (kB)", core::stringc(val[0])); | ||
720 | glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, val); | ||
721 | os::Printer::log("Free render buffer memory (kB)", core::stringc(val[0])); | ||
722 | } | ||
723 | #endif | ||
724 | #endif | ||
725 | } | ||
726 | |||
727 | bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const | ||
728 | { | ||
729 | switch (feature) | ||
730 | { | ||
731 | case EVDF_RENDER_TO_TARGET: | ||
732 | return true; | ||
733 | case EVDF_HARDWARE_TL: | ||
734 | return true; // we cannot tell other things | ||
735 | case EVDF_MULTITEXTURE: | ||
736 | return MultiTextureExtension; | ||
737 | case EVDF_BILINEAR_FILTER: | ||
738 | return true; | ||
739 | case EVDF_MIP_MAP: | ||
740 | return true; | ||
741 | case EVDF_MIP_MAP_AUTO_UPDATE: | ||
742 | return FeatureAvailable[IRR_SGIS_generate_mipmap] || FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object]; | ||
743 | case EVDF_STENCIL_BUFFER: | ||
744 | return StencilBuffer; | ||
745 | case EVDF_VERTEX_SHADER_1_1: | ||
746 | case EVDF_ARB_VERTEX_PROGRAM_1: | ||
747 | return FeatureAvailable[IRR_ARB_vertex_program] || FeatureAvailable[IRR_NV_vertex_program1_1]; | ||
748 | case EVDF_PIXEL_SHADER_1_1: | ||
749 | case EVDF_PIXEL_SHADER_1_2: | ||
750 | case EVDF_ARB_FRAGMENT_PROGRAM_1: | ||
751 | return FeatureAvailable[IRR_ARB_fragment_program] || FeatureAvailable[IRR_NV_fragment_program]; | ||
752 | case EVDF_PIXEL_SHADER_2_0: | ||
753 | case EVDF_VERTEX_SHADER_2_0: | ||
754 | case EVDF_ARB_GLSL: | ||
755 | return (FeatureAvailable[IRR_ARB_shading_language_100]||Version>=200); | ||
756 | case EVDF_TEXTURE_NSQUARE: | ||
757 | return true; // non-square is always supported | ||
758 | case EVDF_TEXTURE_NPOT: | ||
759 | // Some ATI cards seem to have only SW support in OpenGL 2.0 | ||
760 | // drivers if the extension is not exposed, so we skip this | ||
761 | // extra test for now! | ||
762 | // return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]||Version>=200); | ||
763 | return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]); | ||
764 | case EVDF_FRAMEBUFFER_OBJECT: | ||
765 | return FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object]; | ||
766 | case EVDF_VERTEX_BUFFER_OBJECT: | ||
767 | return FeatureAvailable[IRR_ARB_vertex_buffer_object]; | ||
768 | case EVDF_COLOR_MASK: | ||
769 | return true; | ||
770 | case EVDF_ALPHA_TO_COVERAGE: | ||
771 | return FeatureAvailable[IRR_ARB_multisample]; | ||
772 | case EVDF_GEOMETRY_SHADER: | ||
773 | return FeatureAvailable[IRR_ARB_geometry_shader4] || FeatureAvailable[IRR_EXT_geometry_shader4] || FeatureAvailable[IRR_NV_geometry_program4] || FeatureAvailable[IRR_NV_geometry_shader4]; | ||
774 | case EVDF_MULTIPLE_RENDER_TARGETS: | ||
775 | return FeatureAvailable[IRR_ARB_draw_buffers] || FeatureAvailable[IRR_ATI_draw_buffers]; | ||
776 | case EVDF_MRT_BLEND: | ||
777 | case EVDF_MRT_COLOR_MASK: | ||
778 | return FeatureAvailable[IRR_EXT_draw_buffers2]; | ||
779 | case EVDF_MRT_BLEND_FUNC: | ||
780 | return FeatureAvailable[IRR_ARB_draw_buffers_blend] || FeatureAvailable[IRR_AMD_draw_buffers_blend]; | ||
781 | case EVDF_OCCLUSION_QUERY: | ||
782 | return FeatureAvailable[IRR_ARB_occlusion_query] && OcclusionQuerySupport; | ||
783 | case EVDF_POLYGON_OFFSET: | ||
784 | // both features supported with OpenGL 1.1 | ||
785 | return Version>=110; | ||
786 | case EVDF_BLEND_OPERATIONS: | ||
787 | return (Version>=120) || FeatureAvailable[IRR_EXT_blend_minmax] || | ||
788 | FeatureAvailable[IRR_EXT_blend_subtract] || FeatureAvailable[IRR_EXT_blend_logic_op]; | ||
789 | case EVDF_TEXTURE_MATRIX: | ||
790 | #ifdef _IRR_COMPILE_WITH_CG_ | ||
791 | // available iff. define is present | ||
792 | case EVDF_CG: | ||
793 | #endif | ||
794 | return true; | ||
795 | default: | ||
796 | return false; | ||
797 | }; | ||
798 | } | ||
799 | |||
800 | |||
801 | } | ||
802 | } | ||
803 | |||
804 | #endif | ||