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)(void);
53 /* WGL_ARB_pixel_format */
54 #define WGL_ACCELERATION_ARB 0x2003
55 #define WGL_COLOR_BITS_ARB 0x2014
56 #define WGL_RED_BITS_ARB 0x2015
57 #define WGL_GREEN_BITS_ARB 0x2017
58 #define WGL_BLUE_BITS_ARB 0x2019
59 #define WGL_ALPHA_BITS_ARB 0x201B
60 #define WGL_SUPPORT_GDI_ARB 0x200F
61 #define WGL_DOUBLE_BUFFER_ARB 0x2011
62 #define WGL_NO_ACCELERATION_ARB 0x2025
63 #define WGL_GENERIC_ACCELERATION_ARB 0x2026
64 #define WGL_FULL_ACCELERATION_ARB 0x2027
66 static BOOL (WINAPI *pwglChoosePixelFormatARB)(HDC, const int *, const FLOAT *, UINT, int *, UINT *);
67 static BOOL (WINAPI *pwglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int *, int *);
70 #define WGL_DRAW_TO_PBUFFER_ARB 0x202D
71 static HPBUFFERARB* (WINAPI *pwglCreatePbufferARB)(HDC, int, int, int, const int *);
72 static HDC (WINAPI *pwglGetPbufferDCARB)(HPBUFFERARB);
74 static const char* wgl_extensions = NULL;
76 static void init_functions(void)
78 #define GET_PROC(func) \
79 p ## func = (void*)wglGetProcAddress(#func); \
81 trace("wglGetProcAddress(%s) failed\n", #func);
83 /* WGL_ARB_create_context */
84 GET_PROC(wglCreateContextAttribsARB);
86 /* WGL_ARB_extensions_string */
87 GET_PROC(wglGetExtensionsStringARB)
89 /* WGL_ARB_make_current_read */
90 GET_PROC(wglMakeContextCurrentARB);
91 GET_PROC(wglGetCurrentReadDCARB);
93 /* WGL_ARB_pixel_format */
94 GET_PROC(wglChoosePixelFormatARB)
95 GET_PROC(wglGetPixelFormatAttribivARB)
98 GET_PROC(wglCreatePbufferARB)
99 GET_PROC(wglGetPbufferDCARB)
100 GET_PROC(wglReleasePbufferDCARB)
105 static void test_pbuffers(HDC hdc)
107 const int iAttribList[] = { WGL_DRAW_TO_PBUFFER_ARB, 1, /* Request pbuffer support */
109 int iFormats[MAX_FORMATS];
110 unsigned int nOnscreenFormats;
111 unsigned int nFormats;
113 int iPixelFormat = 0;
115 nOnscreenFormats = DescribePixelFormat(hdc, 0, 0, NULL);
117 /* When you want to render to a pbuffer you need to call wglGetPbufferDCARB which
118 * returns a 'magic' HDC which you can then pass to wglMakeCurrent to switch rendering
119 * to the pbuffer. Below some tests are performed on what happens if you use standard WGL calls
120 * on this 'magic' HDC for both a pixelformat that support onscreen and offscreen rendering
121 * and a pixelformat that's only available for offscreen rendering (this means that only
122 * wglChoosePixelFormatARB and friends know about the format.
124 * The first thing we need are pixelformats with pbuffer capabilities.
126 res = pwglChoosePixelFormatARB(hdc, iAttribList, NULL, MAX_FORMATS, iFormats, &nFormats);
129 skip("No pbuffer compatible formats found while WGL_ARB_pbuffer is supported\n");
132 trace("nOnscreenFormats: %d\n", nOnscreenFormats);
133 trace("Total number of pbuffer capable pixelformats: %d\n", nFormats);
135 /* Try to select an onscreen pixelformat out of the list */
136 for(i=0; i < nFormats; i++)
138 /* Check if the format is onscreen, if it is choose it */
139 if(iFormats[i] <= nOnscreenFormats)
141 iPixelFormat = iFormats[i];
142 trace("Selected iPixelFormat=%d\n", iPixelFormat);
147 /* A video driver supports a large number of onscreen and offscreen pixelformats.
148 * The traditional WGL calls only see a subset of the whole pixelformat list. First
149 * of all they only see the onscreen formats (the offscreen formats are at the end of the
150 * pixelformat list) and second extended pixelformat capabilities are hidden from the
151 * standard WGL calls. Only functions that depend on WGL_ARB_pixel_format can see them.
153 * Below we check if the pixelformat is also supported onscreen.
155 if(iPixelFormat != 0)
158 HPBUFFERARB pbuffer = pwglCreatePbufferARB(hdc, iPixelFormat, 640 /* width */, 480 /* height */, NULL);
160 skip("Pbuffer creation failed!\n");
162 /* Test the pixelformat returned by GetPixelFormat on a pbuffer as the behavior is not clear */
163 pbuffer_hdc = pwglGetPbufferDCARB(pbuffer);
164 res = GetPixelFormat(pbuffer_hdc);
165 ok(res == iPixelFormat, "Unexpected iPixelFormat=%d returned by GetPixelFormat for format %d\n", res, iPixelFormat);
166 trace("iPixelFormat returned by GetPixelFormat: %d\n", res);
167 trace("PixelFormat from wglChoosePixelFormatARB: %d\n", iPixelFormat);
169 pwglReleasePbufferDCARB(pbuffer, hdc);
171 else skip("Pbuffer test for onscreen pixelformat skipped as no onscreen format with pbuffer capabilities have been found\n");
173 /* Search for a real offscreen format */
174 for(i=0, iPixelFormat=0; i<nFormats; i++)
176 if(iFormats[i] > nOnscreenFormats)
178 iPixelFormat = iFormats[i];
179 trace("Selected iPixelFormat: %d\n", iPixelFormat);
184 if(iPixelFormat != 0)
187 HPBUFFERARB pbuffer = pwglCreatePbufferARB(hdc, iPixelFormat, 640 /* width */, 480 /* height */, NULL);
189 skip("Pbuffer creation failed!\n");
191 /* Test the pixelformat returned by GetPixelFormat on a pbuffer as the behavior is not clear */
192 pbuffer_hdc = pwglGetPbufferDCARB(pbuffer);
193 res = GetPixelFormat(pbuffer_hdc);
195 ok(res == 1, "Unexpected iPixelFormat=%d (1 expected) returned by GetPixelFormat for offscreen format %d\n", res, iPixelFormat);
196 trace("iPixelFormat returned by GetPixelFormat: %d\n", res);
197 trace("PixelFormat from wglChoosePixelFormatARB: %d\n", iPixelFormat);
198 pwglReleasePbufferDCARB(pbuffer, hdc);
200 else skip("Pbuffer test for offscreen pixelformat skipped as no offscreen-only format with pbuffer capabilities has been found\n");
203 static void test_setpixelformat(HDC winhdc)
210 PIXELFORMATDESCRIPTOR pfd = {
211 sizeof(PIXELFORMATDESCRIPTOR),
217 24, /* 24-bit color depth */
218 0, 0, 0, 0, 0, 0, /* color bits */
219 0, /* alpha buffer */
221 0, /* accumulation buffer */
222 0, 0, 0, 0, /* accum bits */
224 0, /* stencil buffer */
225 0, /* auxiliary buffer */
226 PFD_MAIN_PLANE, /* main layer */
228 0, 0, 0 /* layer masks */
232 ok(hdc != 0, "GetDC(0) failed!\n");
234 /* This should pass even on the main device context */
235 pf = ChoosePixelFormat(hdc, &pfd);
236 ok(pf != 0, "ChoosePixelFormat failed on main device context\n");
238 /* SetPixelFormat on the main device context 'X root window' should fail,
239 * but some broken drivers allow it
241 res = SetPixelFormat(hdc, pf, &pfd);
242 trace("SetPixelFormat on main device context %s\n", res ? "succeeded" : "failed");
244 /* Setting the same format that was set on the HDC is allowed; other
246 nCfgs = DescribePixelFormat(winhdc, 0, 0, NULL);
247 pf = GetPixelFormat(winhdc);
248 for(i = 1;i <= nCfgs;i++)
250 int res = SetPixelFormat(winhdc, i, NULL);
251 if(i == pf) ok(res, "Failed to set the same pixel format\n");
252 else ok(!res, "Unexpectedly set an alternate pixel format\n");
255 hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW,
256 10, 10, 200, 200, NULL, NULL, NULL, NULL);
257 ok(hwnd != NULL, "err: %d\n", GetLastError());
260 HDC hdc = GetDC( hwnd );
261 pf = ChoosePixelFormat( hdc, &pfd );
262 ok( pf != 0, "ChoosePixelFormat failed\n" );
263 res = SetPixelFormat( hdc, pf, &pfd );
264 ok( res != 0, "SetPixelFormat failed\n" );
265 i = GetPixelFormat( hdc );
266 ok( i == pf, "GetPixelFormat returned wrong format %d/%d\n", i, pf );
267 ReleaseDC( hwnd, hdc );
268 hdc = GetWindowDC( hwnd );
269 i = GetPixelFormat( hdc );
270 ok( i == pf, "GetPixelFormat returned wrong format %d/%d\n", i, pf );
271 ReleaseDC( hwnd, hdc );
272 DestroyWindow( hwnd );
275 hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW,
276 10, 10, 200, 200, NULL, NULL, NULL, NULL);
277 ok(hwnd != NULL, "err: %d\n", GetLastError());
280 HDC hdc = GetWindowDC( hwnd );
281 pf = ChoosePixelFormat( hdc, &pfd );
282 ok( pf != 0, "ChoosePixelFormat failed\n" );
283 res = SetPixelFormat( hdc, pf, &pfd );
284 ok( res != 0, "SetPixelFormat failed\n" );
285 i = GetPixelFormat( hdc );
286 ok( i == pf, "GetPixelFormat returned wrong format %d/%d\n", i, pf );
287 ReleaseDC( hwnd, hdc );
288 DestroyWindow( hwnd );
292 static void test_sharelists(HDC winhdc)
294 HGLRC hglrc1, hglrc2, hglrc3;
297 hglrc1 = wglCreateContext(winhdc);
298 res = wglShareLists(0, 0);
299 ok(res == FALSE, "Sharing display lists for no contexts passed!\n");
301 /* Test 1: Create a context and just share lists without doing anything special */
302 hglrc2 = wglCreateContext(winhdc);
305 res = wglShareLists(hglrc1, hglrc2);
306 ok(res, "Sharing of display lists failed\n");
307 wglDeleteContext(hglrc2);
310 /* Test 2: Share display lists with a 'destination' context which has been made current */
311 hglrc2 = wglCreateContext(winhdc);
314 res = wglMakeCurrent(winhdc, hglrc2);
315 ok(res, "Make current failed\n");
316 res = wglShareLists(hglrc1, hglrc2);
317 todo_wine ok(res, "Sharing display lists with a destination context which has been made current failed\n");
318 wglMakeCurrent(0, 0);
319 wglDeleteContext(hglrc2);
322 /* Test 3: Share display lists with a context which already shares display lists with another context.
323 * According to MSDN the second parameter cannot share any display lists but some buggy drivers might allow it */
324 hglrc3 = wglCreateContext(winhdc);
327 res = wglShareLists(hglrc3, hglrc1);
328 ok(res == FALSE, "Sharing of display lists passed for a context which already shared lists before\n");
329 wglDeleteContext(hglrc3);
332 /* Test 4: Share display lists with a 'source' context which has been made current */
333 hglrc2 = wglCreateContext(winhdc);
336 res = wglMakeCurrent(winhdc, hglrc1);
337 ok(res, "Make current failed\n");
338 res = wglShareLists(hglrc1, hglrc2);
339 ok(res, "Sharing display lists with a source context which has been made current failed\n");
340 wglMakeCurrent(0, 0);
341 wglDeleteContext(hglrc2);
345 static void test_makecurrent(HDC winhdc)
351 hglrc = wglCreateContext(winhdc);
352 ok( hglrc != 0, "wglCreateContext failed\n" );
354 ret = wglMakeCurrent( winhdc, hglrc );
355 ok( ret, "wglMakeCurrent failed\n" );
357 ok( wglGetCurrentContext() == hglrc, "wrong context\n" );
359 /* set the same context again */
360 ret = wglMakeCurrent( winhdc, hglrc );
361 ok( ret, "wglMakeCurrent failed\n" );
363 /* check wglMakeCurrent(x, y) after another call to wglMakeCurrent(x, y) */
364 ret = wglMakeCurrent( winhdc, NULL );
365 ok( ret, "wglMakeCurrent failed\n" );
367 ret = wglMakeCurrent( winhdc, NULL );
368 ok( ret, "wglMakeCurrent failed\n" );
370 SetLastError( 0xdeadbeef );
371 ret = wglMakeCurrent( NULL, NULL );
372 ok( !ret, "wglMakeCurrent succeeded\n" );
373 error = GetLastError();
374 ok( error == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got error=%x\n", error);
376 ret = wglMakeCurrent( winhdc, NULL );
377 ok( ret, "wglMakeCurrent failed\n" );
379 ret = wglMakeCurrent( winhdc, hglrc );
380 ok( ret, "wglMakeCurrent failed\n" );
382 ret = wglMakeCurrent( NULL, NULL );
383 ok( ret, "wglMakeCurrent failed\n" );
385 SetLastError( 0xdeadbeef );
386 ret = wglMakeCurrent( NULL, NULL );
387 ok( !ret, "wglMakeCurrent succeeded\n" );
388 error = GetLastError();
389 ok( error == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got error=%x\n", error);
391 ret = wglMakeCurrent( winhdc, hglrc );
392 ok( ret, "wglMakeCurrent failed\n" );
395 static void test_colorbits(HDC hdc)
397 const int iAttribList[] = { WGL_COLOR_BITS_ARB, WGL_RED_BITS_ARB, WGL_GREEN_BITS_ARB,
398 WGL_BLUE_BITS_ARB, WGL_ALPHA_BITS_ARB };
399 int iAttribRet[sizeof(iAttribList)/sizeof(iAttribList[0])];
400 const int iAttribs[] = { WGL_ALPHA_BITS_ARB, 1, 0 };
401 unsigned int nFormats;
403 int iPixelFormat = 0;
405 if (!pwglChoosePixelFormatARB)
407 win_skip("wglChoosePixelFormatARB is not available\n");
411 /* We need a pixel format with at least one bit of alpha */
412 res = pwglChoosePixelFormatARB(hdc, iAttribs, NULL, 1, &iPixelFormat, &nFormats);
413 if(res == FALSE || nFormats == 0)
415 skip("No suitable pixel formats found\n");
419 res = pwglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0,
420 sizeof(iAttribList)/sizeof(iAttribList[0]), iAttribList, iAttribRet);
423 skip("wglGetPixelFormatAttribivARB failed\n");
426 iAttribRet[1] += iAttribRet[2]+iAttribRet[3]+iAttribRet[4];
427 ok(iAttribRet[0] == iAttribRet[1], "WGL_COLOR_BITS_ARB (%d) does not equal R+G+B+A (%d)!\n",
428 iAttribRet[0], iAttribRet[1]);
431 static void test_gdi_dbuf(HDC hdc)
433 const int iAttribList[] = { WGL_SUPPORT_GDI_ARB, WGL_DOUBLE_BUFFER_ARB };
434 int iAttribRet[sizeof(iAttribList)/sizeof(iAttribList[0])];
435 unsigned int nFormats;
439 if (!pwglGetPixelFormatAttribivARB)
441 win_skip("wglGetPixelFormatAttribivARB is not available\n");
445 nFormats = DescribePixelFormat(hdc, 0, 0, NULL);
446 for(iPixelFormat = 1;iPixelFormat <= nFormats;iPixelFormat++)
448 res = pwglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0,
449 sizeof(iAttribList)/sizeof(iAttribList[0]), iAttribList,
451 ok(res!=FALSE, "wglGetPixelFormatAttribivARB failed for pixel format %d\n", iPixelFormat);
455 ok(!(iAttribRet[0] && iAttribRet[1]), "GDI support and double buffering on pixel format %d\n", iPixelFormat);
459 static void test_acceleration(HDC hdc)
461 const int iAttribList[] = { WGL_ACCELERATION_ARB };
462 int iAttribRet[sizeof(iAttribList)/sizeof(iAttribList[0])];
463 unsigned int nFormats;
466 PIXELFORMATDESCRIPTOR pfd;
468 if (!pwglGetPixelFormatAttribivARB)
470 win_skip("wglGetPixelFormatAttribivARB is not available\n");
474 nFormats = DescribePixelFormat(hdc, 0, 0, NULL);
475 for(iPixelFormat = 1; iPixelFormat <= nFormats; iPixelFormat++)
477 res = pwglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0,
478 sizeof(iAttribList)/sizeof(iAttribList[0]), iAttribList,
480 ok(res!=FALSE, "wglGetPixelFormatAttribivARB failed for pixel format %d\n", iPixelFormat);
484 memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
485 DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
487 switch(iAttribRet[0])
489 case WGL_NO_ACCELERATION_ARB:
490 ok( (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED)) == PFD_GENERIC_FORMAT , "Expected only PFD_GENERIC_FORMAT to be set for WGL_NO_ACCELERATION_ARB!: iPixelFormat=%d, dwFlags=%x!\n", iPixelFormat, pfd.dwFlags);
492 case WGL_GENERIC_ACCELERATION_ARB:
493 ok( (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED)) == (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED), "Expected both PFD_GENERIC_FORMAT and PFD_GENERIC_ACCELERATION to be set for WGL_GENERIC_ACCELERATION_ARB: iPixelFormat=%d, dwFlags=%x!\n", iPixelFormat, pfd.dwFlags);
495 case WGL_FULL_ACCELERATION_ARB:
496 ok( (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED)) == 0, "Expected no PFD_GENERIC_FORMAT/_ACCELERATION to be set for WGL_FULL_ACCELERATION_ARB: iPixelFormat=%d, dwFlags=%x!\n", iPixelFormat, pfd.dwFlags);
502 static void test_make_current_read(HDC hdc)
506 HGLRC hglrc = wglCreateContext(hdc);
510 skip("wglCreateContext failed!\n");
514 res = wglMakeCurrent(hdc, hglrc);
517 skip("wglMakeCurrent failed!\n");
521 /* Test what wglGetCurrentReadDCARB does for wglMakeCurrent as the spec doesn't mention it */
522 hread = pwglGetCurrentReadDCARB();
523 trace("hread %p, hdc %p\n", hread, hdc);
524 ok(hread == hdc, "wglGetCurrentReadDCARB failed for standard wglMakeCurrent\n");
526 pwglMakeContextCurrentARB(hdc, hdc, hglrc);
527 hread = pwglGetCurrentReadDCARB();
528 ok(hread == hdc, "wglGetCurrentReadDCARB failed for wglMakeContextCurrent\n");
531 static void test_dc(HWND hwnd, HDC hdc)
536 /* Get another DC and make sure it has the same pixel format */
540 pf1 = GetPixelFormat(hdc);
541 pf2 = GetPixelFormat(hdc2);
542 ok(pf1 == pf2, "Second DC does not have the same format (%d != %d)\n", pf1, pf2);
545 skip("Could not get a different DC for the window\n");
549 ReleaseDC(hwnd, hdc2);
554 /* Nvidia converts win32 error codes to (0xc007 << 16) | win32_error_code */
555 #define NVIDIA_HRESULT_FROM_WIN32(x) (HRESULT_FROM_WIN32(x) | 0x40000000)
556 static void test_opengl3(HDC hdc)
558 /* Try to create a context compatible with OpenGL 1.x; 1.0-2.1 is allowed */
561 int attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 1, 0};
563 gl3Ctx = pwglCreateContextAttribsARB(hdc, 0, attribs);
564 ok(gl3Ctx != 0, "pwglCreateContextAttribsARB for a 1.x context failed!\n");
565 wglDeleteContext(gl3Ctx);
568 /* Try to pass an invalid HDC */
572 gl3Ctx = pwglCreateContextAttribsARB((HDC)0xdeadbeef, 0, 0);
573 ok(gl3Ctx == 0, "pwglCreateContextAttribsARB using an invalid HDC passed\n");
574 error = GetLastError();
575 todo_wine ok(error == ERROR_DC_NOT_FOUND ||
576 broken(error == NVIDIA_HRESULT_FROM_WIN32(ERROR_INVALID_DATA)), /* Nvidia Vista + Win7 */
577 "Expected ERROR_DC_NOT_FOUND, got error=%x\n", error);
578 wglDeleteContext(gl3Ctx);
581 /* Try to pass an invalid shareList */
585 gl3Ctx = pwglCreateContextAttribsARB(hdc, (HGLRC)0xdeadbeef, 0);
586 todo_wine ok(gl3Ctx == 0, "pwglCreateContextAttribsARB using an invalid shareList passed\n");
587 error = GetLastError();
588 /* The Nvidia implementation seems to return hresults instead of win32 error codes */
589 todo_wine ok(error == ERROR_INVALID_OPERATION ||
590 error == NVIDIA_HRESULT_FROM_WIN32(ERROR_INVALID_OPERATION), "Expected ERROR_INVALID_OPERATION, got error=%x\n", error);
591 wglDeleteContext(gl3Ctx);
594 /* Try to create an OpenGL 3.0 context */
596 int attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 0, 0};
597 HGLRC gl3Ctx = pwglCreateContextAttribsARB(hdc, 0, attribs);
601 skip("Skipping the rest of the WGL_ARB_create_context test due to lack of OpenGL 3.0\n");
605 wglDeleteContext(gl3Ctx);
608 /* 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 */
610 HGLRC glCtx = wglCreateContext(hdc);
612 int attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 0, 0};
613 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};
615 HGLRC gl3Ctx = pwglCreateContextAttribsARB(hdc, glCtx, attribs);
616 ok(gl3Ctx != NULL, "Sharing of a display list between OpenGL 3.0 and OpenGL 1.x/2.x failed!\n");
618 wglDeleteContext(gl3Ctx);
620 gl3Ctx = pwglCreateContextAttribsARB(hdc, glCtx, attribs_future);
621 ok(gl3Ctx != NULL, "Sharing of a display list between a forward compatible OpenGL 3.0 context and OpenGL 1.x/2.x failed!\n");
623 wglDeleteContext(gl3Ctx);
626 wglDeleteContext(glCtx);
629 /* Try to create an OpenGL 3.0 context and test windowless rendering */
632 int attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 0, 0};
635 gl3Ctx = pwglCreateContextAttribsARB(hdc, 0, attribs);
636 ok(gl3Ctx != 0, "pwglCreateContextAttribsARB for a 3.0 context failed!\n");
638 /* OpenGL 3.0 allows offscreen rendering WITHOUT a drawable
639 * Neither AMD or Nvidia support it at this point. The WGL_ARB_create_context specs also say that
640 * it is hard because drivers use the HDC to enter the display driver and it sounds like they don't
641 * expect drivers to ever offer it.
643 res = wglMakeCurrent(0, gl3Ctx);
644 ok(res == FALSE, "Wow, OpenGL 3.0 windowless rendering passed while it was expected not to!\n");
646 wglMakeCurrent(0, 0);
649 wglDeleteContext(gl3Ctx);
656 PIXELFORMATDESCRIPTOR pfd = {
657 sizeof(PIXELFORMATDESCRIPTOR),
663 24, /* 24-bit color depth */
664 0, 0, 0, 0, 0, 0, /* color bits */
665 0, /* alpha buffer */
667 0, /* accumulation buffer */
668 0, 0, 0, 0, /* accum bits */
670 0, /* stencil buffer */
671 0, /* auxiliary buffer */
672 PFD_MAIN_PLANE, /* main layer */
674 0, 0, 0 /* layer masks */
677 hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW,
678 10, 10, 200, 200, NULL, NULL, NULL, NULL);
679 ok(hwnd != NULL, "err: %d\n", GetLastError());
683 int iPixelFormat, res;
686 ShowWindow(hwnd, SW_SHOW);
690 iPixelFormat = ChoosePixelFormat(hdc, &pfd);
691 if(iPixelFormat == 0)
693 /* This should never happen as ChoosePixelFormat always returns a closest match, but currently this fails in Wine if we don't have glX */
694 win_skip("Unable to find pixel format.\n");
698 /* We shouldn't be able to create a context from a hdc which doesn't have a pixel format set */
699 hglrc = wglCreateContext(hdc);
700 ok(hglrc == NULL, "wglCreateContext should fail when no pixel format has been set, but it passed\n");
701 error = GetLastError();
702 ok(error == ERROR_INVALID_PIXEL_FORMAT, "expected ERROR_INVALID_PIXEL_FORMAT for wglCreateContext without a pixelformat set, but received %#x\n", error);
704 res = SetPixelFormat(hdc, iPixelFormat, &pfd);
705 ok(res, "SetPixelformat failed: %x\n", GetLastError());
709 hglrc = wglCreateContext(hdc);
710 res = wglMakeCurrent(hdc, hglrc);
711 ok(res, "wglMakeCurrent failed!\n");
714 trace("OpenGL renderer: %s\n", glGetString(GL_RENDERER));
715 trace("OpenGL driver version: %s\n", glGetString(GL_VERSION));
716 trace("OpenGL vendor: %s\n", glGetString(GL_VENDOR));
720 skip("Skipping OpenGL tests without a current context\n");
724 /* Initialisation of WGL functions depends on an implicit WGL context. For this reason we can't load them before making
725 * any WGL call :( On Wine this would work but not on real Windows because there can be different implementations (software, ICD, MCD).
728 /* The lack of wglGetExtensionsStringARB in general means broken software rendering or the lack of decent OpenGL support, skip tests in such cases */
729 if (!pwglGetExtensionsStringARB)
731 win_skip("wglGetExtensionsStringARB is not available\n");
735 test_makecurrent(hdc);
736 test_setpixelformat(hdc);
737 test_sharelists(hdc);
740 test_acceleration(hdc);
742 wgl_extensions = pwglGetExtensionsStringARB(hdc);
743 if(wgl_extensions == NULL) skip("Skipping opengl32 tests because this OpenGL implementation doesn't support WGL extensions!\n");
745 if(strstr(wgl_extensions, "WGL_ARB_create_context"))
748 if(strstr(wgl_extensions, "WGL_ARB_make_current_read"))
749 test_make_current_read(hdc);
751 skip("WGL_ARB_make_current_read not supported, skipping test\n");
753 if(strstr(wgl_extensions, "WGL_ARB_pbuffer"))
756 skip("WGL_ARB_pbuffer not supported, skipping pbuffer test\n");
759 ReleaseDC(hwnd, hdc);