include: Assorted spelling fixes.
[wine] / dlls / gdi32 / opengl.c
1 /*
2  * OpenGL function forwarding to the display driver
3  *
4  * Copyright (c) 1999 Lionel Ulmer
5  * Copyright (c) 2005 Raphael Junqueira
6  * Copyright (c) 2006 Roderick Colenbrander
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdlib.h>
29
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winerror.h"
34 #include "winternl.h"
35 #include "winnt.h"
36 #include "gdi_private.h"
37
38
39 static const WCHAR opengl32W[] = {'o','p','e','n','g','l','3','2','.','d','l','l',0};
40 static HMODULE opengl32;
41 static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
42 static INT (WINAPI *wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR*);
43 static INT (WINAPI *wglGetPixelFormat)(HDC);
44 static BOOL (WINAPI *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
45 static BOOL (WINAPI *wglSwapBuffers)(HDC);
46
47 /***********************************************************************
48  *      __wine_get_wgl_driver  (GDI32.@)
49  */
50 struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version )
51 {
52     struct opengl_funcs *ret = NULL;
53     DC * dc = get_dc_ptr( hdc );
54
55     if (dc)
56     {
57         PHYSDEV physdev = GET_DC_PHYSDEV( dc, wine_get_wgl_driver );
58         ret = physdev->funcs->wine_get_wgl_driver( physdev, version );
59         release_dc_ptr( dc );
60     }
61     return ret;
62 }
63
64 /******************************************************************************
65  *              ChoosePixelFormat (GDI32.@)
66  */
67 INT WINAPI ChoosePixelFormat( HDC hdc, const PIXELFORMATDESCRIPTOR *pfd )
68 {
69     if (!wglChoosePixelFormat)
70     {
71         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
72         if (!(wglChoosePixelFormat = (void *)GetProcAddress( opengl32, "wglChoosePixelFormat" )))
73             return 0;
74     }
75     return wglChoosePixelFormat( hdc, pfd );
76 }
77
78 /******************************************************************************
79  *              DescribePixelFormat (GDI32.@)
80  */
81 INT WINAPI DescribePixelFormat( HDC hdc, INT fmt, UINT size, PIXELFORMATDESCRIPTOR *pfd )
82 {
83     if (!wglDescribePixelFormat)
84     {
85         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
86         if (!(wglDescribePixelFormat = (void *)GetProcAddress( opengl32, "wglDescribePixelFormat" )))
87             return 0;
88     }
89     return wglDescribePixelFormat( hdc, fmt, size, pfd );
90 }
91
92 /******************************************************************************
93  *              GetPixelFormat (GDI32.@)
94  */
95 INT WINAPI GetPixelFormat( HDC hdc )
96 {
97     if (!wglGetPixelFormat)
98     {
99         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
100         if (!(wglGetPixelFormat = (void *)GetProcAddress( opengl32, "wglGetPixelFormat" )))
101             return 0;
102     }
103     return wglGetPixelFormat( hdc );
104 }
105
106 /******************************************************************************
107  *              SetPixelFormat (GDI32.@)
108  */
109 BOOL WINAPI SetPixelFormat( HDC hdc, INT fmt, const PIXELFORMATDESCRIPTOR *pfd )
110 {
111     if (!wglSetPixelFormat)
112     {
113         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
114         if (!(wglSetPixelFormat = (void *)GetProcAddress( opengl32, "wglSetPixelFormat" )))
115             return 0;
116     }
117     return wglSetPixelFormat( hdc, fmt, pfd );
118 }
119
120 /******************************************************************************
121  *              SwapBuffers (GDI32.@)
122  */
123 BOOL WINAPI SwapBuffers( HDC hdc )
124 {
125     if (!wglSwapBuffers)
126     {
127         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
128         if (!(wglSwapBuffers = (void *)GetProcAddress( opengl32, "wglSwapBuffers" )))
129             return 0;
130     }
131     return wglSwapBuffers( hdc );
132 }