[FORMATTING] Remove trailing whitespace. Addendum to 34593d93.
[reactos.git] / dll / opengl / opengl32 / opengl32.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: lib/opengl32/opengl.h
5 * PURPOSE: OpenGL32 lib, general header
6 */
7
8 #ifndef _OPENGL32_PCH_
9 #define _OPENGL32_PCH_
10
11 #define WIN32_NO_STATUS
12 #include <stdarg.h>
13 #include <windef.h>
14 #include <winbase.h>
15 #include <winuser.h>
16 #include <wingdi.h>
17 #include <winddi.h>
18 #include <GL/gl.h>
19
20 #ifndef OPENGL32_USE_TLS
21 #include <pstypes.h>
22 #endif
23
24 #include <wine/debug.h>
25
26 #include "icd.h"
27
28 /* *$%$£^§! headers inclusion */
29 static __inline
30 BOOLEAN
31 RemoveEntryList(
32 _In_ PLIST_ENTRY Entry)
33 {
34 PLIST_ENTRY OldFlink;
35 PLIST_ENTRY OldBlink;
36
37 OldFlink = Entry->Flink;
38 OldBlink = Entry->Blink;
39 OldFlink->Blink = OldBlink;
40 OldBlink->Flink = OldFlink;
41 return (OldFlink == OldBlink);
42 }
43
44 static __inline
45 VOID
46 InsertTailList(
47 _In_ PLIST_ENTRY ListHead,
48 _In_ PLIST_ENTRY Entry
49 )
50 {
51 PLIST_ENTRY OldBlink;
52 OldBlink = ListHead->Blink;
53 Entry->Flink = ListHead;
54 Entry->Blink = OldBlink;
55 OldBlink->Flink = Entry;
56 ListHead->Blink = Entry;
57 }
58
59
60 static __inline
61 VOID
62 InitializeListHead(
63 _Inout_ PLIST_ENTRY ListHead
64 )
65 {
66 ListHead->Flink = ListHead->Blink = ListHead;
67 }
68
69 extern LIST_ENTRY ContextListHead;
70
71 struct wgl_context
72 {
73 DWORD magic;
74 volatile LONG lock;
75
76 LIST_ENTRY ListEntry;
77
78 DHGLRC dhglrc;
79 struct ICD_Data* icd_data;
80 INT pixelformat;
81 volatile LONG thread_id;
82 };
83
84 #define WGL_DC_OBJ_DC 0x1
85 struct wgl_dc_data
86 {
87 /* Header */
88 union
89 {
90 HWND hwnd;
91 HDC hdc;
92 HANDLE u;
93 } owner;
94 ULONG flags;
95
96 /* Pixel format */
97 INT pixelformat;
98
99 /* ICD */
100 struct ICD_Data* icd_data;
101 INT nb_icd_formats;
102
103 /* Software implementation */
104 INT nb_sw_formats;
105 void* sw_data;
106
107 /* Linked list */
108 struct wgl_dc_data* next;
109 };
110
111 /* Clean up functions */
112 void IntDeleteAllContexts(void);
113 void IntDeleteAllICDs(void);
114
115 FORCEINLINE
116 const GLDISPATCHTABLE*
117 IntGetCurrentDispatchTable(void)
118 {
119 return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable;
120 }
121
122 FORCEINLINE
123 void
124 IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
125 {
126 NtCurrentTeb()->glTable = (void*)table;
127 }
128
129 FORCEINLINE
130 void
131 IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
132 {
133 TEB* CurrentTeb = NtCurrentTeb();
134
135 CurrentTeb->glCurrentRC = hglrc;
136 CurrentTeb->glReserved2 = hdc;
137 CurrentTeb->glSectionInfo = dc_data;
138 }
139
140 FORCEINLINE
141 HGLRC
142 IntGetCurrentRC(void)
143 {
144 return NtCurrentTeb()->glCurrentRC;
145 }
146
147 FORCEINLINE
148 HDC
149 IntGetCurrentDC(void)
150 {
151 return NtCurrentTeb()->glReserved2;
152 }
153
154 static inline
155 struct wgl_dc_data*
156 IntGetCurrentDcData(void)
157 {
158 return NtCurrentTeb()->glSectionInfo;
159 }
160
161 FORCEINLINE
162 void
163 IntSetCurrentICDPrivate(void* value)
164 {
165 NtCurrentTeb()->glContext = value;
166 }
167
168 FORCEINLINE
169 void*
170 IntGetCurrentICDPrivate(void)
171 {
172 return (void*)NtCurrentTeb()->glContext;
173 }
174
175 FORCEINLINE
176 DHGLRC
177 IntGetCurrentDHGLRC(void)
178 {
179 struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
180 if(!ctx) return NULL;
181 return ctx->dhglrc;
182 }
183
184 /* Software implementation functions */
185 INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr);
186 BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data*, INT format);
187 DHGLRC sw_CreateContext(struct wgl_dc_data*);
188 BOOL sw_DeleteContext(DHGLRC dhglrc);
189 BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc);
190 void sw_ReleaseContext(DHGLRC hglrc);
191 PROC sw_GetProcAddress(LPCSTR name);
192 BOOL sw_CopyContext(DHGLRC dhglrcSrc, DHGLRC dhglrcDst, UINT mask);
193 BOOL sw_ShareLists(DHGLRC dhglrcSrc, DHGLRC dhglrcDst);
194 BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data* dc_data);
195
196 #endif /* _OPENGL32_PCH_ */