3 * Copyright (C) 2003 ReactOS Team
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 typedef int (*CHOOSEPIXELFMT
) (HDC
, CONST PIXELFORMATDESCRIPTOR
*);
32 typedef BOOL (*SETPIXELFMT
) (HDC
, int, CONST PIXELFORMATDESCRIPTOR
*);
33 typedef BOOL (*SWAPBUFFERS
) (HDC hdc
);
34 typedef int (*DESCRIBEPIXELFMT
) (HDC
, int, UINT
, LPPIXELFORMATDESCRIPTOR
);
35 typedef int (*GETPIXELFMT
) (HDC
);
38 static CHOOSEPIXELFMT glChoosePixelFormat
= NULL
;
39 static SETPIXELFMT glSetPixelFormat
= NULL
;
40 static SWAPBUFFERS glSwapBuffers
= NULL
;
41 static DESCRIBEPIXELFMT glDescribePixelFormat
= NULL
;
42 static GETPIXELFMT glGetPixelFormat
= NULL
;
47 HINSTANCE hOpenGL
= NULL
;
49 static BOOL
OpenGLEnable(void)
53 hOpenGL
= LoadLibraryA("OPENGL32.DLL");
58 if(glChoosePixelFormat
== NULL
) {
59 glChoosePixelFormat
= (CHOOSEPIXELFMT
)GetProcAddress(hOpenGL
, "wglChoosePixelFormat");
60 if(glChoosePixelFormat
== NULL
)
64 if(glSetPixelFormat
== NULL
) {
65 glSetPixelFormat
= (SETPIXELFMT
)GetProcAddress(hOpenGL
, "wglSetPixelFormat");
66 if(glSetPixelFormat
== NULL
)
70 if(glSwapBuffers
== NULL
) {
71 glSwapBuffers
= (SWAPBUFFERS
)GetProcAddress(hOpenGL
, "wglSwapBuffers");
72 if(glSwapBuffers
== NULL
)
76 if(glDescribePixelFormat
== NULL
) {
77 glDescribePixelFormat
= (DESCRIBEPIXELFMT
)GetProcAddress(hOpenGL
, "wglDescribePixelFormat");
78 if(glDescribePixelFormat
== NULL
)
82 if(glGetPixelFormat
== NULL
) {
83 glGetPixelFormat
= (GETPIXELFMT
)GetProcAddress(hOpenGL
, "wglGetPixelFormat");
84 if(glGetPixelFormat
== NULL
)
88 return(TRUE
); /* OpenGL is initialized and enabled*/
98 ChoosePixelFormat(HDC hdc
,
99 CONST PIXELFORMATDESCRIPTOR
* ppfd
)
101 if (glChoosePixelFormat
== NULL
)
102 if (OpenGLEnable() == FALSE
)
105 return(glChoosePixelFormat(hdc
, ppfd
));
115 DescribePixelFormat(HDC hdc
,
118 LPPIXELFORMATDESCRIPTOR ppfd
)
120 if (glDescribePixelFormat
== NULL
)
121 if (OpenGLEnable() == FALSE
)
124 return(glDescribePixelFormat(hdc
, iPixelFormat
, nBytes
, ppfd
));
134 GetPixelFormat(HDC hdc
)
136 if (glGetPixelFormat
== NULL
)
137 if (OpenGLEnable() == FALSE
)
140 return(glGetPixelFormat(hdc
));
150 SetPixelFormat(HDC hdc
,
152 CONST PIXELFORMATDESCRIPTOR
* ppfd
)
154 if (glSetPixelFormat
== NULL
)
155 if (OpenGLEnable() == FALSE
)
158 return(glSetPixelFormat(hdc
, iPixelFormat
, ppfd
));
170 if (glSwapBuffers
== NULL
)
171 if (OpenGLEnable() == FALSE
)
175 return(glSwapBuffers(hdc
));
180 Do this here for now.
188 GetEnhMetaFilePixelFormat(
191 PIXELFORMATDESCRIPTOR
*ppfd
196 if(GetEnhMetaFileHeader(hemf
, sizeof(ENHMETAHEADER
), &pemh
))
200 if(pemh
.cbPixelFormat
)
202 memcpy((void*)ppfd
, UlongToPtr(pemh
.offPixelFormat
), cbBuffer
);
203 return(pemh
.cbPixelFormat
);