1 /* Support for window-specific OpenGL extensions.
3 * Copyright (c) 2004 Lionel Ulmer
4 * Copyright (c) 2005 Alex Woods
5 * Copyright (c) 2005 Raphael Junqueira
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
36 #include "opengl_ext.h"
37 #include "wine/library.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
43 /* x11drv GDI escapes */
44 #define X11DRV_ESCAPE 6789
45 enum x11drv_escape_codes
47 X11DRV_GET_DISPLAY, /* get X11 display for a DC */
48 X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
49 X11DRV_GET_FONT, /* get current X font for a DC */
50 X11DRV_SET_DRAWABLE, /* set current drawable for a DC */
52 struct x11drv_escape_set_drawable
54 enum x11drv_escape_codes code; /* escape code (X11DRV_SET_DRAWABLE) */
55 Drawable drawable; /* X drawable */
56 int mode; /* ClipByChildren or IncludeInferiors */
57 POINT org; /* origin of DC relative to drawable */
58 POINT drawable_org; /* origin of drawable relative to screen */
61 /* retrieve the X display to use on a given DC */
62 inline static Display *get_display( HDC hdc )
65 enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY;
67 if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
68 sizeof(display), (LPSTR)&display )) display = NULL;
71 inline static void set_drawable( HDC hdc, Drawable drawable )
73 struct x11drv_escape_set_drawable escape;
75 escape.code = X11DRV_SET_DRAWABLE;
76 escape.drawable = drawable;
77 escape.mode = IncludeInferiors;
78 escape.org.x = escape.org.y = 0;
79 escape.drawable_org.x = escape.drawable_org.y = 0;
81 ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, 0, NULL );
84 /* Some WGL extensions... */
85 static const char *WGL_extensions_base = "WGL_ARB_extensions_string WGL_EXT_extensions_string";
86 static char *WGL_extensions = NULL;
89 * Extensions-query functions
91 * @TODO: use a struct to handle parameters
93 BOOL query_function_make_current_read(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
94 const char* glx_version, const char *glx_extensions,
95 const char *server_glx_extensions, const char *client_glx_extensions)
97 return 0 <= strcmp("1.3", glx_version);
100 BOOL query_function_multisample(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
101 const char* glx_version, const char *glx_extensions,
102 const char *server_glx_extensions, const char *client_glx_extensions)
104 return NULL != strstr(glx_extensions, "GLX_ARB_multisample");
107 BOOL query_function_pbuffer(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
108 const char* glx_version, const char *glx_extensions,
109 const char *server_glx_extensions, const char *client_glx_extensions)
111 TRACE("gl_version is: \"%s\"\n", gl_version);
112 TRACE("glx_exts is: \"%s\"\n", glx_extensions);
114 return 0 <= strcmp("1.3", glx_version) || NULL != strstr(glx_extensions, "GLX_SGIX_pbuffer");
117 BOOL query_function_pixel_format(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
118 const char* glx_version, const char *glx_extensions,
119 const char *server_glx_extensions, const char *client_glx_extensions)
124 /** GLX_ARB_render_texture */
126 * http://oss.sgi.com/projects/ogl-sample/registry/ARB/wgl_render_texture.txt
127 * ~/tmp/ogl/ogl_offscreen_rendering_3
129 Bool (*p_glXBindTexImageARB)(Display *dpy, GLXPbuffer pbuffer, int buffer);
130 Bool (*p_glXReleaseTexImageARB)(Display *dpy, GLXPbuffer pbuffer, int buffer);
131 Bool (*p_glXDrawableAttribARB)(Display *dpy, GLXDrawable draw, const int *attribList);
132 int use_render_texture_emulation = 0;
133 int use_render_texture_ati = 0;
134 BOOL query_function_render_texture(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
135 const char* glx_version, const char *glx_extensions,
136 const char *server_glx_extensions, const char *client_glx_extensions)
139 if (NULL != strstr(glx_extensions, "GLX_ATI_render_texture")) {
140 p_glXBindTexImageARB = proc( (const GLubyte *) "glXBindTexImageARB");
141 p_glXReleaseTexImageARB = proc( (const GLubyte *) "glXReleaseTexImageARB");
142 p_glXDrawableAttribARB = proc( (const GLubyte *) "glXDrawableAttribARB");
143 bTest = (NULL != p_glXBindTexImageARB && NULL != p_glXReleaseTexImageARB && NULL != p_glXDrawableAttribARB);
146 TRACE("Active WGL_render_texture: found GLX_ATI_render_texture extensions\n");
147 use_render_texture_ati = 1;
150 bTest = (0 <= strcmp("1.3", glx_version) || NULL != strstr(glx_extensions, "GLX_SGIX_pbuffer"));
152 if (NULL != strstr(glx_extensions, "GLX_ARB_render_texture")) {
153 p_glXBindTexImageARB = proc( (const GLubyte *) "glXBindTexImageARB");
154 p_glXReleaseTexImageARB = proc( (const GLubyte *) "glXReleaseTexImageARB");
155 p_glXDrawableAttribARB = proc( (const GLubyte *) "glXDrawableAttribARB");
156 TRACE("glXBindTexImageARB found as %p\n", p_glXBindTexImageARB);
157 TRACE("glXReleaseTexImageARB found as %p\n", p_glXReleaseTexImageARB);
158 TRACE("glXDrawableAttribARB found as %p\n", p_glXDrawableAttribARB);
159 bTest = (NULL != p_glXBindTexImageARB && NULL != p_glXReleaseTexImageARB && NULL != p_glXDrawableAttribARB);
161 TRACE("Active WGL_render_texture: emulation using pbuffers\n");
162 use_render_texture_emulation = 1;
168 int (*p_glXSwapIntervalSGI)(int);
169 BOOL query_function_swap_control(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
170 const char* glx_version, const char *glx_extensions,
171 const char *server_glx_extensions, const char *client_glx_extensions)
173 BOOL bTest = (0 <= strcmp("1.3", glx_version) || NULL != strstr(glx_extensions, "GLX_SGI_swap_control"));
175 p_glXSwapIntervalSGI = proc( (const GLubyte *) "glXSwapIntervalSGI");
176 bTest = (NULL != p_glXSwapIntervalSGI);
181 /***********************************************************************
182 * wglGetExtensionsStringEXT(OPENGL32.@)
184 const char * WINAPI wglGetExtensionsStringEXT(void) {
185 TRACE("() returning \"%s\"\n", WGL_extensions);
187 return WGL_extensions;
190 /***********************************************************************
191 * wglGetExtensionsStringARB(OPENGL32.@)
193 const char * WINAPI wglGetExtensionsStringARB(HDC hdc) {
194 TRACE("() returning \"%s\"\n", WGL_extensions);
196 return WGL_extensions;
199 static int swap_interval = 1;
201 /***********************************************************************
202 * wglSwapIntervalEXT(OPENGL32.@)
204 BOOL WINAPI wglSwapIntervalEXT(int interval) {
205 TRACE("(%d)\n", interval);
206 swap_interval = interval;
207 if (NULL != p_glXSwapIntervalSGI) {
208 return 0 == p_glXSwapIntervalSGI(interval);
210 WARN("(): GLX_SGI_swap_control extension seems not supported\n");
214 /***********************************************************************
215 * wglGetSwapIntervalEXT(OPENGL32.@)
217 int WINAPI wglGetSwapIntervalEXT(VOID) {
219 return swap_interval;
222 typedef struct wine_glpbuffer {
231 int use_render_texture;
232 GLuint texture_target;
233 GLuint texture_bind_target;
242 #define PUSH1(attribs,att) attribs[nAttribs++] = (att);
243 #define PUSH2(attribs,att,value) attribs[nAttribs++] = (att); attribs[nAttribs++] = (value);
245 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
246 #define WGL_DRAW_TO_WINDOW_ARB 0x2001
247 #define WGL_DRAW_TO_BITMAP_ARB 0x2002
248 #define WGL_ACCELERATION_ARB 0x2003
249 #define WGL_NEED_PALETTE_ARB 0x2004
250 #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
251 #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
252 #define WGL_SWAP_METHOD_ARB 0x2007
253 #define WGL_NUMBER_OVERLAYS_ARB 0x2008
254 #define WGL_NUMBER_UNDERLAYS_ARB 0x2009
255 #define WGL_TRANSPARENT_ARB 0x200A
256 #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
257 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
258 #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
259 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
260 #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
261 #define WGL_SHARE_DEPTH_ARB 0x200C
262 #define WGL_SHARE_STENCIL_ARB 0x200D
263 #define WGL_SHARE_ACCUM_ARB 0x200E
264 #define WGL_SUPPORT_GDI_ARB 0x200F
265 #define WGL_SUPPORT_OPENGL_ARB 0x2010
266 #define WGL_DOUBLE_BUFFER_ARB 0x2011
267 #define WGL_STEREO_ARB 0x2012
268 #define WGL_PIXEL_TYPE_ARB 0x2013
269 #define WGL_COLOR_BITS_ARB 0x2014
270 #define WGL_RED_BITS_ARB 0x2015
271 #define WGL_RED_SHIFT_ARB 0x2016
272 #define WGL_GREEN_BITS_ARB 0x2017
273 #define WGL_GREEN_SHIFT_ARB 0x2018
274 #define WGL_BLUE_BITS_ARB 0x2019
275 #define WGL_BLUE_SHIFT_ARB 0x201A
276 #define WGL_ALPHA_BITS_ARB 0x201B
277 #define WGL_ALPHA_SHIFT_ARB 0x201C
278 #define WGL_ACCUM_BITS_ARB 0x201D
279 #define WGL_ACCUM_RED_BITS_ARB 0x201E
280 #define WGL_ACCUM_GREEN_BITS_ARB 0x201F
281 #define WGL_ACCUM_BLUE_BITS_ARB 0x2020
282 #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
283 #define WGL_DEPTH_BITS_ARB 0x2022
284 #define WGL_STENCIL_BITS_ARB 0x2023
285 #define WGL_AUX_BUFFERS_ARB 0x2024
287 #define WGL_NO_ACCELERATION_ARB 0x2025
288 #define WGL_GENERIC_ACCELERATION_ARB 0x2026
289 #define WGL_FULL_ACCELERATION_ARB 0x2027
291 #define WGL_PBUFFER_WIDTH_ARB 0x2034
292 #define WGL_PBUFFER_HEIGHT_ARB 0x2035
293 #define WGL_PBUFFER_LOST_ARB 0x2036
294 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D
295 #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
296 #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
297 #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
298 #define WGL_PBUFFER_LARGEST_ARB 0x2033
300 #define WGL_TYPE_RGBA_ARB 0x202B
301 #define WGL_TYPE_COLORINDEX_ARB 0x202C
303 #define WGL_SAMPLE_BUFFERS_ARB 0x2041
304 #define WGL_SAMPLES_ARB 0x2042
309 /** GetPixelFormat/ChoosePixelFormat */
310 #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
311 #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
312 /** CreatePbuffer / QueryPbuffer */
313 #define WGL_TEXTURE_FORMAT_ARB 0x2072
314 #define WGL_TEXTURE_TARGET_ARB 0x2073
315 #define WGL_MIPMAP_TEXTURE_ARB 0x2074
316 /** CreatePbuffer / QueryPbuffer */
317 #define WGL_TEXTURE_RGB_ARB 0x2075
318 #define WGL_TEXTURE_RGBA_ARB 0x2076
319 #define WGL_NO_TEXTURE_ARB 0x2077
320 /** CreatePbuffer / QueryPbuffer */
321 #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
322 #define WGL_TEXTURE_1D_ARB 0x2079
323 #define WGL_TEXTURE_2D_ARB 0x207A
324 #define WGL_NO_TEXTURE_ARB 0x2077
325 /** SetPbufferAttribARB/QueryPbufferARB parameters */
326 #define WGL_MIPMAP_LEVEL_ARB 0x207B
327 #define WGL_CUBE_MAP_FACE_ARB 0x207C
328 /** SetPbufferAttribARB/QueryPbufferARB attribs */
329 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
330 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
331 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
332 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
333 #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
334 #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
335 /** BindTexImageARB/ReleaseTexImageARB */
336 #define WGL_FRONT_LEFT_ARB 0x2083
337 #define WGL_FRONT_RIGHT_ARB 0x2084
338 #define WGL_BACK_LEFT_ARB 0x2085
339 #define WGL_BACK_RIGHT_ARB 0x2086
340 #define WGL_AUX0_ARB 0x2087
341 #define WGL_AUX1_ARB 0x2088
342 #define WGL_AUX2_ARB 0x2089
343 #define WGL_AUX3_ARB 0x208A
344 #define WGL_AUX4_ARB 0x208B
345 #define WGL_AUX5_ARB 0x208C
346 #define WGL_AUX6_ARB 0x208D
347 #define WGL_AUX7_ARB 0x208E
348 #define WGL_AUX8_ARB 0x208F
349 #define WGL_AUX9_ARB 0x2090
352 * WGL_ATI_pixel_format_float / WGL_ARB_color_buffer_float
354 #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
355 #define GL_RGBA_FLOAT_MODE_ATI 0x8820
356 #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
357 #define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
358 #define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
359 #define GL_CLAMP_READ_COLOR_ARB 0x891C
360 /** GLX_ATI_pixel_format_float */
361 #define GLX_RGBA_FLOAT_ATI_BIT 0x00000100
362 /** GLX_ARB_pixel_format_float */
363 #define GLX_RGBA_FLOAT_BIT 0x00000004
364 #define GLX_RGBA_FLOAT_TYPE 0x20B9
365 /** GLX_ATI_render_texture */
366 #define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800
367 #define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801
368 #define GLX_TEXTURE_FORMAT_ATI 0x9802
369 #define GLX_TEXTURE_TARGET_ATI 0x9803
370 #define GLX_MIPMAP_TEXTURE_ATI 0x9804
371 #define GLX_TEXTURE_RGB_ATI 0x9805
372 #define GLX_TEXTURE_RGBA_ATI 0x9806
373 #define GLX_NO_TEXTURE_ATI 0x9807
374 #define GLX_TEXTURE_CUBE_MAP_ATI 0x9808
375 #define GLX_TEXTURE_1D_ATI 0x9809
376 #define GLX_TEXTURE_2D_ATI 0x980A
377 #define GLX_MIPMAP_LEVEL_ATI 0x980B
378 #define GLX_CUBE_MAP_FACE_ATI 0x980C
379 #define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D
380 #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E
381 #define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F
382 #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810
383 #define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811
384 #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812
385 #define GLX_FRONT_LEFT_ATI 0x9813
386 #define GLX_FRONT_RIGHT_ATI 0x9814
387 #define GLX_BACK_LEFT_ATI 0x9815
388 #define GLX_BACK_RIGHT_ATI 0x9816
389 #define GLX_AUX0_ATI 0x9817
390 #define GLX_AUX1_ATI 0x9818
391 #define GLX_AUX2_ATI 0x9819
392 #define GLX_AUX3_ATI 0x981A
393 #define GLX_AUX4_ATI 0x981B
394 #define GLX_AUX5_ATI 0x981C
395 #define GLX_AUX6_ATI 0x981D
396 #define GLX_AUX7_ATI 0x981E
397 #define GLX_AUX8_ATI 0x981F
398 #define GLX_AUX9_ATI 0x9820
399 #define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821
400 #define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822
404 #if 0 /* not used yet */
405 static int ConvertAttribGLXtoWGL(const int* iWGLAttr, int* oGLXAttr) {
407 FIXME("not yet implemented!\n");
412 static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, Wine_GLPBuffer* pbuf) {
417 int wantColorBits = 0;
420 while (0 != iWGLAttr[cur]) {
421 TRACE("pAttr[%d] = %x\n", cur, iWGLAttr[cur]);
423 switch (iWGLAttr[cur]) {
424 case WGL_COLOR_BITS_ARB:
425 pop = iWGLAttr[++cur];
426 wantColorBits = pop; /** see end */
428 case WGL_BLUE_BITS_ARB:
429 pop = iWGLAttr[++cur];
430 PUSH2(oGLXAttr, GLX_BLUE_SIZE, pop);
431 TRACE("pAttr[%d] = GLX_BLUE_SIZE: %d\n", cur, pop);
433 case WGL_RED_BITS_ARB:
434 pop = iWGLAttr[++cur];
435 PUSH2(oGLXAttr, GLX_RED_SIZE, pop);
436 TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur, pop);
438 case WGL_GREEN_BITS_ARB:
439 pop = iWGLAttr[++cur];
440 PUSH2(oGLXAttr, GLX_GREEN_SIZE, pop);
441 TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur, pop);
443 case WGL_ALPHA_BITS_ARB:
444 pop = iWGLAttr[++cur];
446 PUSH2(oGLXAttr, GLX_ALPHA_SIZE, pop);
447 TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur, pop);
449 case WGL_DEPTH_BITS_ARB:
450 pop = iWGLAttr[++cur];
451 PUSH2(oGLXAttr, GLX_DEPTH_SIZE, pop);
452 TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur, pop);
454 case WGL_STENCIL_BITS_ARB:
455 pop = iWGLAttr[++cur];
456 PUSH2(oGLXAttr, GLX_STENCIL_SIZE, pop);
457 TRACE("pAttr[%d] = GLX_STENCIL_SIZE: %d\n", cur, pop);
459 case WGL_DOUBLE_BUFFER_ARB:
460 pop = iWGLAttr[++cur];
461 PUSH2(oGLXAttr, GLX_DOUBLEBUFFER, pop);
462 TRACE("pAttr[%d] = GLX_DOUBLEBUFFER: %d\n", cur, pop);
465 case WGL_PIXEL_TYPE_ARB:
466 pop = iWGLAttr[++cur];
468 case WGL_TYPE_COLORINDEX_ARB: pop = GLX_COLOR_INDEX_BIT; isColor = 1; break ;
469 case WGL_TYPE_RGBA_ARB: pop = GLX_RGBA_BIT; break ;
470 case WGL_TYPE_RGBA_FLOAT_ATI: pop = GLX_RGBA_FLOAT_ATI_BIT; break ;
472 ERR("unexpected PixelType(%x)\n", pop);
475 PUSH2(oGLXAttr, GLX_RENDER_TYPE, pop);
476 TRACE("pAttr[%d] = GLX_RENDER_TYPE: %d\n", cur, pop);
479 case WGL_SUPPORT_GDI_ARB:
480 pop = iWGLAttr[++cur];
481 PUSH2(oGLXAttr, GLX_X_RENDERABLE, pop);
482 TRACE("pAttr[%d] = GLX_RENDERABLE: %d\n", cur, pop);
485 case WGL_DRAW_TO_BITMAP_ARB:
486 pop = iWGLAttr[++cur];
487 PUSH2(oGLXAttr, GLX_X_RENDERABLE, pop);
488 TRACE("pAttr[%d] = GLX_RENDERABLE: %d\n", cur, pop);
490 PUSH2(oGLXAttr, GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT);
491 TRACE("pAttr[%d] = GLX_DRAWABLE_TYPE: GLX_PIXMAP_BIT\n", cur);
495 case WGL_DRAW_TO_WINDOW_ARB:
496 pop = iWGLAttr[++cur];
498 PUSH2(oGLXAttr, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT);
499 TRACE("pAttr[%d] = GLX_DRAWABLE_TYPE: GLX_WINDOW_BIT\n", cur);
503 case WGL_DRAW_TO_PBUFFER_ARB:
504 pop = iWGLAttr[++cur];
505 PUSH2(oGLXAttr, GLX_X_RENDERABLE, pop);
506 TRACE("pAttr[%d] = GLX_RENDERABLE: %d\n", cur, pop);
508 PUSH2(oGLXAttr, GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
509 TRACE("pAttr[%d] = GLX_DRAWABLE_TYPE: GLX_PBUFFER_BIT\n", cur);
513 case WGL_ACCELERATION_ARB:
514 case WGL_SUPPORT_OPENGL_ARB:
515 pop = iWGLAttr[++cur];
516 /** nothing to do, if we are here, supposing support Accelerated OpenGL */
517 TRACE("pAttr[%d] = WGL_SUPPORT_OPENGL_ARB: %d\n", cur, pop);
520 case WGL_PBUFFER_LARGEST_ARB:
521 pop = iWGLAttr[++cur];
522 PUSH2(oGLXAttr, GLX_LARGEST_PBUFFER, pop);
523 TRACE("pAttr[%d] = GLX_LARGEST_PBUFFER: %x\n", cur, pop);
526 case WGL_SAMPLE_BUFFERS_ARB:
527 pop = iWGLAttr[++cur];
528 PUSH2(oGLXAttr, GLX_SAMPLE_BUFFERS_ARB, pop);
529 TRACE("pAttr[%d] = GLX_SAMPLE_BUFFERS_ARB: %x\n", cur, pop);
532 case WGL_SAMPLES_ARB:
533 pop = iWGLAttr[++cur];
534 PUSH2(oGLXAttr, GLX_SAMPLES_ARB, pop);
535 TRACE("pAttr[%d] = GLX_SAMPLES_ARB: %x\n", cur, pop);
538 case WGL_TEXTURE_FORMAT_ARB:
539 case WGL_TEXTURE_TARGET_ARB:
540 case WGL_MIPMAP_TEXTURE_ARB:
541 TRACE("WGL_render_texture Attributes: %x as %x\n", iWGLAttr[cur], iWGLAttr[cur + 1]);
542 pop = iWGLAttr[++cur];
544 ERR("trying to use GLX_Pbuffer Attributes without Pbuffer (was %x)\n", iWGLAttr[cur]);
546 if (use_render_texture_ati) {
547 /** nothing to do here */
549 else if (!use_render_texture_emulation) {
550 if (WGL_NO_TEXTURE_ARB != pop) {
551 ERR("trying to use WGL_render_texture Attributes without support (was %x)\n", iWGLAttr[cur]);
552 return -1; /** error: don't support it */
554 PUSH2(oGLXAttr, GLX_X_RENDERABLE, pop);
555 PUSH2(oGLXAttr, GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT);
560 case WGL_BIND_TO_TEXTURE_RGB_ARB:
561 case WGL_BIND_TO_TEXTURE_RGBA_ARB:
562 pop = iWGLAttr[++cur];
563 /** cannot be converted, see direct handling on
564 * - wglGetPixelFormatAttribivARB
565 * TODO: wglChoosePixelFormat
570 FIXME("unsupported %x WGL Attribute\n", iWGLAttr[cur]);
577 * Trick as WGL_COLOR_BITS_ARB != GLX_BUFFER_SIZE
578 * WGL_COLOR_BITS_ARB + WGL_ALPHA_BITS_ARB == GLX_BUFFER_SIZE
581 * The number of color bitplanes in each color buffer. For RGBA
582 * pixel types, it is the size of the color buffer, excluding the
583 * alpha bitplanes. For color-index pixels, it is the size of the
584 * color index buffer.
587 * This attribute defines the number of bits per color buffer.
588 * For GLX FBConfigs that correspond to a PseudoColor or StaticColor visual,
589 * this is equal to the depth value reported in the X11 visual.
590 * For GLX FBConfigs that correspond to TrueColor or DirectColor visual,
591 * this is the sum of GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_BLUE_SIZE, and GLX_ALPHA_SIZE.
594 if (0 < wantColorBits) {
596 wantColorBits += sz_alpha;
598 if (32 < wantColorBits) {
599 ERR("buggy %d GLX_BUFFER_SIZE default to 32\n", wantColorBits);
602 PUSH2(oGLXAttr, GLX_BUFFER_SIZE, wantColorBits);
603 TRACE("pAttr[%d] = WGL_COLOR_BITS_ARB: %d\n", cur, wantColorBits);
609 GLboolean WINAPI wglGetPixelFormatAttribivARB(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues)
611 Display* display = get_display( hdc );
613 GLXFBConfig* cfgs = NULL;
614 GLXFBConfig curCfg = NULL;
620 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues);
622 if (0 < iLayerPlane) {
623 FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane);
627 cfgs = glXGetFBConfigs(display, DefaultScreen(display), &nCfgs);
629 ERR("no FB Configs found for display(%p)\n", display);
633 for (i = 0; i < nAttributes; ++i) {
634 const int curWGLAttr = piAttributes[i];
635 TRACE("pAttr[%d] = %x\n", i, curWGLAttr);
637 switch (curWGLAttr) {
638 case WGL_NUMBER_PIXEL_FORMATS_ARB:
642 case WGL_SUPPORT_OPENGL_ARB:
643 piValues[i] = GL_TRUE;
646 case WGL_ACCELERATION_ARB:
647 curGLXAttr = GLX_CONFIG_CAVEAT;
648 if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
649 curCfg = cfgs[iPixelFormat - 1];
650 hTest = glXGetFBConfigAttrib(display, curCfg, curGLXAttr, &tmp);
651 if (hTest) goto get_error;
653 case GLX_NONE: piValues[i] = WGL_FULL_ACCELERATION_ARB; break;
654 case GLX_SLOW_CONFIG: piValues[i] = WGL_NO_ACCELERATION_ARB; break;
655 case GLX_NON_CONFORMANT_CONFIG: piValues[i] = WGL_FULL_ACCELERATION_ARB; break;
657 ERR("unexpected Config Caveat(%x)\n", tmp);
658 piValues[i] = WGL_NO_ACCELERATION_ARB;
662 case WGL_TRANSPARENT_ARB:
663 curGLXAttr = GLX_TRANSPARENT_TYPE;
664 if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
665 curCfg = cfgs[iPixelFormat - 1];
666 hTest = glXGetFBConfigAttrib(display, curCfg, curGLXAttr, &tmp);
667 if (hTest) goto get_error;
668 piValues[i] = GL_FALSE;
669 if (GLX_NONE != tmp) piValues[i] = GL_TRUE;
672 case WGL_PIXEL_TYPE_ARB:
673 curGLXAttr = GLX_RENDER_TYPE;
674 if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
675 curCfg = cfgs[iPixelFormat - 1];
676 hTest = glXGetFBConfigAttrib(display, curCfg, curGLXAttr, &tmp);
677 if (hTest) goto get_error;
678 TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp);
679 if (tmp & GLX_RGBA_BIT) { piValues[i] = WGL_TYPE_RGBA_ARB; }
680 else if (tmp & GLX_COLOR_INDEX_BIT) { piValues[i] = WGL_TYPE_COLORINDEX_ARB; }
681 else if (tmp & GLX_RGBA_FLOAT_BIT) { piValues[i] = WGL_TYPE_RGBA_FLOAT_ATI; }
682 else if (tmp & GLX_RGBA_FLOAT_ATI_BIT) { piValues[i] = WGL_TYPE_RGBA_FLOAT_ATI; }
684 ERR("unexpected RenderType(%x)\n", tmp);
685 piValues[i] = WGL_TYPE_RGBA_ARB;
689 case WGL_COLOR_BITS_ARB:
690 /** see ConvertAttribWGLtoGLX for explain */
691 if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
692 curCfg = cfgs[iPixelFormat - 1];
693 hTest = glXGetFBConfigAttrib(display, curCfg, GLX_BUFFER_SIZE, piValues + i);
694 if (hTest) goto get_error;
695 TRACE("WGL_COLOR_BITS_ARB: GLX_BUFFER_SIZE = %d\n", piValues[i]);
696 hTest = glXGetFBConfigAttrib(display, curCfg, GLX_ALPHA_SIZE, &tmp);
697 if (hTest) goto get_error;
698 TRACE("WGL_COLOR_BITS_ARB: GLX_ALPHA_SIZE = %d\n", tmp);
699 piValues[i] = piValues[i] - tmp;
702 case WGL_BIND_TO_TEXTURE_RGB_ARB:
703 if (use_render_texture_ati) {
704 curGLXAttr = GLX_BIND_TO_TEXTURE_RGB_ATI;
707 case WGL_BIND_TO_TEXTURE_RGBA_ARB:
708 if (use_render_texture_ati) {
709 curGLXAttr = GLX_BIND_TO_TEXTURE_RGBA_ATI;
712 if (!use_render_texture_emulation) {
713 piValues[i] = GL_FALSE;
716 curGLXAttr = GLX_RENDER_TYPE;
717 if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
718 curCfg = cfgs[iPixelFormat - 1];
719 hTest = glXGetFBConfigAttrib(display, curCfg, curGLXAttr, &tmp);
720 if (hTest) goto get_error;
721 if (GLX_COLOR_INDEX_BIT == tmp) {
722 piValues[i] = GL_FALSE;
725 hTest = glXGetFBConfigAttrib(display, curCfg, GLX_DRAWABLE_TYPE, &tmp);
726 if (hTest) goto get_error;
727 piValues[i] = (tmp & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE;
730 case WGL_BLUE_BITS_ARB:
731 curGLXAttr = GLX_BLUE_SIZE;
733 case WGL_RED_BITS_ARB:
734 curGLXAttr = GLX_RED_SIZE;
736 case WGL_GREEN_BITS_ARB:
737 curGLXAttr = GLX_GREEN_SIZE;
739 case WGL_ALPHA_BITS_ARB:
740 curGLXAttr = GLX_ALPHA_SIZE;
742 case WGL_DEPTH_BITS_ARB:
743 curGLXAttr = GLX_DEPTH_SIZE;
745 case WGL_STENCIL_BITS_ARB:
746 curGLXAttr = GLX_STENCIL_SIZE;
748 case WGL_DOUBLE_BUFFER_ARB:
749 curGLXAttr = GLX_DOUBLEBUFFER;
752 curGLXAttr = GLX_STEREO;
754 case WGL_AUX_BUFFERS_ARB:
755 curGLXAttr = GLX_AUX_BUFFERS;
758 case WGL_SUPPORT_GDI_ARB:
759 case WGL_DRAW_TO_WINDOW_ARB:
760 case WGL_DRAW_TO_BITMAP_ARB:
761 case WGL_DRAW_TO_PBUFFER_ARB:
762 curGLXAttr = GLX_X_RENDERABLE;
765 case WGL_PBUFFER_LARGEST_ARB:
766 curGLXAttr = GLX_LARGEST_PBUFFER;
769 case WGL_SAMPLE_BUFFERS_ARB:
770 curGLXAttr = GLX_SAMPLE_BUFFERS_ARB;
773 case WGL_SAMPLES_ARB:
774 curGLXAttr = GLX_SAMPLES_ARB;
778 FIXME("unsupported %x WGL Attribute\n", curWGLAttr);
781 if (0 != curGLXAttr) {
782 if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
783 curCfg = cfgs[iPixelFormat - 1];
784 hTest = glXGetFBConfigAttrib(display, curCfg, curGLXAttr, piValues + i);
785 if (hTest) goto get_error;
787 piValues[i] = GL_FALSE;
794 ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc, curGLXAttr);
799 ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nCfgs);
804 GLboolean WINAPI wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues)
806 FIXME("(%p, %d, %d, %d, %p, %p): stub\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues);
810 * http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.aix.doc/libs/openglrf/glXChooseFBConfig.htm
812 GLboolean WINAPI wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats)
814 Display* display = get_display( hdc );
819 GLXFBConfig* cfgs = NULL;
824 GLXFBConfig* cfgs_fmt = NULL;
831 TRACE("(%p, %p, %p, %d, %p, %p): hackish\n", hdc, piAttribIList, pfAttribFList, nMaxFormats, piFormats, nNumFormats);
832 if (NULL != pfAttribFList) {
833 FIXME("unused pfAttribFList\n");
836 nAttribs = ConvertAttribWGLtoGLX(piAttribIList, attribs, NULL);
837 if (-1 == nAttribs) {
838 WARN("Cannot convert WGL to GLX attributes\n");
841 PUSH1(attribs, None);
843 cfgs = glXChooseFBConfig(display, DefaultScreen(display), attribs, &nCfgs);
845 WARN("Compatible Pixel Format not found\n");
849 cfgs_fmt = glXGetFBConfigs(display, DefaultScreen(display), &nCfgs_fmt);
850 if (NULL == cfgs_fmt) {
851 ERR("Failed to get All FB Configs\n");
856 for (it = 0; it < nMaxFormats && it < nCfgs; ++it) {
857 gl_test = glXGetFBConfigAttrib(display, cfgs[it], GLX_FBCONFIG_ID, &fmt_id);
859 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
862 for (it_fmt = 0; it_fmt < nCfgs_fmt; ++it_fmt) {
863 gl_test = glXGetFBConfigAttrib(display, cfgs_fmt[it_fmt], GLX_FBCONFIG_ID, &tmp_fmt_id);
865 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
868 if (fmt_id == tmp_fmt_id) {
870 piFormats[pfmt_it] = it_fmt + 1;
872 glXGetFBConfigAttrib(display, cfgs_fmt[it_fmt], GLX_ALPHA_SIZE, &tmp);
873 TRACE("ALPHA_SIZE of FBCONFIG_ID(%d/%d) found as '%d'\n", it_fmt + 1, nCfgs_fmt, tmp);
877 if (it_fmt == nCfgs_fmt) {
878 ERR("Failed to get valid fmt for %d. Try next.\n", it);
881 TRACE("at %d/%d found FBCONFIG_ID(%d/%d)\n", it + 1, nCfgs, piFormats[it], nCfgs_fmt);
884 *nNumFormats = pfmt_it;
891 #define HPBUFFERARB void *
892 HPBUFFERARB WINAPI wglCreatePbufferARB(HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList)
894 Wine_GLPBuffer* object = NULL;
895 Display* display = get_display( hdc );
896 GLXFBConfig* cfgs = NULL;
899 unsigned nAttribs = 0;
901 TRACE("(%p, %d, %d, %d, %p)\n", hdc, iPixelFormat, iWidth, iHeight, piAttribList);
903 if (0 >= iPixelFormat) {
904 ERR("(%p): unexpected iPixelFormat(%d) <= 0, returns NULL\n", hdc, iPixelFormat);
905 SetLastError(ERROR_INVALID_PIXEL_FORMAT);
906 return NULL; /* unespected error */
909 cfgs = glXGetFBConfigs(display, DefaultScreen(display), &nCfgs);
911 if (NULL == cfgs || 0 == nCfgs) {
912 ERR("(%p): Cannot get FB Configs for iPixelFormat(%d), returns NULL\n", hdc, iPixelFormat);
913 SetLastError(ERROR_INVALID_PIXEL_FORMAT);
914 return NULL; /* unespected error */
916 if (nCfgs < iPixelFormat) {
917 ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, iPixelFormat, nCfgs);
918 SetLastError(ERROR_INVALID_PIXEL_FORMAT);
919 goto create_failed; /* unespected error */
922 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Wine_GLPBuffer));
923 if (NULL == object) {
924 SetLastError(ERROR_NO_SYSTEM_RESOURCES);
925 goto create_failed; /* unespected error */
928 object->display = display;
929 object->width = iWidth;
930 object->height = iHeight;
931 object->pixelFormat = iPixelFormat;
933 nAttribs = ConvertAttribWGLtoGLX(piAttribList, attribs, object);
934 if (-1 == nAttribs) {
935 WARN("Cannot convert WGL to GLX attributes\n");
938 PUSH2(attribs, GLX_PBUFFER_WIDTH, iWidth);
939 PUSH2(attribs, GLX_PBUFFER_HEIGHT, iHeight);
941 while (0 != *piAttribList) {
943 switch (*piAttribList) {
944 case WGL_TEXTURE_FORMAT_ARB: {
946 attr_v = *piAttribList;
947 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_FORMAT_ARB as %x\n", attr_v);
948 if (use_render_texture_ati) {
951 case WGL_NO_TEXTURE_ARB: type = GLX_NO_TEXTURE_ATI; break ;
952 case WGL_TEXTURE_RGB_ARB: type = GLX_TEXTURE_RGB_ATI; break ;
953 case WGL_TEXTURE_RGBA_ARB: type = GLX_TEXTURE_RGBA_ATI; break ;
955 SetLastError(ERROR_INVALID_DATA);
958 object->use_render_texture = 1;
959 PUSH2(attribs, GLX_TEXTURE_FORMAT_ATI, type);
961 if (WGL_NO_TEXTURE_ARB == attr_v) {
962 object->use_render_texture = 0;
964 if (!use_render_texture_emulation) {
965 SetLastError(ERROR_INVALID_DATA);
969 case WGL_TEXTURE_RGB_ARB:
970 object->use_render_texture = GL_RGB;
972 case WGL_TEXTURE_RGBA_ARB:
973 object->use_render_texture = GL_RGBA;
976 SetLastError(ERROR_INVALID_DATA);
984 case WGL_TEXTURE_TARGET_ARB: {
986 attr_v = *piAttribList;
987 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_TARGET_ARB as %x\n", attr_v);
988 if (use_render_texture_ati) {
991 case WGL_NO_TEXTURE_ARB: type = GLX_NO_TEXTURE_ATI; break ;
992 case WGL_TEXTURE_CUBE_MAP_ARB: type = GLX_TEXTURE_CUBE_MAP_ATI; break ;
993 case WGL_TEXTURE_1D_ARB: type = GLX_TEXTURE_1D_ATI; break ;
994 case WGL_TEXTURE_2D_ARB: type = GLX_TEXTURE_2D_ATI; break ;
996 SetLastError(ERROR_INVALID_DATA);
999 PUSH2(attribs, GLX_TEXTURE_TARGET_ATI, type);
1001 if (WGL_NO_TEXTURE_ARB == attr_v) {
1002 object->texture_target = 0;
1004 if (!use_render_texture_emulation) {
1005 SetLastError(ERROR_INVALID_DATA);
1009 case WGL_TEXTURE_CUBE_MAP_ARB: {
1010 if (iWidth != iHeight) {
1011 SetLastError(ERROR_INVALID_DATA);
1014 object->texture_target = GL_TEXTURE_CUBE_MAP;
1015 object->texture_bind_target = GL_TEXTURE_CUBE_MAP;
1018 case WGL_TEXTURE_1D_ARB: {
1020 SetLastError(ERROR_INVALID_DATA);
1023 object->texture_target = GL_TEXTURE_1D;
1024 object->texture_bind_target = GL_TEXTURE_1D;
1027 case WGL_TEXTURE_2D_ARB: {
1028 object->texture_target = GL_TEXTURE_2D;
1029 object->texture_bind_target = GL_TEXTURE_2D;
1033 SetLastError(ERROR_INVALID_DATA);
1041 case WGL_MIPMAP_TEXTURE_ARB: {
1043 attr_v = *piAttribList;
1044 TRACE("WGL_render_texture Attribute: WGL_MIPMAP_TEXTURE_ARB as %x\n", attr_v);
1045 if (use_render_texture_ati) {
1046 PUSH2(attribs, GLX_MIPMAP_TEXTURE_ATI, attr_v);
1048 if (!use_render_texture_emulation) {
1049 SetLastError(ERROR_INVALID_DATA);
1054 SetLastError(ERROR_INVALID_DATA);
1065 PUSH1(attribs, None);
1067 object->drawable = glXCreatePbuffer(display, cfgs[iPixelFormat - 1], attribs);
1068 TRACE("new Pbuffer drawable as %p\n", (void*) object->drawable);
1069 if (!object->drawable) {
1070 SetLastError(ERROR_NO_SYSTEM_RESOURCES);
1071 goto create_failed; /* unespected error */
1073 TRACE("->(%p)\n", object);
1077 return (HPBUFFERARB) object;
1080 if (NULL != cfgs) XFree(cfgs);
1081 if (NULL != object) HeapFree(GetProcessHeap(), 0, object);
1082 TRACE("->(FAILED)\n");
1083 return (HPBUFFERARB) NULL;
1086 HDC WINAPI wglGetPbufferDCARB(HPBUFFERARB hPbuffer)
1088 Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
1090 if (NULL == object) {
1091 SetLastError(ERROR_INVALID_HANDLE);
1094 hDC = CreateCompatibleDC(object->hdc);
1095 SetPixelFormat(hDC, object->pixelFormat, NULL);
1096 set_drawable(hDC, object->drawable); /* works ?? */
1097 TRACE("(%p)->(%p)\n", hPbuffer, hDC);
1101 int WINAPI wglReleasePbufferDCARB(HPBUFFERARB hPbuffer, HDC hdc)
1103 TRACE("(%p, %p)\n", hPbuffer, hdc);
1108 GLboolean WINAPI wglDestroyPbufferARB(HPBUFFERARB hPbuffer)
1110 Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
1111 TRACE("(%p)\n", hPbuffer);
1112 if (NULL == object) {
1113 SetLastError(ERROR_INVALID_HANDLE);
1116 glXDestroyPbuffer(object->display, object->drawable);
1117 HeapFree(GetProcessHeap(), 0, object);
1121 GLboolean WINAPI wglQueryPbufferARB(HPBUFFERARB hPbuffer, int iAttribute, int *piValue)
1123 Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
1124 TRACE("(%p, 0x%x, %p)\n", hPbuffer, iAttribute, piValue);
1125 if (NULL == object) {
1126 SetLastError(ERROR_INVALID_HANDLE);
1129 switch (iAttribute) {
1130 case WGL_PBUFFER_WIDTH_ARB:
1131 glXQueryDrawable(object->display, object->drawable, GLX_WIDTH, (unsigned int*) piValue);
1133 case WGL_PBUFFER_HEIGHT_ARB:
1134 glXQueryDrawable(object->display, object->drawable, GLX_HEIGHT, (unsigned int*) piValue);
1137 case WGL_PBUFFER_LOST_ARB:
1138 FIXME("unsupported WGL_PBUFFER_LOST_ARB (need glXSelectEvent/GLX_DAMAGED work)\n");
1141 case WGL_TEXTURE_FORMAT_ARB:
1142 if (use_render_texture_ati) {
1144 int type = WGL_NO_TEXTURE_ARB;
1145 glXQueryDrawable(object->display, object->drawable, GLX_TEXTURE_FORMAT_ATI, &tmp);
1147 case GLX_NO_TEXTURE_ATI: type = WGL_NO_TEXTURE_ARB; break ;
1148 case GLX_TEXTURE_RGB_ATI: type = WGL_TEXTURE_RGB_ARB; break ;
1149 case GLX_TEXTURE_RGBA_ATI: type = WGL_TEXTURE_RGBA_ARB; break ;
1153 if (!object->use_render_texture) {
1154 *piValue = WGL_NO_TEXTURE_ARB;
1156 if (!use_render_texture_emulation) {
1157 SetLastError(ERROR_INVALID_HANDLE);
1160 if (GL_RGBA == object->use_render_texture) {
1161 *piValue = WGL_TEXTURE_RGBA_ARB;
1163 *piValue = WGL_TEXTURE_RGB_ARB;
1169 case WGL_TEXTURE_TARGET_ARB:
1170 if (use_render_texture_ati) {
1172 int type = WGL_NO_TEXTURE_ARB;
1173 glXQueryDrawable(object->display, object->drawable, GLX_TEXTURE_TARGET_ATI, &tmp);
1175 case GLX_NO_TEXTURE_ATI: type = WGL_NO_TEXTURE_ARB; break ;
1176 case GLX_TEXTURE_CUBE_MAP_ATI: type = WGL_TEXTURE_CUBE_MAP_ARB; break ;
1177 case GLX_TEXTURE_1D_ATI: type = WGL_TEXTURE_1D_ARB; break ;
1178 case GLX_TEXTURE_2D_ATI: type = WGL_TEXTURE_2D_ARB; break ;
1182 if (!object->texture_target) {
1183 *piValue = WGL_NO_TEXTURE_ARB;
1185 if (!use_render_texture_emulation) {
1186 SetLastError(ERROR_INVALID_DATA);
1189 switch (object->texture_target) {
1190 case GL_TEXTURE_1D: *piValue = WGL_TEXTURE_CUBE_MAP_ARB; break;
1191 case GL_TEXTURE_2D: *piValue = WGL_TEXTURE_1D_ARB; break;
1192 case GL_TEXTURE_CUBE_MAP: *piValue = WGL_TEXTURE_2D_ARB; break;
1198 case WGL_MIPMAP_TEXTURE_ARB:
1199 if (use_render_texture_ati) {
1200 glXQueryDrawable(object->display, object->drawable, GLX_MIPMAP_TEXTURE_ATI, (unsigned int*) piValue);
1202 *piValue = GL_FALSE; /** don't support that */
1203 FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute);
1208 FIXME("unexpected attribute %x\n", iAttribute);
1215 GLboolean WINAPI wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuffer)
1217 Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
1218 TRACE("(%p, %d)\n", hPbuffer, iBuffer);
1219 if (NULL == object) {
1220 SetLastError(ERROR_INVALID_HANDLE);
1223 if (!object->use_render_texture) {
1224 SetLastError(ERROR_INVALID_HANDLE);
1227 if (!use_render_texture_ati && 1 == use_render_texture_emulation) {
1229 GLint prev_binded_tex;
1230 glGetIntegerv(object->texture_target, &prev_binded_tex);
1231 if (NULL == object->render_ctx) {
1232 object->render_hdc = wglGetPbufferDCARB(hPbuffer);
1233 object->render_ctx = wglCreateContext(object->render_hdc);
1236 object->prev_hdc = wglGetCurrentDC();
1237 object->prev_ctx = wglGetCurrentContext();
1238 wglMakeCurrent(object->render_hdc, object->render_ctx);
1241 glBindTexture(object->texture_target, object->texture);
1242 if (GL_RGBA == object->use_render_texture) {
1243 glTexImage2D(object->texture_target, 0, GL_RGBA8, object->width, object->height, 0, GL_RGBA, GL_FLOAT, NULL);
1245 glTexImage2D(object->texture_target, 0, GL_RGB8, object->width, object->height, 0, GL_RGB, GL_FLOAT, NULL);
1249 object->texture = prev_binded_tex;
1252 if (NULL != p_glXBindTexImageARB) {
1253 return p_glXBindTexImageARB(object->display, object->drawable, iBuffer);
1258 GLboolean WINAPI wglReleaseTexImageARB(HPBUFFERARB hPbuffer, int iBuffer)
1260 Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
1261 TRACE("(%p, %d)\n", hPbuffer, iBuffer);
1262 if (NULL == object) {
1263 SetLastError(ERROR_INVALID_HANDLE);
1266 if (!object->use_render_texture) {
1267 SetLastError(ERROR_INVALID_HANDLE);
1270 if (!use_render_texture_ati && 1 == use_render_texture_emulation) {
1272 GLint prev_binded_tex;
1273 glGetIntegerv(object->texture_target, &prev_binded_tex);
1274 if (GL_TEXTURE_1D == object->texture_target) {
1275 glCopyTexSubImage1D(object->texture_target, object->texture_level, 0, 0, 0, object->width);
1277 glCopyTexSubImage2D(object->texture_target, object->texture_level, 0, 0, 0, 0, object->width, object->height);
1279 glBindTexture(object->texture_target, prev_binded_tex);
1280 SwapBuffers(object->render_hdc);
1282 glBindTexture(object->texture_target, object->texture);
1283 if (GL_TEXTURE_1D == object->texture_target) {
1284 glCopyTexSubImage1D(object->texture_target, object->texture_level, 0, 0, 0, object->width);
1286 glCopyTexSubImage2D(object->texture_target, object->texture_level, 0, 0, 0, 0, object->width, object->height);
1289 wglMakeCurrent(object->prev_hdc, object->prev_ctx);
1292 if (NULL != p_glXReleaseTexImageARB) {
1293 return p_glXReleaseTexImageARB(object->display, object->drawable, iBuffer);
1298 GLboolean WINAPI wglSetPbufferAttribARB(HPBUFFERARB hPbuffer, const int *piAttribList)
1300 Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
1301 WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer, piAttribList);
1302 if (NULL == object) {
1303 SetLastError(ERROR_INVALID_HANDLE);
1306 if (!object->use_render_texture) {
1307 SetLastError(ERROR_INVALID_HANDLE);
1310 if (!use_render_texture_ati && 1 == use_render_texture_emulation) {
1313 if (NULL != p_glXDrawableAttribARB) {
1314 if (use_render_texture_ati) {
1315 FIXME("Need conversion for GLX_ATI_render_texture\n");
1317 return p_glXDrawableAttribARB(object->display, object->drawable, piAttribList);
1322 static const struct {
1324 BOOL (*query_function)(glXGetProcAddressARB_t proc, const char *gl_version, const char *gl_extensions,
1325 const char *glx_version, const char *glx_extensions,
1326 const char *server_glx_extensions, const char *client_glx_extensions);
1327 } extension_list[] = {
1328 { "WGL_ARB_make_current_read", query_function_make_current_read },
1329 { "WGL_ARB_multisample", query_function_multisample },
1330 { "WGL_ARB_pbuffer", query_function_pbuffer },
1331 { "WGL_ARB_pixel_format" , query_function_pixel_format },
1332 { "WGL_ARB_render_texture", query_function_render_texture },
1333 { "WGL_EXT_swap_control", query_function_swap_control }
1336 /* Used to initialize the WGL extension string at DLL loading */
1337 void wgl_ext_initialize_extensions(Display *display, int screen, glXGetProcAddressARB_t proc, const char* disabled_extensions)
1339 int size = strlen(WGL_extensions_base);
1340 const char *glx_extensions = glXQueryExtensionsString(display, screen);
1341 const char *server_glx_extensions = glXQueryServerString(display, screen, GLX_EXTENSIONS);
1342 const char *client_glx_extensions = glXGetClientString(display, GLX_EXTENSIONS);
1343 const char *gl_extensions = (const char *) glGetString(GL_EXTENSIONS);
1344 const char *gl_version = (const char *) glGetString(GL_VERSION);
1345 const char *server_glx_version = glXQueryServerString(display, screen, GLX_VERSION);
1346 const char *glx_version = glXGetClientString(display, GLX_VERSION);
1349 TRACE("GL version : %s.\n", debugstr_a(gl_version));
1350 TRACE("GL exts : %s.\n", debugstr_a(gl_extensions));
1351 TRACE("GLX exts : %s.\n", debugstr_a(glx_extensions));
1352 TRACE("Server GLX version : %s.\n", debugstr_a(server_glx_version));
1353 TRACE("Client GLX version : %s.\n", debugstr_a(glx_version));
1354 TRACE("Server GLX exts : %s.\n", debugstr_a(server_glx_extensions));
1355 TRACE("Client GLX exts : %s.\n", debugstr_a(client_glx_extensions));
1357 for (i = 0; i < (sizeof(extension_list) / sizeof(extension_list[0])); i++) {
1358 if (strstr(disabled_extensions, extension_list[i].name)) continue ; /* disabled by config, next */
1359 if (extension_list[i].query_function(proc,
1360 gl_version, gl_extensions,
1361 glx_version, glx_extensions,
1362 server_glx_extensions, client_glx_extensions)) {
1363 size += strlen(extension_list[i].name) + 1;
1367 /* For the moment, only 'base' extensions are supported. */
1368 WGL_extensions = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + 1);
1369 if (WGL_extensions == NULL) {
1370 WGL_extensions = (char *) WGL_extensions_base;
1372 strcpy(WGL_extensions, WGL_extensions_base);
1373 for (i = 0; i < (sizeof(extension_list) / sizeof(extension_list[0])); i++) {
1374 if (strstr(disabled_extensions, extension_list[i].name)) continue ; /* disabled by config, next */
1375 if (extension_list[i].query_function(proc,
1376 gl_version, gl_extensions,
1377 glx_version, glx_extensions,
1378 server_glx_extensions, client_glx_extensions)) {
1379 strcat(WGL_extensions, " ");
1380 strcat(WGL_extensions, extension_list[i].name);
1385 TRACE("Supporting following WGL extensions : %s.\n", debugstr_a(WGL_extensions));
1388 void wgl_ext_finalize_extensions(void)
1390 if (WGL_extensions != WGL_extensions_base) {
1391 HeapFree(GetProcessHeap(), 0, WGL_extensions);
1396 /* these are located in wgl.c for convenience of implementation */
1397 BOOL WINAPI wglMakeContextCurrentARB(HDC,HDC,HGLRC);
1398 HDC WINAPI wglGetCurrentReadDCARB(void);
1402 * Putting this at the end to prevent having to write the prototypes :-)
1404 * @WARNING: this list must be ordered by name
1406 * @TODO: real handle caps on providing some func_init functions (third param, ex: to check extensions)
1408 WGL_extension wgl_extension_registry[] = {
1409 { "wglBindTexImageARB", (void *) wglBindTexImageARB, NULL, NULL},
1410 { "wglChoosePixelFormatARB", (void *) wglChoosePixelFormatARB, NULL, NULL},
1411 { "wglCreatePbufferARB", (void *) wglCreatePbufferARB, NULL, NULL},
1412 { "wglDestroyPbufferARB", (void *) wglDestroyPbufferARB, NULL, NULL},
1413 { "wglGetCurrentReadDCARB", (void *) wglGetCurrentReadDCARB, NULL, NULL},
1414 { "wglGetExtensionsStringARB", (void *) wglGetExtensionsStringARB, NULL, NULL},
1415 { "wglGetExtensionsStringEXT", (void *) wglGetExtensionsStringEXT, NULL, NULL},
1416 { "wglGetPbufferDCARB", (void *) wglGetPbufferDCARB, NULL, NULL},
1417 { "wglGetPixelFormatAttribfvARB", (void *) wglGetPixelFormatAttribfvARB, NULL, NULL},
1418 { "wglGetPixelFormatAttribivARB", (void *) wglGetPixelFormatAttribivARB, NULL, NULL},
1419 { "wglGetSwapIntervalEXT", (void *) wglGetSwapIntervalEXT, NULL, NULL},
1420 { "wglMakeContextCurrentARB", (void *) wglMakeContextCurrentARB, NULL, NULL },
1421 { "wglQueryPbufferARB", (void *) wglQueryPbufferARB, NULL, NULL},
1422 { "wglReleasePbufferDCARB", (void *) wglReleasePbufferDCARB, NULL, NULL},
1423 { "wglReleaseTexImageARB", (void *) wglReleaseTexImageARB, NULL, NULL},
1424 { "wglSetPbufferAttribARB", (void *) wglSetPbufferAttribARB, NULL, NULL},
1425 { "wglSwapIntervalEXT", (void *) wglSwapIntervalEXT, NULL, NULL}
1427 int wgl_extension_registry_size = sizeof(wgl_extension_registry) / sizeof(wgl_extension_registry[0]);