1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         BSD - See COPYING.ARM in the top level directory
4  * PURPOSE:         Tests extensions exposed by the software implementation
5  * PROGRAMMERS:     J�r�me Gardou
6  */
7 
8 #include <windows.h>
9 #include <wingdi.h>
10 #include <GL/gl.h>
11 
12 #include "wine/test.h"
13 
14 START_TEST(sw_extensions)
15 {
16     BITMAPINFO biDst;
17     HDC hdcDst = CreateCompatibleDC(0);
18     HBITMAP bmpDst, bmpOld;
19     INT nFormats, iPixelFormat, res, i;
20     PIXELFORMATDESCRIPTOR pfd;
21     const char* output;
22     HGLRC Context;
23     UINT *dstBuffer = NULL;
24 
25     memset(&biDst, 0, sizeof(BITMAPINFO));
26     biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
27     biDst.bmiHeader.biWidth = 4;
28     biDst.bmiHeader.biHeight = -4;
29     biDst.bmiHeader.biPlanes = 1;
30     biDst.bmiHeader.biBitCount = 32;
31     biDst.bmiHeader.biCompression = BI_RGB;
32 
33     bmpDst = CreateDIBSection(0, &biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0);
34 
35     bmpOld = SelectObject(hdcDst, bmpDst);
36 
37     /* Choose a pixel format */
38     nFormats = DescribePixelFormat(hdcDst, 0, 0, NULL);
39     for(i=1; i<=nFormats; i++)
40     {
41         memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
42         DescribePixelFormat(hdcDst, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
43 
44         if((pfd.dwFlags & PFD_DRAW_TO_BITMAP) &&
45            (pfd.dwFlags & PFD_SUPPORT_OPENGL) &&
46            (pfd.cColorBits == 32) &&
47            (pfd.cAlphaBits == 8) )
48         {
49             iPixelFormat = i;
50             break;
51         }
52     }
53 
54     ok(pfd.dwFlags & PFD_GENERIC_FORMAT, "We found a pixel format for drawing to bitmap which is not generic !\n");
55     ok (iPixelFormat >= 1 && iPixelFormat <= nFormats, "Could not find a suitable pixel format.\n");
56     res = SetPixelFormat(hdcDst, iPixelFormat, &pfd);
57     ok (res != 0, "SetPixelFormat failed.\n");
58     Context = wglCreateContext(hdcDst);
59     ok(Context != NULL, "We failed to create a GL context.\n");
60     wglMakeCurrent(hdcDst, Context);
61 
62     /* Get the version */
63     output = (const char*)glGetString(GL_VERSION);
64     ok(strcmp(output, "1.1.0") == 0, "Expected version 1.1.0, got \"%s\".\n", output);
65 
66     /* Get the extensions list */
67     output = (const char*)glGetString(GL_EXTENSIONS);
68     trace("GL extensions are %s.\n", output);
69     ok (strlen(output) == strlen("GL_WIN_swap_hint GL_EXT_bgra GL_EXT_paletted_texture"), "Wrong extension list : \"%s\".\n", output);
70     ok(strstr(output, "GL_WIN_swap_hint") != NULL, "GL_WIN_swap_hint extension is not present.\n");
71     ok(strstr(output, "GL_EXT_bgra") != NULL, "GL_EXT_bgra extension is not present.\n");
72     ok(strstr(output, "GL_EXT_paletted_texture") != NULL, "GL_EXT_paletted_texture extension is not present.\n");
73 
74     /* cleanup */
75     wglDeleteContext(Context);
76     SelectObject(hdcDst, bmpOld);
77     DeleteDC(hdcDst);
78 }
79