Henri Verbeet : opengl32/tests: Add a test for GL on window DCs.

Alexandre Julliard julliard at winehq.org
Thu May 5 12:08:06 CDT 2011


Module: wine
Branch: master
Commit: ef5a99d5e0a0fe75d0187a56175f433461fe01a9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ef5a99d5e0a0fe75d0187a56175f433461fe01a9

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed May  4 22:18:42 2011 +0200

opengl32/tests: Add a test for GL on window DCs.

---

 dlls/opengl32/tests/opengl.c |   74 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index 64b9ee5..e98b7b7 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -26,6 +26,7 @@ void WINAPI glClearColor(float red, float green, float blue, float alpha);
 void WINAPI glClear(unsigned int mask);
 #define GL_COLOR 0x1800
 typedef unsigned int GLenum;
+typedef int GLint;
 void WINAPI glCopyPixels(int x, int y, int width, int height, GLenum type);
 void WINAPI glFinish(void);
 #define GL_NO_ERROR 0x0
@@ -37,6 +38,9 @@ const unsigned char * WINAPI glGetString(unsigned int);
 #define GL_RENDERER 0x1F01
 #define GL_VERSION 0x1F02
 
+#define GL_VIEWPORT 0x0ba2
+void WINAPI glGetIntegerv(GLenum pname, GLint *params);
+
 #define MAX_FORMATS 256
 typedef void* HPBUFFERARB;
 
@@ -888,6 +892,75 @@ static void test_minimized(void)
     DestroyWindow(window);
 }
 
+static void test_window_dc(void)
+{
+    PIXELFORMATDESCRIPTOR pf_desc =
+    {
+        sizeof(PIXELFORMATDESCRIPTOR),
+        1,                     /* version */
+        PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
+        PFD_TYPE_RGBA,
+        24,                    /* 24-bit color depth */
+        0, 0, 0, 0, 0, 0,      /* color bits */
+        0,                     /* alpha buffer */
+        0,                     /* shift bit */
+        0,                     /* accumulation buffer */
+        0, 0, 0, 0,            /* accum bits */
+        32,                    /* z-buffer */
+        0,                     /* stencil buffer */
+        0,                     /* auxiliary buffer */
+        PFD_MAIN_PLANE,        /* main layer */
+        0,                     /* reserved */
+        0, 0, 0                /* layer masks */
+    };
+    int pixel_format;
+    HWND window;
+    RECT vp, r;
+    HGLRC ctx;
+    BOOL ret;
+    HDC dc;
+
+    window = CreateWindowA("static", "opengl32_test",
+            WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, 0, 0, 0, 0);
+    ok(!!window, "Failed to create window, last error %#x.\n", GetLastError());
+
+    ShowWindow(window, SW_SHOW);
+
+    dc = GetWindowDC(window);
+    ok(!!dc, "Failed to get DC.\n");
+
+    pixel_format = ChoosePixelFormat(dc, &pf_desc);
+    if (!pixel_format)
+    {
+        win_skip("Failed to find pixel format.\n");
+        ReleaseDC(window, dc);
+        DestroyWindow(window);
+        return;
+    }
+
+    ret = SetPixelFormat(dc, pixel_format, &pf_desc);
+    ok(ret, "Failed to set pixel format, last error %#x.\n", GetLastError());
+
+    ctx = wglCreateContext(dc);
+    ok(!!ctx, "Failed to create GL context, last error %#x.\n", GetLastError());
+
+    ret = wglMakeCurrent(dc, ctx);
+    ok(ret, "Failed to make context current, last error %#x.\n", GetLastError());
+
+    GetClientRect(window, &r);
+    glGetIntegerv(GL_VIEWPORT, (GLint *)&vp);
+    ok(EqualRect(&r, &vp), "Viewport not equal to client rect.\n");
+
+    ret = wglMakeCurrent(NULL, NULL);
+    ok(ret, "Failed to clear current context, last error %#x.\n", GetLastError());
+
+    ret = wglDeleteContext(ctx);
+    ok(ret, "Failed to delete GL context, last error %#x.\n", GetLastError());
+
+    ReleaseDC(window, dc);
+    DestroyWindow(window);
+}
+
 static void test_destroy(HDC oldhdc)
 {
     PIXELFORMATDESCRIPTOR pf_desc =
@@ -1234,6 +1307,7 @@ START_TEST(opengl)
 
         test_bitmap_rendering();
         test_minimized();
+        test_window_dc();
         test_dc(hwnd, hdc);
 
         hglrc = wglCreateContext(hdc);




More information about the wine-cvs mailing list