2 * Some tests for OpenGL functions
4 * Copyright (C) 2007-2008 Roderick Colenbrander
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
25 const unsigned char * WINAPI
glGetString(unsigned int);
26 #define GL_VENDOR 0x1F00
27 #define GL_RENDERER 0x1F01
28 #define GL_VERSION 0x1F02
30 #define MAX_FORMATS 256
31 typedef void* HPBUFFERARB
;
33 /* WGL_ARB_create_context */
34 HGLRC (WINAPI
*pwglCreateContextAttribsARB
)(HDC hDC
, HGLRC hShareContext
, const int *attribList
);
36 #define ERROR_INVALID_VERSION_ARB 0x2095
37 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
38 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
39 #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
40 #define WGL_CONTEXT_FLAGS_ARB 0x2094
41 /* Flags for WGL_CONTEXT_FLAGS_ARB */
42 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
43 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
45 /* WGL_ARB_extensions_string */
46 static const char* (WINAPI
*pwglGetExtensionsStringARB
)(HDC
);
47 static int (WINAPI
*pwglReleasePbufferDCARB
)(HPBUFFERARB
, HDC
);
49 /* WGL_ARB_make_current_read */
50 static BOOL (WINAPI
*pwglMakeContextCurrentARB
)(HDC hdraw
, HDC hread
, HGLRC hglrc
);
51 static HDC (WINAPI
*pwglGetCurrentReadDCARB
)();
53 /* WGL_ARB_pixel_format */
54 #define WGL_COLOR_BITS_ARB 0x2014
55 #define WGL_RED_BITS_ARB 0x2015
56 #define WGL_GREEN_BITS_ARB 0x2017
57 #define WGL_BLUE_BITS_ARB 0x2019
58 #define WGL_ALPHA_BITS_ARB 0x201B
59 #define WGL_SUPPORT_GDI_ARB 0x200F
60 #define WGL_DOUBLE_BUFFER_ARB 0x2011
62 static BOOL (WINAPI
*pwglChoosePixelFormatARB
)(HDC
, const int *, const FLOAT
*, UINT
, int *, UINT
*);
63 static BOOL (WINAPI
*pwglGetPixelFormatAttribivARB
)(HDC
, int, int, UINT
, const int *, int *);
66 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D
67 static HPBUFFERARB
* (WINAPI
*pwglCreatePbufferARB
)(HDC
, int, int, int, const int *);
68 static HDC (WINAPI
*pwglGetPbufferDCARB
)(HPBUFFERARB
);
70 static const char* wgl_extensions
= NULL
;
72 static void init_functions(void)
74 #define GET_PROC(func) \
75 p ## func = (void*)wglGetProcAddress(#func); \
77 trace("wglGetProcAddress(%s) failed\n", #func);
79 /* WGL_ARB_create_context */
80 GET_PROC(wglCreateContextAttribsARB
);
82 /* WGL_ARB_extensions_string */
83 GET_PROC(wglGetExtensionsStringARB
)
85 /* WGL_ARB_make_current_read */
86 GET_PROC(wglMakeContextCurrentARB
);
87 GET_PROC(wglGetCurrentReadDCARB
);
89 /* WGL_ARB_pixel_format */
90 GET_PROC(wglChoosePixelFormatARB
)
91 GET_PROC(wglGetPixelFormatAttribivARB
)
94 GET_PROC(wglCreatePbufferARB
)
95 GET_PROC(wglGetPbufferDCARB
)
96 GET_PROC(wglReleasePbufferDCARB
)
101 static void test_pbuffers(HDC hdc
)
103 const int iAttribList
[] = { WGL_DRAW_TO_PBUFFER_ARB
, 1, /* Request pbuffer support */
105 int iFormats
[MAX_FORMATS
];
106 unsigned int nOnscreenFormats
;
107 unsigned int nFormats
;
109 int iPixelFormat
= 0;
111 nOnscreenFormats
= DescribePixelFormat(hdc
, 0, 0, NULL
);
113 /* When you want to render to a pbuffer you need to call wglGetPbufferDCARB which
114 * returns a 'magic' HDC which you can then pass to wglMakeCurrent to switch rendering
115 * to the pbuffer. Below some tests are performed on what happens if you use standard WGL calls
116 * on this 'magic' HDC for both a pixelformat that support onscreen and offscreen rendering
117 * and a pixelformat that's only available for offscreen rendering (this means that only
118 * wglChoosePixelFormatARB and friends know about the format.
120 * The first thing we need are pixelformats with pbuffer capabilities.
122 res
= pwglChoosePixelFormatARB(hdc
, iAttribList
, NULL
, MAX_FORMATS
, iFormats
, &nFormats
);
125 skip("No pbuffer compatible formats found while WGL_ARB_pbuffer is supported\n");
128 trace("nOnscreenFormats: %d\n", nOnscreenFormats
);
129 trace("Total number of pbuffer capable pixelformats: %d\n", nFormats
);
131 /* Try to select an onscreen pixelformat out of the list */
132 for(i
=0; i
< nFormats
; i
++)
134 /* Check if the format is onscreen, if it is choose it */
135 if(iFormats
[i
] <= nOnscreenFormats
)
137 iPixelFormat
= iFormats
[i
];
138 trace("Selected iPixelFormat=%d\n", iPixelFormat
);
143 /* A video driver supports a large number of onscreen and offscreen pixelformats.
144 * The traditional WGL calls only see a subset of the whole pixelformat list. First
145 * of all they only see the onscreen formats (the offscreen formats are at the end of the
146 * pixelformat list) and second extended pixelformat capabilities are hidden from the
147 * standard WGL calls. Only functions that depend on WGL_ARB_pixel_format can see them.
149 * Below we check if the pixelformat is also supported onscreen.
151 if(iPixelFormat
!= 0)
154 HPBUFFERARB pbuffer
= pwglCreatePbufferARB(hdc
, iPixelFormat
, 640 /* width */, 480 /* height */, NULL
);
156 skip("Pbuffer creation failed!\n");
158 /* Test the pixelformat returned by GetPixelFormat on a pbuffer as the behavior is not clear */
159 pbuffer_hdc
= pwglGetPbufferDCARB(pbuffer
);
160 res
= GetPixelFormat(pbuffer_hdc
);
161 ok(res
== iPixelFormat
, "Unexpected iPixelFormat=%d returned by GetPixelFormat for format %d\n", res
, iPixelFormat
);
162 trace("iPixelFormat returned by GetPixelFormat: %d\n", res
);
163 trace("PixelFormat from wglChoosePixelFormatARB: %d\n", iPixelFormat
);
165 pwglReleasePbufferDCARB(pbuffer
, hdc
);
167 else skip("Pbuffer test for onscreen pixelformat skipped as no onscreen format with pbuffer capabilities have been found\n");
169 /* Search for a real offscreen format */
170 for(i
=0, iPixelFormat
=0; i
<nFormats
; i
++)
172 if(iFormats
[i
] > nOnscreenFormats
)
174 iPixelFormat
= iFormats
[i
];
175 trace("Selected iPixelFormat: %d\n", iPixelFormat
);
180 if(iPixelFormat
!= 0)
183 HPBUFFERARB pbuffer
= pwglCreatePbufferARB(hdc
, iPixelFormat
, 640 /* width */, 480 /* height */, NULL
);
185 skip("Pbuffer creation failed!\n");
187 /* Test the pixelformat returned by GetPixelFormat on a pbuffer as the behavior is not clear */
188 pbuffer_hdc
= pwglGetPbufferDCARB(pbuffer
);
189 res
= GetPixelFormat(pbuffer_hdc
);
191 ok(res
== 1, "Unexpected iPixelFormat=%d (1 expected) returned by GetPixelFormat for offscreen format %d\n", res
, iPixelFormat
);
192 trace("iPixelFormat returned by GetPixelFormat: %d\n", res
);
193 trace("PixelFormat from wglChoosePixelFormatARB: %d\n", iPixelFormat
);
194 pwglReleasePbufferDCARB(pbuffer
, hdc
);
196 else skip("Pbuffer test for offscreen pixelformat skipped as no offscreen-only format with pbuffer capabilities has been found\n");
199 static void test_setpixelformat(HDC winhdc
)
206 PIXELFORMATDESCRIPTOR pfd
= {
207 sizeof(PIXELFORMATDESCRIPTOR
),
213 24, /* 24-bit color depth */
214 0, 0, 0, 0, 0, 0, /* color bits */
215 0, /* alpha buffer */
217 0, /* accumulation buffer */
218 0, 0, 0, 0, /* accum bits */
220 0, /* stencil buffer */
221 0, /* auxiliary buffer */
222 PFD_MAIN_PLANE
, /* main layer */
224 0, 0, 0 /* layer masks */
228 ok(hdc
!= 0, "GetDC(0) failed!\n");
230 /* This should pass even on the main device context */
231 pf
= ChoosePixelFormat(hdc
, &pfd
);
232 ok(pf
!= 0, "ChoosePixelFormat failed on main device context\n");
234 /* SetPixelFormat on the main device context 'X root window' should fail,
235 * but some broken drivers allow it
237 res
= SetPixelFormat(hdc
, pf
, &pfd
);
238 trace("SetPixelFormat on main device context %s\n", res
? "succeeded" : "failed");
240 /* Setting the same format that was set on the HDC is allowed; other
242 nCfgs
= DescribePixelFormat(winhdc
, 0, 0, NULL
);
243 pf
= GetPixelFormat(winhdc
);
244 for(i
= 1;i
<= nCfgs
;i
++)
246 int res
= SetPixelFormat(winhdc
, i
, NULL
);
247 if(i
== pf
) ok(res
, "Failed to set the same pixel format\n");
248 else ok(!res
, "Unexpectedly set an alternate pixel format\n");
251 hwnd
= CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW
,
252 10, 10, 200, 200, NULL
, NULL
, NULL
, NULL
);
253 ok(hwnd
!= NULL
, "err: %d\n", GetLastError());
256 HDC hdc
= GetDC( hwnd
);
257 pf
= ChoosePixelFormat( hdc
, &pfd
);
258 ok( pf
!= 0, "ChoosePixelFormat failed\n" );
259 res
= SetPixelFormat( hdc
, pf
, &pfd
);
260 ok( res
!= 0, "SetPixelFormat failed\n" );
261 i
= GetPixelFormat( hdc
);
262 ok( i
== pf
, "GetPixelFormat returned wrong format %d/%d\n", i
, pf
);
263 ReleaseDC( hwnd
, hdc
);
264 hdc
= GetWindowDC( hwnd
);
265 i
= GetPixelFormat( hdc
);
266 ok( i
== pf
, "GetPixelFormat returned wrong format %d/%d\n", i
, pf
);
267 ReleaseDC( hwnd
, hdc
);
268 DestroyWindow( hwnd
);
271 hwnd
= CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW
,
272 10, 10, 200, 200, NULL
, NULL
, NULL
, NULL
);
273 ok(hwnd
!= NULL
, "err: %d\n", GetLastError());
276 HDC hdc
= GetWindowDC( hwnd
);
277 pf
= ChoosePixelFormat( hdc
, &pfd
);
278 ok( pf
!= 0, "ChoosePixelFormat failed\n" );
279 res
= SetPixelFormat( hdc
, pf
, &pfd
);
280 ok( res
!= 0, "SetPixelFormat failed\n" );
281 i
= GetPixelFormat( hdc
);
282 ok( i
== pf
, "GetPixelFormat returned wrong format %d/%d\n", i
, pf
);
283 ReleaseDC( hwnd
, hdc
);
284 DestroyWindow( hwnd
);
288 static void test_sharelists(HDC winhdc
)
290 HGLRC hglrc1
, hglrc2
, hglrc3
;
293 hglrc1
= wglCreateContext(winhdc
);
294 res
= wglShareLists(0, 0);
295 ok(res
== FALSE
, "Sharing display lists for no contexts passed!\n");
297 /* Test 1: Create a context and just share lists without doing anything special */
298 hglrc2
= wglCreateContext(winhdc
);
301 res
= wglShareLists(hglrc1
, hglrc2
);
302 ok(res
, "Sharing of display lists failed\n");
303 wglDeleteContext(hglrc2
);
306 /* Test 2: Share display lists with a 'destination' context which has been made current */
307 hglrc2
= wglCreateContext(winhdc
);
310 res
= wglMakeCurrent(winhdc
, hglrc2
);
311 ok(res
, "Make current failed\n");
312 res
= wglShareLists(hglrc1
, hglrc2
);
313 todo_wine
ok(res
, "Sharing display lists with a destination context which has been made current passed\n");
314 wglMakeCurrent(0, 0);
315 wglDeleteContext(hglrc2
);
318 /* Test 3: Share display lists with a context which already shares display lists with another context.
319 * According to MSDN the second paramater can't share any display lists but some buggy drivers might allow it */
320 hglrc3
= wglCreateContext(winhdc
);
323 res
= wglShareLists(hglrc3
, hglrc1
);
324 ok(res
== FALSE
, "Sharing of display lists failed for a context which already shared lists before\n");
325 wglDeleteContext(hglrc3
);
328 /* Test 4: Share display lists with a 'source' context which has been made current */
329 hglrc2
= wglCreateContext(winhdc
);
332 res
= wglMakeCurrent(winhdc
, hglrc1
);
333 ok(res
, "Make current failed\n");
334 res
= wglShareLists(hglrc1
, hglrc2
);
335 ok(res
, "Sharing display lists with a source context which has been made current passed\n");
336 wglMakeCurrent(0, 0);
337 wglDeleteContext(hglrc2
);
341 static void test_makecurrent(HDC winhdc
)
346 hglrc
= wglCreateContext(winhdc
);
347 ok( hglrc
!= 0, "wglCreateContext failed\n" );
349 ret
= wglMakeCurrent( winhdc
, hglrc
);
350 ok( ret
, "wglMakeCurrent failed\n" );
352 ok( wglGetCurrentContext() == hglrc
, "wrong context\n" );
355 static void test_colorbits(HDC hdc
)
357 const int iAttribList
[] = { WGL_COLOR_BITS_ARB
, WGL_RED_BITS_ARB
, WGL_GREEN_BITS_ARB
,
358 WGL_BLUE_BITS_ARB
, WGL_ALPHA_BITS_ARB
};
359 int iAttribRet
[sizeof(iAttribList
)/sizeof(iAttribList
[0])];
360 const int iAttribs
[] = { WGL_ALPHA_BITS_ARB
, 1, 0 };
361 unsigned int nFormats
;
363 int iPixelFormat
= 0;
365 if (!pwglChoosePixelFormatARB
)
367 win_skip("wglChoosePixelFormatARB is not available\n");
371 /* We need a pixel format with at least one bit of alpha */
372 res
= pwglChoosePixelFormatARB(hdc
, iAttribs
, NULL
, 1, &iPixelFormat
, &nFormats
);
373 if(res
== FALSE
|| nFormats
== 0)
375 skip("No suitable pixel formats found\n");
379 res
= pwglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0,
380 sizeof(iAttribList
)/sizeof(iAttribList
[0]), iAttribList
, iAttribRet
);
383 skip("wglGetPixelFormatAttribivARB failed\n");
386 iAttribRet
[1] += iAttribRet
[2]+iAttribRet
[3]+iAttribRet
[4];
387 ok(iAttribRet
[0] == iAttribRet
[1], "WGL_COLOR_BITS_ARB (%d) does not equal R+G+B+A (%d)!\n",
388 iAttribRet
[0], iAttribRet
[1]);
391 static void test_gdi_dbuf(HDC hdc
)
393 const int iAttribList
[] = { WGL_SUPPORT_GDI_ARB
, WGL_DOUBLE_BUFFER_ARB
};
394 int iAttribRet
[sizeof(iAttribList
)/sizeof(iAttribList
[0])];
395 unsigned int nFormats
;
399 if (!pwglGetPixelFormatAttribivARB
)
401 win_skip("wglGetPixelFormatAttribivARB is not available\n");
405 nFormats
= DescribePixelFormat(hdc
, 0, 0, NULL
);
406 for(iPixelFormat
= 1;iPixelFormat
<= nFormats
;iPixelFormat
++)
408 res
= pwglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, 0,
409 sizeof(iAttribList
)/sizeof(iAttribList
[0]), iAttribList
,
411 ok(res
!=FALSE
, "wglGetPixelFormatAttribivARB failed for pixel format %d\n", iPixelFormat
);
415 ok(!(iAttribRet
[0] && iAttribRet
[1]), "GDI support and double buffering on pixel format %d\n", iPixelFormat
);
419 static void test_make_current_read(HDC hdc
)
423 HGLRC hglrc
= wglCreateContext(hdc
);
427 skip("wglCreateContext failed!\n");
431 res
= wglMakeCurrent(hdc
, hglrc
);
434 skip("wglMakeCurrent failed!\n");
438 /* Test what wglGetCurrentReadDCARB does for wglMakeCurrent as the spec doesn't mention it */
439 hread
= pwglGetCurrentReadDCARB();
440 trace("hread %p, hdc %p\n", hread
, hdc
);
441 ok(hread
== hdc
, "wglGetCurrentReadDCARB failed for standard wglMakeCurrent\n");
443 pwglMakeContextCurrentARB(hdc
, hdc
, hglrc
);
444 hread
= pwglGetCurrentReadDCARB();
445 ok(hread
== hdc
, "wglGetCurrentReadDCARB failed for wglMakeContextCurrent\n");
448 static void test_dc(HWND hwnd
, HDC hdc
)
453 /* Get another DC and make sure it has the same pixel format */
457 pf1
= GetPixelFormat(hdc
);
458 pf2
= GetPixelFormat(hdc2
);
459 ok(pf1
== pf2
, "Second DC does not have the same format (%d != %d)\n", pf1
, pf2
);
462 skip("Could not get a different DC for the window\n");
466 ReleaseDC(hwnd
, hdc2
);
471 static void test_opengl3(HDC hdc
)
473 /* Try to create a context using an invalid OpenGL version namely 0.x */
476 int attribs
[] = {WGL_CONTEXT_MAJOR_VERSION_ARB
, 0, 0};
478 gl3Ctx
= pwglCreateContextAttribsARB(hdc
, 0, attribs
);
479 ok(gl3Ctx
== 0, "wglCreateContextAttribs with major version=0 should fail!\n");
482 wglDeleteContext(gl3Ctx
);
485 /* Try to create a context compatible with OpenGL 1.x; 1.0-2.1 is allowed */
488 int attribs
[] = {WGL_CONTEXT_MAJOR_VERSION_ARB
, 1, 0};
490 gl3Ctx
= pwglCreateContextAttribsARB(hdc
, 0, attribs
);
491 ok(gl3Ctx
!= 0, "pwglCreateContextAttribsARB for a 1.x context failed!\n");
492 wglDeleteContext(gl3Ctx
);
495 /* Try to pass an invalid HDC */
499 gl3Ctx
= pwglCreateContextAttribsARB((HDC
)0xdeadbeef, 0, 0);
500 ok(gl3Ctx
== 0, "pwglCreateContextAttribsARB using an invalid HDC passed\n");
501 error
= GetLastError();
502 todo_wine
ok(error
== ERROR_DC_NOT_FOUND
, "Expected ERROR_DC_NOT_FOUND, got error=%x\n", error
);
503 wglDeleteContext(gl3Ctx
);
506 /* Try to pass an invalid shareList */
510 gl3Ctx
= pwglCreateContextAttribsARB(hdc
, (HGLRC
)0xdeadbeef, 0);
511 ok(gl3Ctx
== 0, "pwglCreateContextAttribsARB using an invalid shareList passed\n");
512 error
= GetLastError();
513 todo_wine
ok(error
== ERROR_INVALID_OPERATION
, "Expected ERROR_INVALID_OPERATION, got error=%x\n", error
);
514 wglDeleteContext(gl3Ctx
);
517 /* Try to create an OpenGL 3.0 context */
519 int attribs
[] = {WGL_CONTEXT_MAJOR_VERSION_ARB
, 3, WGL_CONTEXT_MINOR_VERSION_ARB
, 0, 0};
520 HGLRC gl3Ctx
= pwglCreateContextAttribsARB(hdc
, 0, attribs
);
524 skip("Skipping the rest of the WGL_ARB_create_context test due to lack of OpenGL 3.0\n");
528 wglDeleteContext(gl3Ctx
);
531 /* Test matching an OpenGL 3.0 context with an older one, OpenGL 3.0 should allow it until the new object model is introduced in a future revision */
533 HGLRC glCtx
= wglCreateContext(hdc
);
535 int attribs
[] = {WGL_CONTEXT_MAJOR_VERSION_ARB
, 3, WGL_CONTEXT_MINOR_VERSION_ARB
, 0, 0};
536 int attribs_future
[] = {WGL_CONTEXT_FLAGS_ARB
, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
, WGL_CONTEXT_MAJOR_VERSION_ARB
, 3, WGL_CONTEXT_MINOR_VERSION_ARB
, 0, 0};
538 HGLRC gl3Ctx
= pwglCreateContextAttribsARB(hdc
, glCtx
, attribs
);
539 ok(gl3Ctx
!= NULL
, "Sharing of a display list between OpenGL 3.0 and OpenGL 1.x/2.x failed!\n");
541 wglDeleteContext(gl3Ctx
);
543 gl3Ctx
= pwglCreateContextAttribsARB(hdc
, glCtx
, attribs_future
);
544 ok(gl3Ctx
!= NULL
, "Sharing of a display list between a forward compatible OpenGL 3.0 context and OpenGL 1.x/2.x failed!\n");
546 wglDeleteContext(gl3Ctx
);
549 wglDeleteContext(glCtx
);
552 /* Try to create an OpenGL 3.0 context and test windowless rendering */
555 int attribs
[] = {WGL_CONTEXT_MAJOR_VERSION_ARB
, 3, WGL_CONTEXT_MINOR_VERSION_ARB
, 0, 0};
558 gl3Ctx
= pwglCreateContextAttribsARB(hdc
, 0, attribs
);
559 ok(gl3Ctx
!= 0, "pwglCreateContextAttribsARB for a 3.0 context failed!\n");
561 /* OpenGL 3.0 allows offscreen rendering WITHOUT a drawable */
562 /* NOTE: Nvidia's 177.89 beta drivers don't allow this yet */
563 res
= wglMakeCurrent(0, gl3Ctx
);
564 todo_wine
ok(res
== TRUE
, "OpenGL 3.0 should allow windowless rendering, but the test failed!\n");
566 wglMakeCurrent(0, 0);
569 wglDeleteContext(gl3Ctx
);
576 PIXELFORMATDESCRIPTOR pfd
= {
577 sizeof(PIXELFORMATDESCRIPTOR
),
583 24, /* 24-bit color depth */
584 0, 0, 0, 0, 0, 0, /* color bits */
585 0, /* alpha buffer */
587 0, /* accumulation buffer */
588 0, 0, 0, 0, /* accum bits */
590 0, /* stencil buffer */
591 0, /* auxiliary buffer */
592 PFD_MAIN_PLANE
, /* main layer */
594 0, 0, 0 /* layer masks */
597 hwnd
= CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW
,
598 10, 10, 200, 200, NULL
, NULL
, NULL
, NULL
);
599 ok(hwnd
!= NULL
, "err: %d\n", GetLastError());
603 int iPixelFormat
, res
;
606 ShowWindow(hwnd
, SW_SHOW
);
610 iPixelFormat
= ChoosePixelFormat(hdc
, &pfd
);
611 if(iPixelFormat
== 0)
613 /* This should never happen as ChoosePixelFormat always returns a closest match, but currently this fails in Wine if we don't have glX */
614 win_skip("Unable to find pixel format.\n");
618 /* We shouldn't be able to create a context from a hdc which doesn't have a pixel format set */
619 hglrc
= wglCreateContext(hdc
);
620 ok(hglrc
== NULL
, "wglCreateContext should fail when no pixel format has been set, but it passed\n");
621 error
= GetLastError();
622 ok(error
== ERROR_INVALID_PIXEL_FORMAT
, "expected ERROR_INVALID_PIXEL_FORMAT for wglCreateContext without a pixelformat set, but received %#x\n", error
);
624 res
= SetPixelFormat(hdc
, iPixelFormat
, &pfd
);
625 ok(res
, "SetPixelformat failed: %x\n", GetLastError());
629 hglrc
= wglCreateContext(hdc
);
630 res
= wglMakeCurrent(hdc
, hglrc
);
631 ok(res
, "wglMakeCurrent failed!\n");
634 trace("OpenGL renderer: %s\n", glGetString(GL_RENDERER
));
635 trace("OpenGL driver version: %s\n", glGetString(GL_VERSION
));
636 trace("OpenGL vendor: %s\n", glGetString(GL_VENDOR
));
640 skip("Skipping OpenGL tests without a current context\n");
644 /* Initialisation of WGL functions depends on an implicit WGL context. For this reason we can't load them before making
645 * any WGL call :( On Wine this would work but not on real Windows because there can be different implementations (software, ICD, MCD).
648 /* The lack of wglGetExtensionsStringARB in general means broken software rendering or the lack of decent OpenGL support, skip tests in such cases */
649 if (!pwglGetExtensionsStringARB
)
651 win_skip("wglGetExtensionsStringARB is not available\n");
655 test_makecurrent(hdc
);
656 test_setpixelformat(hdc
);
657 test_sharelists(hdc
);
661 wgl_extensions
= pwglGetExtensionsStringARB(hdc
);
662 if(wgl_extensions
== NULL
) skip("Skipping opengl32 tests because this OpenGL implementation doesn't support WGL extensions!\n");
664 if(strstr(wgl_extensions
, "WGL_ARB_create_context"))
667 if(strstr(wgl_extensions
, "WGL_ARB_make_current_read"))
668 test_make_current_read(hdc
);
670 skip("WGL_ARB_make_current_read not supported, skipping test\n");
672 if(strstr(wgl_extensions
, "WGL_ARB_pbuffer"))
675 skip("WGL_ARB_pbuffer not supported, skipping pbuffer test\n");
678 ReleaseDC(hwnd
, hdc
);