01e2ed35922030a48a19d1ff46c7dc1256092ea2
[reactos.git] / reactos / lib / opengl32 / opengl32.h
1 /* $Id: opengl32.h,v 1.13 2004/02/11 17:39:24 vizzini Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/opengl32/opengl32.h
6 * PURPOSE: OpenGL32 lib
7 * PROGRAMMER: Royce Mitchell III, Anich Gregor (blight)
8 * UPDATE HISTORY:
9 * Feb 1, 2004: Created
10 */
11
12 #ifndef OPENGL32_PRIVATE_H
13 #define OPENGL32_PRIVATE_H
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif//__cplusplus
18
19 /* gl function list */
20 #include "glfuncs.h"
21
22 /* ICD index list/types */
23 #include "icdtable.h"
24
25 /* debug flags */
26 #if !defined(NDEBUG)
27 # define DEBUG_OPENGL32
28 # define DEBUG_OPENGL32_BRKPTS /* enable breakpoints */
29 # define DEBUG_OPENGL32_ICD_EXPORTS /* dumps the list of (un)supported glXXX
30 functions when an ICD is loaded. */
31 #endif /* !NDEBUG */
32
33 /* debug macros */
34 #ifdef _MSC_VER
35 inline void DBGPRINT ( ... ) {}
36 #else
37 # ifdef DEBUG_OPENGL32
38 ULONG DbgPrint(PCH Format,...);
39 # include <debug.h>
40 # define DBGPRINT( fmt, args... ) \
41 DPRINT( "OpenGL32.DLL: %s: "fmt"\n", __FUNCTION__, ##args )
42 # else
43 # define DBGPRINT( ... ) do {} while (0)
44 # endif
45 #endif
46
47 #ifdef DEBUG_OPENGL32_BRKPTS
48 # if defined(__GNUC__)
49 # define DBGBREAK() __asm__( "int $3" );
50 # elif defined(_MSC_VER)
51 # define DBGBREAK() __asm { int 3 }
52 # else
53 # error Unsupported compiler!
54 # endif
55 #endif
56
57 /* function/data attributes */
58 #define EXPORT __declspec(dllexport)
59 #ifdef _MSC_VER
60 # define NAKED __declspec(naked)
61 # define SHARED
62 # ifndef STDCALL
63 # define STDCALL __stdcall
64 # endif/*STDCALL*/
65 #else /* GCC */
66 # define NAKED __attribute__((naked))
67 # define SHARED __attribute__((section("shared"), shared))
68 #endif
69
70 #ifdef APIENTRY
71 #undef APIENTRY
72 #endif//APIENTRY
73 #define APIENTRY EXPORT __stdcall
74
75 /* gl function list */
76 #include "glfuncs.h"
77
78 /* GL data types - x86 typedefs */
79 typedef unsigned int GLenum;
80 typedef unsigned char GLboolean;
81 typedef unsigned int GLbitfield;
82 typedef signed char GLbyte;
83 typedef short GLshort;
84 typedef int GLint;
85 typedef int GLsizei;
86 typedef unsigned char GLubyte;
87 typedef unsigned short GLushort;
88 typedef unsigned int GLuint;
89 typedef unsigned short GLhalf;
90 typedef float GLfloat;
91 typedef float GLclampf;
92 typedef double GLdouble;
93 typedef double GLclampd;
94 typedef void GLvoid;
95
96 /* Called by the driver to set the dispatch table */
97 typedef DWORD APIENTRY (*SetContextCallBack)( const ICDTable * );
98
99 /* OpenGL ICD data */
100 typedef struct tagGLDRIVERDATA
101 {
102 HMODULE handle; /* DLL handle */
103 UINT refcount; /* number of references to this ICD */
104 WCHAR driver_name[256]; /* name of display driver */
105
106 WCHAR dll[256]; /* Dll value from registry */
107 DWORD version; /* Version value from registry */
108 DWORD driver_version; /* DriverVersion value from registry */
109 DWORD flags; /* Flags value from registry */
110
111 BOOL APIENTRY (*DrvCopyContext)( HGLRC, HGLRC, UINT );
112 HGLRC APIENTRY (*DrvCreateContext)( HDC );
113 HGLRC APIENTRY (*DrvCreateLayerContext)( HDC, int );
114 BOOL APIENTRY (*DrvDeleteContext)( HGLRC );
115 BOOL APIENTRY (*DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
116 int APIENTRY (*DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
117 int APIENTRY (*DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
118 FARPROC APIENTRY (*DrvGetProcAddress)( LPCSTR lpProcName );
119 void APIENTRY (*DrvReleaseContext)();
120 BOOL APIENTRY (*DrvRealizeLayerPalette)( HDC, int, BOOL );
121 PICDTable APIENTRY (*DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback );
122 int APIENTRY (*DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
123 BOOL APIENTRY (*DrvSetPixelFormat)( IN HDC, IN int, IN CONST PIXELFORMATDESCRIPTOR * );
124 BOOL APIENTRY (*DrvShareLists)( HGLRC, HGLRC );
125 BOOL APIENTRY (*DrvSwapBuffers)( HDC );
126 BOOL APIENTRY (*DrvSwapLayerBuffers)( HDC, UINT );
127 BOOL APIENTRY (*DrvValidateVersion)( DWORD );
128
129 struct tagGLDRIVERDATA *next; /* next ICD -- linked list */
130 } GLDRIVERDATA;
131
132 /* Out private OpenGL context (saved in TLS) */
133 typedef struct tagGLRC
134 {
135 GLDRIVERDATA *icd; /* driver used for this context */
136 HDC hdc; /* DC handle */
137 BOOL is_current; /* wether this context is current for some DC */
138 DWORD thread_id; /* thread holding this context */
139
140 HGLRC hglrc; /* GLRC from DrvCreateContext */
141
142 struct tagGLRC *next; /* linked list */
143 } GLRC;
144
145 /* Process data */
146 typedef struct tagGLPROCESSDATA
147 {
148 GLDRIVERDATA *driver_list; /* list of loaded drivers */
149 HANDLE driver_mutex; /* mutex to protect driver list */
150 GLRC *glrc_list; /* list of GL rendering contexts */
151 HANDLE glrc_mutex; /* mutex to protect glrc list */
152 HDC cachedHdc; /* cached HDC from last SetPixelFormat */
153 INT cachedFormat; /* cached format from last SetPixelFormat */
154 } GLPROCESSDATA;
155
156 /* TLS data */
157 typedef struct tagGLTHREADDATA
158 {
159 GLRC *glrc; /* current GL rendering context */
160 } GLTHREADDATA;
161
162 extern DWORD OPENGL32_tls;
163 extern GLPROCESSDATA OPENGL32_processdata;
164 #define OPENGL32_threaddata ((GLTHREADDATA *)TlsGetValue( OPENGL32_tls ))
165
166 /* function prototypes */
167 GLDRIVERDATA *OPENGL32_LoadICDForHDC( HDC hdc );
168 GLDRIVERDATA *OPENGL32_LoadICD( LPCWSTR driver );
169 BOOL OPENGL32_UnloadICD( GLDRIVERDATA *icd );
170 DWORD OPENGL32_RegEnumDrivers( DWORD idx, LPWSTR name, LPDWORD cName );
171 DWORD OPENGL32_RegGetDriverInfo( LPCWSTR driver, GLDRIVERDATA *icd );
172
173 /* empty gl functions from gl.c */
174 int STDCALL glEmptyFunc0();
175 int STDCALL glEmptyFunc4( long );
176 int STDCALL glEmptyFunc8( long, long );
177 int STDCALL glEmptyFunc12( long, long, long );
178 int STDCALL glEmptyFunc16( long, long, long, long );
179 int STDCALL glEmptyFunc20( long, long, long, long, long );
180 int STDCALL glEmptyFunc24( long, long, long, long, long, long );
181 int STDCALL glEmptyFunc28( long, long, long, long, long, long, long );
182 int STDCALL glEmptyFunc32( long, long, long, long, long, long, long, long );
183 int STDCALL glEmptyFunc36( long, long, long, long, long, long, long, long,
184 long );
185 int STDCALL glEmptyFunc40( long, long, long, long, long, long, long, long,
186 long, long );
187 int STDCALL glEmptyFunc44( long, long, long, long, long, long, long, long,
188 long, long, long );
189 int STDCALL glEmptyFunc48( long, long, long, long, long, long, long, long,
190 long, long, long, long );
191 int STDCALL glEmptyFunc52( long, long, long, long, long, long, long, long,
192 long, long, long, long, long );
193 int STDCALL glEmptyFunc56( long, long, long, long, long, long, long, long,
194 long, long, long, long, long, long );
195
196 #define X(func,ret,typeargs,args,icdidx,tebidx,stack) EXPORT ret STDCALL func typeargs;
197 GLFUNCS_MACRO
198 #undef X
199
200 #ifdef __cplusplus
201 }; // extern "C"
202 #endif//__cplusplus
203
204 #endif//OPENGL32_PRIVATE_H
205
206 /* EOF */