* Sync to trunk HEAD (r53298).
[reactos.git] / dll / win32 / opengl32 / opengl32.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: lib/opengl32/opengl32.h
5 * PURPOSE: OpenGL32 lib
6 * PROGRAMMER: Royce Mitchell III, Anich Gregor (blight)
7 * UPDATE HISTORY:
8 * Feb 1, 2004: Created
9 */
10
11 #ifndef OPENGL32_PRIVATE_H
12 #define OPENGL32_PRIVATE_H
13
14 #define snwprintf _snwprintf
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19
20 #define NDEBUG
21
22 #ifndef PFD_GENERIC_ACCELERATED
23 # define PFD_GENERIC_ACCELERATED 0x00001000
24 #endif
25
26 #define OPENGL_DRIVERS_SUBKEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\OpenGLDrivers"
27 #define OPENGL_DRIVERS_SUBKEY2 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\OpenGLDrivers\\"
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 #define WIN32_LEAN_AND_MEAN
34 #define WIN32_NO_STATUS
35 #include <windows.h>
36 #include <winreg.h>
37
38 #define NTOS_MODE_USER
39 #include <winddi.h>
40 #include <ndk/pstypes.h>
41
42 #include <GL/gl.h>
43 #include <GL/glu.h>
44
45 /* gl function list */
46 #include "glfuncs.h"
47
48 /* ICD index list/types */
49 #include "icdtable.h"
50
51 /* debug flags */
52 #if !defined(NDEBUG)
53 # define DEBUG_OPENGL32
54 /* enable breakpoints */
55 /*# define DEBUG_OPENGL32_BRKPTS*/
56 /* dumps the list of (un)supported glXXX functions when an ICD is loaded. */
57 # define DEBUG_OPENGL32_ICD_EXPORTS
58 /* prints much information about whats going on */
59 # define DEBUG_OPENGL32_TRACE
60 #endif /* !NDEBUG */
61
62 /* debug macros */
63 # ifdef DEBUG_OPENGL32
64 # include <debug.h>
65 # define DBGPRINT( fmt, args... ) \
66 DPRINT( "OpenGL32.DLL: %s: "fmt"\n", __FUNCTION__, ##args )
67 # endif
68
69 #ifndef DBGPRINT
70 # define DBGPRINT( ... ) do {} while (0)
71 #endif
72
73 #ifdef DEBUG_OPENGL32_BRKPTS
74 # if defined(__GNUC__)
75 # define DBGBREAK() __asm__( "int $3" );
76 # elif defined(_MSC_VER)
77 # define DBGBREAK() __asm { int 3 }
78 # else
79 # error Unsupported compiler!
80 # endif
81 #else
82 # define DBGBREAK() do {} while (0)
83 #endif
84
85 #ifdef DEBUG_OPENGL32_TRACE
86 # define DBGTRACE( args... ) DBGPRINT( args )
87 #else
88 # define DBGTRACE( ... ) do {} while (0)
89 #endif
90
91 /* function/data attributes */
92 #define EXPORT __declspec(dllexport)
93 #ifdef _MSC_VER
94 # define NAKED __declspec(naked)
95 # define SHARED
96 # ifndef WINAPI
97 # define WINAPI __stdcall
98 # endif /* WINAPI */
99 #else /* GCC */
100 # define NAKED __attribute__((naked))
101 # define SHARED __attribute__((section("shared"), shared))
102 #endif
103
104 #ifdef APIENTRY
105 #undef APIENTRY
106 #endif /* APIENTRY */
107 #define APIENTRY __stdcall
108
109 /* Called by the driver to set the dispatch table */
110 typedef DWORD (WINAPI *SetContextCallBack)( const ICDTable * );
111
112 /* OpenGL ICD data */
113 typedef struct tagGLDRIVERDATA
114 {
115 HMODULE handle; /*!< DLL handle */
116 UINT refcount; /*!< Number of references to this ICD */
117 WCHAR driver_name[256]; /*!< Name of ICD driver */
118
119 WCHAR dll[256]; /*!< Dll filename from registry */
120 DWORD version; /*!< Version value from registry */
121 DWORD driver_version; /*!< DriverVersion value from registry */
122 DWORD flags; /*!< Flags value from registry */
123
124 BOOL (WINAPI *DrvCopyContext)( HGLRC, HGLRC, UINT );
125 HGLRC (WINAPI *DrvCreateContext)( HDC );
126 HGLRC (WINAPI *DrvCreateLayerContext)( HDC, int );
127 BOOL (WINAPI *DrvDeleteContext)( HGLRC );
128 BOOL (WINAPI *DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
129 int (WINAPI *DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
130 int (WINAPI *DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
131 PROC (WINAPI *DrvGetProcAddress)( LPCSTR lpProcName );
132 void (WINAPI *DrvReleaseContext)( HGLRC hglrc ); /* maybe returns BOOL? */
133 BOOL (WINAPI *DrvRealizeLayerPalette)( HDC, int, BOOL );
134 PICDTable (WINAPI *DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback );
135 int (WINAPI *DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
136 BOOL (WINAPI *DrvSetPixelFormat)( IN HDC, IN int, const PIXELFORMATDESCRIPTOR * );
137 BOOL (WINAPI *DrvShareLists)( HGLRC, HGLRC );
138 BOOL (WINAPI *DrvSwapBuffers)( HDC );
139 BOOL (WINAPI *DrvSwapLayerBuffers)( HDC, UINT );
140 BOOL (WINAPI *DrvValidateVersion)( DWORD );
141
142 struct tagGLDRIVERDATA *next; /* next ICD -- linked list */
143 } GLDRIVERDATA;
144
145 /* Our private OpenGL context (stored in TLS) */
146 typedef struct tagGLRC
147 {
148 GLDRIVERDATA *icd; /*!< driver used for this context */
149 HDC hdc; /*!< DC handle */
150 BOOL is_current; /*!< Wether this context is current for some DC */
151 DWORD thread_id; /*!< Thread holding this context */
152
153 HGLRC hglrc; /*!< GLRC from DrvCreateContext (ICD internal) */
154
155 struct tagGLRC *next; /* linked list */
156 } GLRC;
157
158 /* OpenGL private device context data */
159 typedef struct tagGLDCDATA
160 {
161 HDC hdc; /*!< Device context handle for which this data is */
162 GLDRIVERDATA *icd; /*!< Driver used for this DC */
163 int pixel_format; /*!< Selected pixel format */
164
165 struct tagGLDCDATA *next; /* linked list */
166 } GLDCDATA;
167
168
169 /* Process data */
170 typedef struct tagGLPROCESSDATA
171 {
172 GLDRIVERDATA *driver_list; /*!< List of loaded drivers */
173 HANDLE driver_mutex; /*!< Mutex to protect driver list */
174 GLRC *glrc_list; /*!< List of GL rendering contexts */
175 HANDLE glrc_mutex; /*!< Mutex to protect glrc list */
176 GLDCDATA *dcdata_list; /*!< List of GL private DC data */
177 HANDLE dcdata_mutex; /*!< Mutex to protect glrc list */
178 } GLPROCESSDATA;
179
180 /* TLS data */
181 typedef struct tagGLTHREADDATA
182 {
183 GLRC *glrc; /*!< current GL rendering context */
184 } GLTHREADDATA;
185
186 extern DWORD OPENGL32_tls;
187 extern GLPROCESSDATA OPENGL32_processdata;
188 #define OPENGL32_threaddata ((GLTHREADDATA *)TlsGetValue( OPENGL32_tls ))
189
190 /* function prototypes */
191 GLDRIVERDATA *OPENGL32_LoadICD( LPCWSTR driver );
192 BOOL OPENGL32_UnloadICD( GLDRIVERDATA *icd );
193 BOOL APIENTRY rosglMakeCurrent( HDC hdc, HGLRC hglrc );
194 BOOL APIENTRY IntUseFontBitmapsA( HDC hDC, DWORD first, DWORD count, DWORD listBase );
195 BOOL APIENTRY IntUseFontBitmapsW( HDC hDC, DWORD first, DWORD count, DWORD listBase );
196 BOOL APIENTRY IntUseFontOutlinesA( HDC hDC, DWORD first, DWORD count, DWORD listBase,
197 FLOAT chordalDeviation, FLOAT extrusion, INT format,
198 GLYPHMETRICSFLOAT *glyphMetricsFloatArray );
199 BOOL APIENTRY IntUseFontOutlinesW( HDC hDC, DWORD first, DWORD count, DWORD listBase,
200 FLOAT chordalDeviation, FLOAT extrusion, INT format,
201 GLYPHMETRICSFLOAT *glyphMetricsFloatArray );
202
203 /* empty gl functions from gl.c */
204 int WINAPI glEmptyFunc0( void );
205 int WINAPI glEmptyFunc4( long );
206 int WINAPI glEmptyFunc8( long, long );
207 int WINAPI glEmptyFunc12( long, long, long );
208 int WINAPI glEmptyFunc16( long, long, long, long );
209 int WINAPI glEmptyFunc20( long, long, long, long, long );
210 int WINAPI glEmptyFunc24( long, long, long, long, long, long );
211 int WINAPI glEmptyFunc28( long, long, long, long, long, long, long );
212 int WINAPI glEmptyFunc32( long, long, long, long, long, long, long, long );
213 int WINAPI glEmptyFunc36( long, long, long, long, long, long, long, long,
214 long );
215 int WINAPI glEmptyFunc40( long, long, long, long, long, long, long, long,
216 long, long );
217 int WINAPI glEmptyFunc44( long, long, long, long, long, long, long, long,
218 long, long, long );
219 int WINAPI glEmptyFunc48( long, long, long, long, long, long, long, long,
220 long, long, long, long );
221 int WINAPI glEmptyFunc52( long, long, long, long, long, long, long, long,
222 long, long, long, long, long );
223 int WINAPI glEmptyFunc56( long, long, long, long, long, long, long, long,
224 long, long, long, long, long, long );
225
226 #ifdef OPENGL32_GL_FUNC_PROTOTYPES
227
228 #define X(func,ret,typeargs,args,icdidx,tebidx,stack) ret WINAPI func typeargs;
229 GLFUNCS_MACRO
230 #undef X
231
232 #endif /* OPENGL32_GL_FUNC_PROTOTYPES */
233
234 #ifdef __cplusplus
235 }; /* extern "C" */
236 #endif /* __cplusplus */
237
238 #endif /* OPENGL32_PRIVATE_H */
239
240 /* EOF */