From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/tests/opengl.c | 116 +++++++++++++++++------------------ 1 file changed, 56 insertions(+), 60 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 25485841d70..d98c2c7af5e 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -861,84 +861,79 @@ static void test_acceleration(HDC hdc)
static void test_bitmap_rendering( BOOL use_dib ) { - PIXELFORMATDESCRIPTOR pfd; - int i, ret, bpp, iPixelFormat=0; - unsigned int nFormats; + BITMAPINFO bmi = {.bmiHeader = {.biSize = sizeof(BITMAPINFOHEADER), .biPlanes = 1, .biCompression = BI_RGB}}; + int i, ret, bpp, count, pixel_format = 0; + HBITMAP bmp, old_bmp, bmp2; HGLRC hglrc, hglrc2; - BITMAPINFO biDst; - HBITMAP bmpDst, oldDst, bmp2; - HDC hdcDst, hdcScreen; - UINT *dstBuffer = NULL; + UINT *pixels = NULL; + HDC hdc;
- hdcScreen = CreateCompatibleDC(0); - hdcDst = CreateCompatibleDC(0); + winetest_push_context( use_dib ? "DIB" : "DDB" ); + + hdc = CreateCompatibleDC( 0 );
if (use_dib) { bpp = 32; - memset(&biDst, 0, sizeof(BITMAPINFO)); - biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - biDst.bmiHeader.biWidth = 4; - biDst.bmiHeader.biHeight = -4; - biDst.bmiHeader.biPlanes = 1; - biDst.bmiHeader.biBitCount = 32; - biDst.bmiHeader.biCompression = BI_RGB; - - bmpDst = CreateDIBSection(0, &biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0); - - biDst.bmiHeader.biWidth = 12; - biDst.bmiHeader.biHeight = -12; - biDst.bmiHeader.biBitCount = 16; - bmp2 = CreateDIBSection(0, &biDst, DIB_RGB_COLORS, NULL, NULL, 0); + bmi.bmiHeader.biWidth = 4; + bmi.bmiHeader.biHeight = -4; + bmi.bmiHeader.biBitCount = 32; + bmp = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, (void **)&pixels, NULL, 0 ); + + bmi.bmiHeader.biWidth = 12; + bmi.bmiHeader.biHeight = -12; + bmi.bmiHeader.biBitCount = 16; + bmp2 = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, NULL, NULL, 0 ); } else { - bpp = GetDeviceCaps( hdcScreen, BITSPIXEL ); - bmpDst = CreateBitmap( 4, 4, 1, bpp, NULL ); + bpp = GetDeviceCaps( hdc, BITSPIXEL ); + bmp = CreateBitmap( 4, 4, 1, bpp, NULL ); bmp2 = CreateBitmap( 12, 12, 1, bpp, NULL ); }
- oldDst = SelectObject(hdcDst, bmpDst); - - trace( "testing on %s\n", use_dib ? "DIB" : "DDB" ); + old_bmp = SelectObject( hdc, bmp );
/* Pick a pixel format by hand because ChoosePixelFormat is unreliable */ - nFormats = DescribePixelFormat(hdcDst, 0, 0, NULL); - for(i=1; i<=nFormats; i++) + count = DescribePixelFormat( hdc, 0, 0, NULL ); + for (i = 1; i <= count; i++) { - memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); - DescribePixelFormat(hdcDst, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + PIXELFORMATDESCRIPTOR pfd = {0}; + + DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
if((pfd.dwFlags & PFD_DRAW_TO_BITMAP) && (pfd.dwFlags & PFD_SUPPORT_OPENGL) && (pfd.cColorBits == bpp) && (pfd.cAlphaBits == 8) ) { - iPixelFormat = i; + pixel_format = i; break; } }
- if(!iPixelFormat) + if (!pixel_format) { skip("Unable to find a suitable pixel format\n"); } else { - ret = SetPixelFormat(hdcDst, iPixelFormat, &pfd); + PIXELFORMATDESCRIPTOR pfd = {0}; + + ret = SetPixelFormat( hdc, pixel_format, &pfd ); ok( ret, "SetPixelFormat failed\n" ); - ret = GetPixelFormat( hdcDst ); - ok( ret == iPixelFormat, "GetPixelFormat returned %d/%d\n", ret, iPixelFormat ); - ret = SetPixelFormat(hdcDst, iPixelFormat + 1, &pfd); + ret = GetPixelFormat( hdc ); + ok( ret == pixel_format, "GetPixelFormat returned %d/%d\n", ret, pixel_format ); + ret = SetPixelFormat( hdc, pixel_format + 1, &pfd ); ok( !ret, "SetPixelFormat succeeded\n" ); - hglrc = wglCreateContext(hdcDst); + hglrc = wglCreateContext( hdc ); ok(hglrc != NULL, "Unable to create a context\n");
if(hglrc) { GLint viewport[4]; - wglMakeCurrent(hdcDst, hglrc); - hglrc2 = wglCreateContext(hdcDst); + wglMakeCurrent( hdc, hglrc ); + hglrc2 = wglCreateContext( hdc ); ok(hglrc2 != NULL, "Unable to create a context\n");
/* Note this is RGBA but we read ARGB back */ @@ -950,15 +945,15 @@ static void test_bitmap_rendering( BOOL use_dib ) ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); /* Note apparently the alpha channel is not supported by the software renderer (bitmap only works using software) */ - if (dstBuffer) + if (pixels) for (i = 0; i < 16; i++) - ok(dstBuffer[i] == 0x223344 || dstBuffer[i] == 0x11223344, "Received color=%x at %u\n", - dstBuffer[i], i); + ok( pixels[i] == 0x223344 || pixels[i] == 0x11223344, + "Received color=%x at %u\n", pixels[i], i );
- SelectObject(hdcDst, bmp2); - ret = GetPixelFormat( hdcDst ); - ok( ret == iPixelFormat, "GetPixelFormat returned %d/%d\n", ret, iPixelFormat ); - ret = SetPixelFormat(hdcDst, iPixelFormat + 1, &pfd); + SelectObject( hdc, bmp2 ); + ret = GetPixelFormat( hdc ); + ok( ret == pixel_format, "GetPixelFormat returned %d/%d\n", ret, pixel_format ); + ret = SetPixelFormat( hdc, pixel_format + 1, &pfd ); ok( !ret, "SetPixelFormat succeeded\n" );
/* context still uses the old pixel format and viewport */ @@ -970,7 +965,7 @@ static void test_bitmap_rendering( BOOL use_dib ) "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] );
wglMakeCurrent(NULL, NULL); - wglMakeCurrent(hdcDst, hglrc); + wglMakeCurrent( hdc, hglrc ); glClearColor((float)0x44/0xff, (float)0x55/0xff, (float)0x66/0xff, (float)0x11/0xff); glClear(GL_COLOR_BUFFER_BIT); glFinish(); @@ -978,22 +973,22 @@ static void test_bitmap_rendering( BOOL use_dib ) ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] );
- wglMakeCurrent(hdcDst, hglrc2); + wglMakeCurrent( hdc, hglrc2 ); glGetIntegerv( GL_VIEWPORT, viewport ); ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] );
- wglMakeCurrent(hdcDst, hglrc); + wglMakeCurrent( hdc, hglrc ); glGetIntegerv( GL_VIEWPORT, viewport ); ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] );
- SelectObject(hdcDst, bmpDst); - ret = GetPixelFormat( hdcDst ); - ok( ret == iPixelFormat, "GetPixelFormat returned %d/%d\n", ret, iPixelFormat ); - ret = SetPixelFormat(hdcDst, iPixelFormat + 1, &pfd); + SelectObject( hdc, bmp ); + ret = GetPixelFormat( hdc ); + ok( ret == pixel_format, "GetPixelFormat returned %d/%d\n", ret, pixel_format ); + ret = SetPixelFormat( hdc, pixel_format + 1, &pfd ); ok( !ret, "SetPixelFormat succeeded\n" ); - wglMakeCurrent(hdcDst, hglrc2); + wglMakeCurrent( hdc, hglrc2 ); glGetIntegerv( GL_VIEWPORT, viewport ); ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); @@ -1003,11 +998,12 @@ static void test_bitmap_rendering( BOOL use_dib ) } }
- SelectObject(hdcDst, oldDst); + SelectObject( hdc, old_bmp ); DeleteObject(bmp2); - DeleteObject(bmpDst); - DeleteDC(hdcDst); - DeleteDC(hdcScreen); + DeleteObject( bmp ); + DeleteDC( hdc ); + + winetest_pop_context(); }
struct wgl_thread_param
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/tests/opengl.c | 203 ++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 89 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index d98c2c7af5e..a56702e34ef 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -863,9 +863,10 @@ static void test_bitmap_rendering( BOOL use_dib ) { BITMAPINFO bmi = {.bmiHeader = {.biSize = sizeof(BITMAPINFOHEADER), .biPlanes = 1, .biCompression = BI_RGB}}; int i, ret, bpp, count, pixel_format = 0; - HBITMAP bmp, old_bmp, bmp2; + HBITMAP bmp, old_bmp, bmp2, tmp_bmp; HGLRC hglrc, hglrc2; UINT *pixels = NULL; + GLint viewport[4]; HDC hdc;
winetest_push_context( use_dib ? "DIB" : "DDB" ); @@ -892,112 +893,136 @@ static void test_bitmap_rendering( BOOL use_dib ) bmp2 = CreateBitmap( 12, 12, 1, bpp, NULL ); }
+ ret = GetPixelFormat( hdc ); + ok( ret == 0, "got %d\n", ret ); + count = DescribePixelFormat( hdc, 0, 0, NULL ); + ok( count > 1, "got %d\n", count ); + old_bmp = SelectObject( hdc, bmp ); + ok( !!old_bmp, "got %p\n", old_bmp ); + + /* cannot create a GL context without a pixel format */ + + hglrc = wglCreateContext( hdc ); + todo_wine + ok( !hglrc, "wglCreateContext succeeded\n" ); + if (hglrc) wglDeleteContext( hglrc ); + + /* cannot set pixel format twice */
- /* Pick a pixel format by hand because ChoosePixelFormat is unreliable */ - count = DescribePixelFormat( hdc, 0, 0, NULL ); for (i = 1; i <= count; i++) { PIXELFORMATDESCRIPTOR pfd = {0};
- DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd ); + winetest_push_context( "%u", i ); + + ret = DescribePixelFormat( hdc, i, sizeof(pfd), &pfd ); + ok( ret == count, "got %d\n", ret );
- if((pfd.dwFlags & PFD_DRAW_TO_BITMAP) && - (pfd.dwFlags & PFD_SUPPORT_OPENGL) && - (pfd.cColorBits == bpp) && - (pfd.cAlphaBits == 8) ) + if ((pfd.dwFlags & PFD_DRAW_TO_BITMAP) && (pfd.dwFlags & PFD_SUPPORT_OPENGL) && + pfd.cColorBits == bpp && pfd.cAlphaBits == 8) { - pixel_format = i; - break; + ret = SetPixelFormat( hdc, i, &pfd ); + if (pixel_format) ok( !ret, "SetPixelFormat succeeded\n" ); + else ok( ret, "SetPixelFormat failed\n" ); + if (ret) pixel_format = i; + ret = GetPixelFormat( hdc ); + ok( ret == pixel_format, "got %d\n", ret ); } - }
- if (!pixel_format) - { - skip("Unable to find a suitable pixel format\n"); + winetest_pop_context(); } - else + + ok( !!pixel_format, "got pixel_format %u\n", pixel_format ); + + /* even after changing the selected bitmap */ + + tmp_bmp = SelectObject( hdc, bmp2 ); + ok( tmp_bmp == bmp, "got %p\n", tmp_bmp ); + + for (i = 1; i <= count; i++) { PIXELFORMATDESCRIPTOR pfd = {0};
- ret = SetPixelFormat( hdc, pixel_format, &pfd ); - ok( ret, "SetPixelFormat failed\n" ); + winetest_push_context( "%u", i ); + + ret = DescribePixelFormat( hdc, i, sizeof(pfd), &pfd ); + ok( ret == count, "got %d\n", ret ); + + ret = SetPixelFormat( hdc, i, &pfd ); + if (pixel_format != i) ok( !ret, "SetPixelFormat succeeded\n" ); + else ok( ret, "SetPixelFormat succeeded\n" ); ret = GetPixelFormat( hdc ); - ok( ret == pixel_format, "GetPixelFormat returned %d/%d\n", ret, pixel_format ); - ret = SetPixelFormat( hdc, pixel_format + 1, &pfd ); - ok( !ret, "SetPixelFormat succeeded\n" ); - hglrc = wglCreateContext( hdc ); - ok(hglrc != NULL, "Unable to create a context\n"); + ok( ret == pixel_format, "got %d\n", ret );
- if(hglrc) - { - GLint viewport[4]; - wglMakeCurrent( hdc, hglrc ); - hglrc2 = wglCreateContext( hdc ); - ok(hglrc2 != NULL, "Unable to create a context\n"); - - /* Note this is RGBA but we read ARGB back */ - glClearColor((float)0x22/0xff, (float)0x33/0xff, (float)0x44/0xff, (float)0x11/0xff); - glClear(GL_COLOR_BUFFER_BIT); - glGetIntegerv( GL_VIEWPORT, viewport ); - glFinish(); - - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - /* Note apparently the alpha channel is not supported by the software renderer (bitmap only works using software) */ - if (pixels) - for (i = 0; i < 16; i++) - ok( pixels[i] == 0x223344 || pixels[i] == 0x11223344, - "Received color=%x at %u\n", pixels[i], i ); - - SelectObject( hdc, bmp2 ); - ret = GetPixelFormat( hdc ); - ok( ret == pixel_format, "GetPixelFormat returned %d/%d\n", ret, pixel_format ); - ret = SetPixelFormat( hdc, pixel_format + 1, &pfd ); - ok( !ret, "SetPixelFormat succeeded\n" ); - - /* context still uses the old pixel format and viewport */ - glClearColor((float)0x44/0xff, (float)0x33/0xff, (float)0x22/0xff, (float)0x11/0xff); - glClear(GL_COLOR_BUFFER_BIT); - glFinish(); - glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - - wglMakeCurrent(NULL, NULL); - wglMakeCurrent( hdc, hglrc ); - glClearColor((float)0x44/0xff, (float)0x55/0xff, (float)0x66/0xff, (float)0x11/0xff); - glClear(GL_COLOR_BUFFER_BIT); - glFinish(); - glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - - wglMakeCurrent( hdc, hglrc2 ); - glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - - wglMakeCurrent( hdc, hglrc ); - glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - - SelectObject( hdc, bmp ); - ret = GetPixelFormat( hdc ); - ok( ret == pixel_format, "GetPixelFormat returned %d/%d\n", ret, pixel_format ); - ret = SetPixelFormat( hdc, pixel_format + 1, &pfd ); - ok( !ret, "SetPixelFormat succeeded\n" ); - wglMakeCurrent( hdc, hglrc2 ); - glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - - wglDeleteContext(hglrc2); - wglDeleteContext(hglrc); - } + winetest_pop_context(); }
+ tmp_bmp = SelectObject( hdc, bmp ); + ok( tmp_bmp == bmp2, "got %p\n", tmp_bmp ); + + /* creating a GL context now works */ + + hglrc = wglCreateContext( hdc ); + ok( !!hglrc, "wglCreateContext failed, error %lu\n", GetLastError() ); + ret = wglMakeCurrent( hdc, hglrc ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + + hglrc2 = wglCreateContext( hdc ); + ok( hglrc2 != NULL, "Unable to create a context\n" ); + + /* Note this is RGBA but we read ARGB back */ + glClearColor( (float)0x22 / 0xff, (float)0x33 / 0xff, (float)0x44 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + glGetIntegerv( GL_VIEWPORT, viewport ); + glFinish(); + + ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, + "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + /* Note apparently the alpha channel is not supported by the software renderer (bitmap only works using software) */ + for (i = 0; pixels && i < 16; i++) ok( pixels[i] == 0x223344 || pixels[i] == 0x11223344, "Received color=%x at %u\n", pixels[i], i ); + + tmp_bmp = SelectObject( hdc, bmp2 ); + ok( tmp_bmp == bmp, "got %p\n", tmp_bmp ); + + /* context still uses the old pixel format and viewport */ + glClearColor( (float)0x44 / 0xff, (float)0x33 / 0xff, (float)0x22 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + glFinish(); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, + "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + + wglMakeCurrent( NULL, NULL ); + wglMakeCurrent( hdc, hglrc ); + glClearColor( (float)0x44 / 0xff, (float)0x55 / 0xff, (float)0x66 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + glFinish(); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, + "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + + wglMakeCurrent( hdc, hglrc2 ); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, + "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + + wglMakeCurrent( hdc, hglrc ); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, + "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + + tmp_bmp = SelectObject( hdc, bmp ); + ok( tmp_bmp == bmp2, "got %p\n", tmp_bmp ); + + wglMakeCurrent( hdc, hglrc2 ); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, + "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + + wglDeleteContext( hglrc2 ); + wglDeleteContext( hglrc ); + SelectObject( hdc, old_bmp ); DeleteObject(bmp2); DeleteObject( bmp );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/tests/opengl.c | 214 +++++++++++++++++++++++++++++------ 1 file changed, 182 insertions(+), 32 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index a56702e34ef..8a1a82b66e5 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -859,14 +859,33 @@ static void test_acceleration(HDC hdc) } }
+static void read_bitmap_pixels( HDC hdc, HBITMAP bmp, UINT *pixels, UINT width, UINT height, UINT bpp ) +{ + BITMAPINFO bmi = + { + .bmiHeader.biSize = sizeof(BITMAPINFOHEADER), + .bmiHeader.biPlanes = 1, + .bmiHeader.biWidth = width, + .bmiHeader.biHeight = -height, + .bmiHeader.biBitCount = bpp, + .bmiHeader.biSizeImage = width * height * bpp / 8, + .bmiHeader.biCompression = BI_RGB, + }; + BOOL ret; + + ret = GetDIBits( hdc, bmp, 0, height, pixels, &bmi, DIB_RGB_COLORS ); + ok( ret, "GetDIBits failed, error %lu\n", GetLastError() ); +} + static void test_bitmap_rendering( BOOL use_dib ) { + static const RECT expect_rect = {0, 0, 4, 4}, expect_rect2 = {0, 0, 12, 12}; BITMAPINFO bmi = {.bmiHeader = {.biSize = sizeof(BITMAPINFOHEADER), .biPlanes = 1, .biCompression = BI_RGB}}; + UINT buffer[16 * 16], buffer2[16 * 16], *pixels = buffer, *pixels2 = buffer2, pixel; int i, ret, bpp, count, pixel_format = 0; HBITMAP bmp, old_bmp, bmp2, tmp_bmp; + GLint viewport[4], object; HGLRC hglrc, hglrc2; - UINT *pixels = NULL; - GLint viewport[4]; HDC hdc;
winetest_push_context( use_dib ? "DIB" : "DDB" ); @@ -880,17 +899,21 @@ static void test_bitmap_rendering( BOOL use_dib ) bmi.bmiHeader.biHeight = -4; bmi.bmiHeader.biBitCount = 32; bmp = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, (void **)&pixels, NULL, 0 ); + memset( (void *)pixels, 0xcd, sizeof(*pixels) * 4 * 4 );
bmi.bmiHeader.biWidth = 12; bmi.bmiHeader.biHeight = -12; bmi.bmiHeader.biBitCount = 16; - bmp2 = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, NULL, NULL, 0 ); + bmp2 = CreateDIBSection( 0, &bmi, DIB_RGB_COLORS, (void **)&pixels2, NULL, 0 ); + memset( (void *)pixels2, 0xdc, sizeof(*pixels2) * 12 * 12 ); } else { bpp = GetDeviceCaps( hdc, BITSPIXEL ); - bmp = CreateBitmap( 4, 4, 1, bpp, NULL ); - bmp2 = CreateBitmap( 12, 12, 1, bpp, NULL ); + memset( (void *)pixels, 0xcd, sizeof(*pixels) * 4 * 4 ); + bmp = CreateBitmap( 4, 4, 1, bpp, pixels ); + memset( (void *)pixels2, 0xdc, sizeof(*pixels2) * 12 * 12 ); + bmp2 = CreateBitmap( 12, 12, 1, bpp, pixels2 ); }
ret = GetPixelFormat( hdc ); @@ -904,8 +927,7 @@ static void test_bitmap_rendering( BOOL use_dib ) /* cannot create a GL context without a pixel format */
hglrc = wglCreateContext( hdc ); - todo_wine - ok( !hglrc, "wglCreateContext succeeded\n" ); + todo_wine ok( !hglrc, "wglCreateContext succeeded\n" ); if (hglrc) wglDeleteContext( hglrc );
/* cannot set pixel format twice */ @@ -968,63 +990,191 @@ static void test_bitmap_rendering( BOOL use_dib ) ret = wglMakeCurrent( hdc, hglrc ); ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() );
- hglrc2 = wglCreateContext( hdc ); - ok( hglrc2 != NULL, "Unable to create a context\n" ); + glGetIntegerv( GL_READ_BUFFER, &object ); + ok( object == GL_FRONT, "got %u\n", object ); + glGetIntegerv( GL_DRAW_BUFFER, &object ); + ok( object == GL_FRONT, "got %u\n", object ); + + memset( viewport, 0xcd, sizeof(viewport) ); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( EqualRect( (RECT *)viewport, &expect_rect ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) ); + + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + todo_wine ok( (pixel & 0xffffff) == 0xcdcdcd, "got %#x\n", pixel );
- /* Note this is RGBA but we read ARGB back */ glClearColor( (float)0x22 / 0xff, (float)0x33 / 0xff, (float)0x44 / 0xff, (float)0x11 / 0xff ); glClear( GL_COLOR_BUFFER_BIT ); - glGetIntegerv( GL_VIEWPORT, viewport ); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + ok( (pixels[0] & 0xffffff) == 0xcdcdcd, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] ); + glFinish(); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x443322, "got %#x\n", pixel ); + + + glClearColor( (float)0x55 / 0xff, (float)0x66 / 0xff, (float)0x77 / 0xff, (float)0x88 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] ); + + glFlush(); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + ok( (pixels[0] & 0xffffff) == 0x556677, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x776655, "got %#x\n", pixel ); + + + glClearColor( (float)0x22 / 0xff, (float)0x33 / 0xff, (float)0x44 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + ok( (pixels[0] & 0xffffff) == 0x556677, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] ); + + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x443322, "got %#x\n", pixel ); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] );
- ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); - /* Note apparently the alpha channel is not supported by the software renderer (bitmap only works using software) */ - for (i = 0; pixels && i < 16; i++) ok( pixels[i] == 0x223344 || pixels[i] == 0x11223344, "Received color=%x at %u\n", pixels[i], i );
tmp_bmp = SelectObject( hdc, bmp2 ); ok( tmp_bmp == bmp, "got %p\n", tmp_bmp );
/* context still uses the old pixel format and viewport */ + memset( viewport, 0xcd, sizeof(viewport) ); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( EqualRect( (RECT *)viewport, &expect_rect ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) ); + + /* pixels are read from the selected bitmap */ + + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + todo_wine ok( (pixel & 0xffffff) == 0xdcdcdc, "got %#x\n", pixel ); + + if (use_dib) + { + memset( buffer2, 0xa5, sizeof(buffer2) ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + todo_wine ok( (pixel & 0xffffff) == 0xdcdcdc, "got %#x\n", pixel ); + memset( buffer2, 0xdc, sizeof(buffer2) ); + } + + /* GL doesn't render to the bitmap that was selected on wglMakeCurrent, but + * copies to the bitmap that is currently selected on the HDC on Finish/Flush. + */ + glClearColor( (float)0x44 / 0xff, (float)0x33 / 0xff, (float)0x22 / 0xff, (float)0x11 / 0xff ); glClear( GL_COLOR_BUFFER_BIT ); + + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0xdcdcdc, "got %#x\n", pixels2[0] ); + glFinish(); + + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + todo_wine ok( (pixels2[0] & 0xffffff) == 0x443322, "got %#x\n", pixels2[0] ); + + + ret = wglMakeCurrent( NULL, NULL ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + ret = wglMakeCurrent( hdc, hglrc ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + + memset( viewport, 0xcd, sizeof(viewport) ); glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + ok( EqualRect( (RECT *)viewport, &expect_rect ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) );
- wglMakeCurrent( NULL, NULL ); - wglMakeCurrent( hdc, hglrc ); glClearColor( (float)0x44 / 0xff, (float)0x55 / 0xff, (float)0x66 / 0xff, (float)0x11 / 0xff ); glClear( GL_COLOR_BUFFER_BIT ); glFinish(); - glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] );
- wglMakeCurrent( hdc, hglrc2 ); + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0x445566, "got %#x\n", pixels2[0] ); + + + /* creating a context uses the currently selected bitmap size as viewport */ + + hglrc2 = wglCreateContext( hdc ); + ok( !!hglrc2, "wglCreateContext failed, error %lu\n", GetLastError() ); + + ret = wglMakeCurrent( hdc, hglrc2 ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + + memset( viewport, 0xcd, sizeof(viewport) ); glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + ok( EqualRect( (RECT *)viewport, &expect_rect2 ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) ); + + glClearColor( (float)0x66 / 0xff, (float)0x55 / 0xff, (float)0x44 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + glFinish(); + + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + if (use_dib) todo_wine ok( (pixels2[0] & 0xffffff) == 0x03148, "got %#x\n", pixels2[0] ); + else ok( (pixels2[0] & 0xffffff) == 0x665544, "got %#x\n", pixels2[0] );
- wglMakeCurrent( hdc, hglrc ); + ret = wglMakeCurrent( hdc, hglrc ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + + memset( viewport, 0xcd, sizeof(viewport) ); glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 4 && viewport[3] == 4, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + ok( EqualRect( (RECT *)viewport, &expect_rect ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) ); + + glClearColor( (float)0x66 / 0xff, (float)0x77 / 0xff, (float)0x88 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + glFinish(); + + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x223344, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0x667788, "got %#x\n", pixels2[0] ); +
tmp_bmp = SelectObject( hdc, bmp ); ok( tmp_bmp == bmp2, "got %p\n", tmp_bmp );
- wglMakeCurrent( hdc, hglrc2 ); + ret = wglMakeCurrent( hdc, hglrc2 ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + + memset( viewport, 0xcd, sizeof(viewport) ); glGetIntegerv( GL_VIEWPORT, viewport ); - ok( viewport[0] == 0 && viewport[1] == 0 && viewport[2] == 12 && viewport[3] == 12, - "wrong viewport %d,%d,%d,%d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); + ok( EqualRect( (RECT *)viewport, &expect_rect2 ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) ); + + glClearColor( (float)0x88 / 0xff, (float)0x77 / 0xff, (float)0x66 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + glFinish(); + + if (pixels == buffer) read_bitmap_pixels( hdc, bmp, pixels, 4, 4, bpp ); + if (pixels2 == buffer2) read_bitmap_pixels( hdc, bmp2, pixels2, 12, 12, bpp ); + if (use_dib) todo_wine ok( (pixels[0] & 0xffffff) == 0x45cc, "got %#x\n", pixels[0] ); + else ok( (pixels[0] & 0xffffff) == 0x887766, "got %#x\n", pixels[0] ); + ok( (pixels2[0] & 0xffffff) == 0x667788, "got %#x\n", pixels2[0] );
wglDeleteContext( hglrc2 ); wglDeleteContext( hglrc );
SelectObject( hdc, old_bmp ); - DeleteObject(bmp2); + DeleteObject( bmp2 ); DeleteObject( bmp ); DeleteDC( hdc );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/gdi32/tests/bitmap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 9400c534e90..773e0fad5ee 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -5704,7 +5704,7 @@ static void test_D3DKMTCreateDCFromMemory( void ) DWORD type, pixel; int size; HDC bmp_dc; - HBITMAP bmp; + HBITMAP bmp, bmp2, tmp_bmp;
static const struct { @@ -5894,6 +5894,12 @@ static void test_D3DKMTCreateDCFromMemory( void ) ret = BitBlt( bmp_dc, 0, 0, create_desc.Width, create_desc.Height, create_desc.hDc, 0, 0, SRCCOPY ); ok(ret, "Failed to blit.\n");
+ /* cannot select a different bitmap on D3DKMT DCs */ + bmp2 = CreateBitmap( 4, 4, 1, 32, NULL ); + tmp_bmp = SelectObject( create_desc.hDc, bmp2 ); + todo_wine ok( !tmp_bmp, "SelectObject succeeded\n" ); + DeleteObject( bmp2 ); + destroy_desc.hDc = create_desc.hDc; destroy_desc.hBitmap = create_desc.hBitmap;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/tests/opengl.c | 144 ++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-)
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 8a1a82b66e5..387673481e0 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -18,13 +18,27 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include <windows.h> -#include <wingdi.h> +#include <stdarg.h> +#include <stddef.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "wingdi.h" +#include "winuser.h" +#include "winternl.h" +#include "ddk/d3dkmthk.h" + #include "wine/test.h" #include "wine/wgl.h"
#define MAX_FORMATS 256
+static NTSTATUS (WINAPI *pD3DKMTCreateDCFromMemory)( D3DKMT_CREATEDCFROMMEMORY *desc ); +static NTSTATUS (WINAPI *pD3DKMTDestroyDCFromMemory)( const D3DKMT_DESTROYDCFROMMEMORY *desc ); + /* WGL_ARB_create_context */ static HGLRC (WINAPI *pwglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext, const int *attribList);
@@ -1181,6 +1195,126 @@ static void test_bitmap_rendering( BOOL use_dib ) winetest_pop_context(); }
+static void test_d3dkmt_rendering(void) +{ + static const RECT expect_rect = {0, 0, 4, 4}; + int i, ret, count, pixel_format = 0; + D3DKMT_CREATEDCFROMMEMORY create; + D3DKMT_DESTROYDCFROMMEMORY desc; + UINT pixels[16 * 16], pixel; + GLint viewport[4], object; + NTSTATUS status; + HGLRC hglrc; + + create.pMemory = pixels; + create.Format = D3DDDIFMT_A8R8G8B8; + create.Width = 4; + create.Height = 4; + create.Pitch = 4 * 4; + create.hDeviceDc = CreateCompatibleDC( 0 ); + create.pColorTable = NULL; + status = pD3DKMTCreateDCFromMemory( &create ); + ok( !status, "got %#lx\n", status ); + DeleteDC( create.hDeviceDc ); + desc.hBitmap = create.hBitmap; + desc.hDc = create.hDc; + + ret = GetPixelFormat( desc.hDc ); + ok( ret == 0, "got %d\n", ret ); + count = DescribePixelFormat( desc.hDc, 0, 0, NULL ); + ok( count > 1, "got %d\n", count ); + + /* cannot create a GL context without a pixel format */ + + hglrc = wglCreateContext( desc.hDc ); + todo_wine ok( !hglrc, "wglCreateContext succeeded\n" ); + if (hglrc) wglDeleteContext( hglrc ); + + /* cannot set pixel format twice */ + + for (i = 1; i <= count; i++) + { + PIXELFORMATDESCRIPTOR pfd = {0}; + + winetest_push_context( "%u", i ); + + ret = DescribePixelFormat( desc.hDc, i, sizeof(pfd), &pfd ); + ok( ret == count, "got %d\n", ret ); + + if ((pfd.dwFlags & PFD_DRAW_TO_BITMAP) && (pfd.dwFlags & PFD_SUPPORT_OPENGL) && + pfd.cColorBits == 32 && pfd.cAlphaBits == 8) + { + ret = SetPixelFormat( desc.hDc, i, &pfd ); + if (pixel_format) ok( !ret, "SetPixelFormat succeeded\n" ); + else ok( ret, "SetPixelFormat failed\n" ); + if (ret) pixel_format = i; + ret = GetPixelFormat( desc.hDc ); + ok( ret == pixel_format, "got %d\n", ret ); + } + + winetest_pop_context(); + } + + ok( !!pixel_format, "got pixel_format %u\n", pixel_format ); + + /* creating a GL context now works */ + + hglrc = wglCreateContext( desc.hDc ); + ok( !!hglrc, "wglCreateContext failed, error %lu\n", GetLastError() ); + ret = wglMakeCurrent( desc.hDc, hglrc ); + ok( ret, "wglMakeCurrent failed, error %lu\n", GetLastError() ); + + glGetIntegerv( GL_READ_BUFFER, &object ); + ok( object == GL_FRONT, "got %u\n", object ); + glGetIntegerv( GL_DRAW_BUFFER, &object ); + ok( object == GL_FRONT, "got %u\n", object ); + + memset( viewport, 0xcd, sizeof(viewport) ); + glGetIntegerv( GL_VIEWPORT, viewport ); + ok( EqualRect( (RECT *)viewport, &expect_rect ), "got viewport %s\n", wine_dbgstr_rect( (RECT *)viewport ) ); + + memset( (void *)pixels, 0xcd, sizeof(*pixels) * 4 * 4 ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + todo_wine ok( (pixel & 0xffffff) == 0xcdcdcd, "got %#x\n", pixel ); + + glClearColor( (float)0x44 / 0xff, (float)0x33 / 0xff, (float)0x22 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + ok( (pixels[0] & 0xffffff) == 0xcdcdcd, "got %#x\n", pixels[0] ); + glFinish(); + ok( (pixels[0] & 0xffffff) == 0x443322, "got %#x\n", pixels[0] ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); + + glClearColor( (float)0x55 / 0xff, (float)0x66 / 0xff, (float)0x77 / 0xff, (float)0x88 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + ok( (pixels[0] & 0xffffff) == 0x443322, "got %#x\n", pixels[0] ); + glFlush(); + ok( (pixels[0] & 0xffffff) == 0x556677, "got %#x\n", pixels[0] ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x776655, "got %#x\n", pixel ); + + glClearColor( (float)0x44 / 0xff, (float)0x33 / 0xff, (float)0x22 / 0xff, (float)0x11 / 0xff ); + glClear( GL_COLOR_BUFFER_BIT ); + ok( (pixels[0] & 0xffffff) == 0x556677, "got %#x\n", pixels[0] ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); + todo_wine ok( (pixels[0] & 0xffffff) == 0x443322, "got %#x\n", pixels[0] ); + + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + ok( (pixel & 0xffffff) == 0x223344, "got %#x\n", pixel ); + memset( pixels, 0xa5, sizeof(pixels) ); + glReadPixels( 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel ); + todo_wine ok( (pixel & 0xffffff) == 0xa5a5a5, "got %#x\n", pixel ); + memset( pixels, 0xcd, sizeof(pixels) ); + + wglDeleteContext( hglrc ); + + status = pD3DKMTDestroyDCFromMemory( &desc ); + ok( !status, "got %#lx\n", status ); + + winetest_pop_context(); +} + struct wgl_thread_param { HANDLE test_finished; @@ -2352,10 +2486,15 @@ START_TEST(opengl) ok(hwnd != NULL, "err: %ld\n", GetLastError()); if (hwnd) { + HMODULE gdi32 = GetModuleHandleA("gdi32.dll"); HDC hdc; int iPixelFormat, res; HGLRC hglrc; DWORD error; + + pD3DKMTCreateDCFromMemory = (void *)GetProcAddress( gdi32, "D3DKMTCreateDCFromMemory" ); + pD3DKMTDestroyDCFromMemory = (void *)GetProcAddress( gdi32, "D3DKMTDestroyDCFromMemory" ); + ShowWindow(hwnd, SW_SHOW);
hdc = GetDC(hwnd); @@ -2379,6 +2518,7 @@ START_TEST(opengl)
test_bitmap_rendering( TRUE ); test_bitmap_rendering( FALSE ); + test_d3dkmt_rendering(); test_minimized(); test_window_dc(); test_message_window();