ReactOS 0.4.15-dev-8116-gf69e256
wingl.c
Go to the documentation of this file.
1/*
2 * ReactOS Gdi32
3 * Copyright (C) 2003 ReactOS Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 *
20 *
21 *
22 */
23
24#include <precomp.h>
25
26#define NDEBUG
27#include <debug.h>
28
29
30
36
37
43
44/*
45 OpenGL Handle.
46*/
48
50 FARPROC *funcptr)
51{
52 PVOID func;
53
55 if (func != NULL)
56 {
58 func,
59 NULL);
60 return TRUE;
61 }
62
63 return FALSE;
64}
65
66static BOOL OpenGLEnable(void)
67{
68 HMODULE hModOpengl32;
69 BOOL Ret = TRUE;
70
71 hModOpengl32 = LoadLibraryW(L"OPENGL32.DLL");
72 if (hModOpengl32 == NULL)
73 return FALSE;
74
76 (PVOID)hModOpengl32,
77 NULL) != NULL)
78 {
79 FreeLibrary(hModOpengl32);
80
81 /* NOTE: Even though another thread was faster loading the
82 library we can't just bail out here. We really need
83 to *try* to locate every function. This is slow but
84 thread-safe */
85 }
86
87 /* The cast is required on x64, because FARPROC has INT_PTR sized return */
88 if (!OpenGLInitFunction("wglChoosePixelFormat", (FARPROC*)&glChoosePixelFormat))
89 Ret = FALSE;
90
91 if (!OpenGLInitFunction("wglSetPixelFormat", (FARPROC*)&glSetPixelFormat))
92 Ret = FALSE;
93
94 if (!OpenGLInitFunction("wglSwapBuffers", (FARPROC*)&glSwapBuffers))
95 Ret = FALSE;
96
97 if (!OpenGLInitFunction("wglDescribePixelFormat", (FARPROC*)&glDescribePixelFormat))
98 Ret = FALSE;
99
100 if (!OpenGLInitFunction("wglGetPixelFormat", (FARPROC*)&glGetPixelFormat))
101 Ret = FALSE;
102
103 return Ret;
104}
105
106
107
108/*
109 * @implemented
110 */
111INT
112WINAPI
115{
117 if (OpenGLEnable() == FALSE)
118 return(0);
119
120 return(glChoosePixelFormat(hdc, ppfd));
121}
122
123
124
125/*
126 * @implemented
127 */
128INT
129WINAPI
132 UINT nBytes,
134{
136 if (OpenGLEnable() == FALSE)
137 return(0);
138
139 return(glDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd));
140}
141
142
143
144/*
145 * @implemented
146 */
147INT
148WINAPI
150{
151 if (glGetPixelFormat == NULL)
152 if (OpenGLEnable() == FALSE)
153 return(0);
154
155 return(glGetPixelFormat(hdc));
156}
157
158
159
160/*
161 * @implemented
162 */
163BOOL
164WINAPI
168{
169 /* Can only be set once */
171 if(current) return current == iPixelFormat ;
172
173 if (glSetPixelFormat == NULL)
174 if (OpenGLEnable() == FALSE)
175 return(0);
176
178}
179
180
181
182/*
183 * @implemented
184 */
185BOOL
186WINAPI
188{
189 if (glSwapBuffers == NULL)
190 if (OpenGLEnable() == FALSE)
191 return(0);
192
193
194 return(glSwapBuffers(hdc));
195}
196
197
198/*
199 Do this here for now.
200*/
201
202/* EOF */
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
int(* FARPROC)()
Definition: compat.h:36
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned int BOOL
Definition: ntddk_ex.h:94
int(WINAPI * GETPIXELFMT)(HDC)
Definition: wingl.c:35
BOOL WINAPI SwapBuffers(HDC hdc)
Definition: wingl.c:187
int(WINAPI * CHOOSEPIXELFMT)(HDC, CONST PIXELFORMATDESCRIPTOR *)
Definition: wingl.c:31
HINSTANCE hOpenGL
Definition: wingl.c:47
BOOL(WINAPI * SETPIXELFMT)(HDC, int, CONST PIXELFORMATDESCRIPTOR *)
Definition: wingl.c:32
static SETPIXELFMT glSetPixelFormat
Definition: wingl.c:39
BOOL(WINAPI * SWAPBUFFERS)(HDC hdc)
Definition: wingl.c:33
static DESCRIBEPIXELFMT glDescribePixelFormat
Definition: wingl.c:41
INT WINAPI DescribePixelFormat(HDC hdc, INT iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
Definition: wingl.c:130
static SWAPBUFFERS glSwapBuffers
Definition: wingl.c:40
static BOOL OpenGLInitFunction(PCSTR name, FARPROC *funcptr)
Definition: wingl.c:49
static BOOL OpenGLEnable(void)
Definition: wingl.c:66
static CHOOSEPIXELFMT glChoosePixelFormat
Definition: wingl.c:38
BOOL WINAPI SetPixelFormat(HDC hdc, INT iPixelFormat, CONST PIXELFORMATDESCRIPTOR *ppfd)
Definition: wingl.c:165
int(WINAPI * DESCRIBEPIXELFMT)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR)
Definition: wingl.c:34
static GETPIXELFMT glGetPixelFormat
Definition: wingl.c:42
INT WINAPI GetPixelFormat(HDC hdc)
Definition: wingl.c:149
INT WINAPI ChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd)
Definition: wingl.c:113
GLenum func
Definition: glext.h:6028
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
struct task_struct * current
Definition: linux.c:32
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
#define CONST
Definition: pedump.c:81
Definition: name.c:39
void * PVOID
Definition: typedefs.h:50
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
_In_ LONG iPixelFormat
Definition: winddi.h:3488
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3490
#define WINAPI
Definition: msvc.h:6
struct tagPIXELFORMATDESCRIPTOR * LPPIXELFORMATDESCRIPTOR