mshtml: Return referenced object in get_node_obj.
[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 #include "wine/debug.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(wgl);
40
41 static const WCHAR opengl32W[] = {'o','p','e','n','g','l','3','2','.','d','l','l',0};
42 static HMODULE opengl32;
43 static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
44 static INT (WINAPI *wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR*);
45 static INT (WINAPI *wglGetPixelFormat)(HDC);
46 static BOOL (WINAPI *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
47 static BOOL (WINAPI *wglSwapBuffers)(HDC);
48
49 /***********************************************************************
50  *      __wine_get_wgl_driver  (GDI32.@)
51  */
52 const struct wgl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version )
53 {
54     const struct wgl_funcs *ret = NULL;
55     DC * dc = get_dc_ptr( hdc );
56
57     if (dc)
58     {
59         PHYSDEV physdev = GET_DC_PHYSDEV( dc, wine_get_wgl_driver );
60         ret = physdev->funcs->wine_get_wgl_driver( physdev, version );
61         release_dc_ptr( dc );
62     }
63     return ret;
64 }
65
66 /******************************************************************************
67  *              ChoosePixelFormat (GDI32.@)
68  */
69 INT WINAPI ChoosePixelFormat( HDC hdc, const PIXELFORMATDESCRIPTOR *pfd )
70 {
71     if (!wglChoosePixelFormat)
72     {
73         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
74         if (!(wglChoosePixelFormat = (void *)GetProcAddress( opengl32, "wglChoosePixelFormat" )))
75             return 0;
76     }
77     return wglChoosePixelFormat( hdc, pfd );
78 }
79
80 /******************************************************************************
81  *              DescribePixelFormat (GDI32.@)
82  */
83 INT WINAPI DescribePixelFormat( HDC hdc, INT fmt, UINT size, PIXELFORMATDESCRIPTOR *pfd )
84 {
85     if (!wglDescribePixelFormat)
86     {
87         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
88         if (!(wglDescribePixelFormat = (void *)GetProcAddress( opengl32, "wglDescribePixelFormat" )))
89             return 0;
90     }
91     return wglDescribePixelFormat( hdc, fmt, size, pfd );
92 }
93
94 /******************************************************************************
95  *              GetPixelFormat (GDI32.@)
96  */
97 INT WINAPI GetPixelFormat( HDC hdc )
98 {
99     if (!wglGetPixelFormat)
100     {
101         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
102         if (!(wglGetPixelFormat = (void *)GetProcAddress( opengl32, "wglGetPixelFormat" )))
103             return 0;
104     }
105     return wglGetPixelFormat( hdc );
106 }
107
108 /******************************************************************************
109  *              SetPixelFormat (GDI32.@)
110  */
111 BOOL WINAPI SetPixelFormat( HDC hdc, INT fmt, const PIXELFORMATDESCRIPTOR *pfd )
112 {
113     if (!wglSetPixelFormat)
114     {
115         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
116         if (!(wglSetPixelFormat = (void *)GetProcAddress( opengl32, "wglSetPixelFormat" )))
117             return 0;
118     }
119     return wglSetPixelFormat( hdc, fmt, pfd );
120 }
121
122 /******************************************************************************
123  *              SwapBuffers (GDI32.@)
124  */
125 BOOL WINAPI SwapBuffers( HDC hdc )
126 {
127     if (!wglSwapBuffers)
128     {
129         if (!opengl32) opengl32 = LoadLibraryW( opengl32W );
130         if (!(wglSwapBuffers = (void *)GetProcAddress( opengl32, "wglSwapBuffers" )))
131             return 0;
132     }
133     return wglSwapBuffers( hdc );
134 }