Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 1
/**************************************************************************
2
 *
3
 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4
 * All Rights Reserved.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the
8
 * "Software"), to deal in the Software without restriction, including
9
 * without limitation the rights to use, copy, modify, merge, publish,
10
 * distribute, sub license, and/or sell copies of the Software, and to
11
 * permit persons to whom the Software is furnished to do so, subject to
12
 * the following conditions:
13
 *
14
 * The above copyright notice and this permission notice (including the
15
 * next paragraph) shall be included in all copies or substantial portions
16
 * of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 *
26
 **************************************************************************/
27
 
28
/**
29
 * @file
30
 *
31
 * Fake WGL API implementation.
32
 *
33
 * These functions implement the WGL API, on top of the ICD DDI, so that the
34
 * resulting DLL can be used as a drop-in replacement for the system's
35
 * opengl32.dll.
36
 *
37
 * These functions never get called for ICD drivers, which use exclusively the
38
 * ICD DDI, i.e., the Drv* entrypoints.
39
 */
40
 
41
#include 
42
 
43
#include "util/u_debug.h"
44
#include "stw_icd.h"
45
#include "stw_context.h"
46
#include "stw_pixelformat.h"
47
#include "stw_wgl.h"
48
 
49
 
50
WINGDIAPI BOOL APIENTRY
51
wglCopyContext(
52
   HGLRC hglrcSrc,
53
   HGLRC hglrcDst,
54
   UINT mask )
55
{
56
   return DrvCopyContext( (DHGLRC)(UINT_PTR)hglrcSrc,
57
                          (DHGLRC)(UINT_PTR)hglrcDst,
58
                          mask );
59
}
60
 
61
WINGDIAPI HGLRC APIENTRY
62
wglCreateContext(
63
   HDC hdc )
64
{
65
   return (HGLRC) DrvCreateContext(hdc);
66
}
67
 
68
WINGDIAPI HGLRC APIENTRY
69
wglCreateLayerContext(
70
   HDC hdc,
71
   int iLayerPlane )
72
{
73
   return (HGLRC) DrvCreateLayerContext( hdc, iLayerPlane );
74
}
75
 
76
WINGDIAPI BOOL APIENTRY
77
wglDeleteContext(
78
   HGLRC hglrc )
79
{
80
   return DrvDeleteContext((DHGLRC)(UINT_PTR)hglrc );
81
}
82
 
83
 
84
WINGDIAPI HGLRC APIENTRY
85
wglGetCurrentContext( VOID )
86
{
87
   return (HGLRC)(UINT_PTR)stw_get_current_context();
88
}
89
 
90
WINGDIAPI HDC APIENTRY
91
wglGetCurrentDC( VOID )
92
{
93
   return stw_get_current_dc();
94
}
95
 
96
WINGDIAPI BOOL APIENTRY
97
wglMakeCurrent(
98
   HDC hdc,
99
   HGLRC hglrc )
100
{
101
   return DrvSetContext( hdc, (DHGLRC)(UINT_PTR)hglrc, NULL ) ? TRUE : FALSE;
102
}
103
 
104
 
105
WINGDIAPI BOOL APIENTRY
106
wglSwapBuffers(
107
   HDC hdc )
108
{
109
   return DrvSwapBuffers( hdc );
110
}
111
 
112
 
113
WINGDIAPI DWORD WINAPI
114
wglSwapMultipleBuffers(UINT n,
115
                       CONST WGLSWAP *ps)
116
{
117
   UINT i;
118
 
119
   for (i =0; i < n; ++i)
120
      wglSwapBuffers(ps->hdc);
121
 
122
   return 0;
123
}
124
 
125
 
126
WINGDIAPI BOOL APIENTRY
127
wglSwapLayerBuffers(
128
   HDC hdc,
129
   UINT fuPlanes )
130
{
131
   return DrvSwapLayerBuffers( hdc, fuPlanes );
132
}
133
 
134
WINGDIAPI PROC APIENTRY
135
wglGetProcAddress(
136
    LPCSTR lpszProc )
137
{
138
   return DrvGetProcAddress( lpszProc );
139
}
140
 
141
 
142
WINGDIAPI int APIENTRY
143
wglChoosePixelFormat(
144
   HDC hdc,
145
   CONST PIXELFORMATDESCRIPTOR *ppfd )
146
{
147
   if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
148
      return 0;
149
   if (ppfd->iPixelType != PFD_TYPE_RGBA)
150
      return 0;
151
   if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
152
      return 0;
153
   if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
154
      return 0;
155
   if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
156
      return 0;
157
   if (ppfd->dwFlags & PFD_SUPPORT_GDI)
158
      return 0;
159
   if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
160
      return 0;
161
 
162
   return stw_pixelformat_choose( hdc, ppfd );
163
}
164
 
165
WINGDIAPI int APIENTRY
166
wglDescribePixelFormat(
167
   HDC hdc,
168
   int iPixelFormat,
169
   UINT nBytes,
170
   LPPIXELFORMATDESCRIPTOR ppfd )
171
{
172
   return DrvDescribePixelFormat( hdc, iPixelFormat, nBytes, ppfd );
173
}
174
 
175
WINGDIAPI int APIENTRY
176
wglGetPixelFormat(
177
   HDC hdc )
178
{
179
   return stw_pixelformat_get( hdc );
180
}
181
 
182
WINGDIAPI BOOL APIENTRY
183
wglSetPixelFormat(
184
   HDC hdc,
185
   int iPixelFormat,
186
   const PIXELFORMATDESCRIPTOR *ppfd )
187
{
188
    /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per
189
     * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx
190
     */
191
   (void) ppfd;
192
 
193
   return DrvSetPixelFormat( hdc, iPixelFormat );
194
}
195
 
196
 
197
WINGDIAPI BOOL APIENTRY
198
wglUseFontBitmapsA(
199
   HDC hdc,
200
   DWORD first,
201
   DWORD count,
202
   DWORD listBase )
203
{
204
   (void) hdc;
205
   (void) first;
206
   (void) count;
207
   (void) listBase;
208
 
209
   assert( 0 );
210
 
211
   return FALSE;
212
}
213
 
214
WINGDIAPI BOOL APIENTRY
215
wglShareLists(
216
   HGLRC hglrc1,
217
   HGLRC hglrc2 )
218
{
219
   return DrvShareLists((DHGLRC)(UINT_PTR)hglrc1,
220
                        (DHGLRC)(UINT_PTR)hglrc2);
221
}
222
 
223
WINGDIAPI BOOL APIENTRY
224
wglUseFontBitmapsW(
225
   HDC hdc,
226
   DWORD first,
227
   DWORD count,
228
   DWORD listBase )
229
{
230
   (void) hdc;
231
   (void) first;
232
   (void) count;
233
   (void) listBase;
234
 
235
   assert( 0 );
236
 
237
   return FALSE;
238
}
239
 
240
WINGDIAPI BOOL APIENTRY
241
wglUseFontOutlinesA(
242
   HDC hdc,
243
   DWORD first,
244
   DWORD count,
245
   DWORD listBase,
246
   FLOAT deviation,
247
   FLOAT extrusion,
248
   int format,
249
   LPGLYPHMETRICSFLOAT lpgmf )
250
{
251
   (void) hdc;
252
   (void) first;
253
   (void) count;
254
   (void) listBase;
255
   (void) deviation;
256
   (void) extrusion;
257
   (void) format;
258
   (void) lpgmf;
259
 
260
   assert( 0 );
261
 
262
   return FALSE;
263
}
264
 
265
WINGDIAPI BOOL APIENTRY
266
wglUseFontOutlinesW(
267
   HDC hdc,
268
   DWORD first,
269
   DWORD count,
270
   DWORD listBase,
271
   FLOAT deviation,
272
   FLOAT extrusion,
273
   int format,
274
   LPGLYPHMETRICSFLOAT lpgmf )
275
{
276
   (void) hdc;
277
   (void) first;
278
   (void) count;
279
   (void) listBase;
280
   (void) deviation;
281
   (void) extrusion;
282
   (void) format;
283
   (void) lpgmf;
284
 
285
   assert( 0 );
286
 
287
   return FALSE;
288
}
289
 
290
WINGDIAPI BOOL APIENTRY
291
wglDescribeLayerPlane(
292
   HDC hdc,
293
   int iPixelFormat,
294
   int iLayerPlane,
295
   UINT nBytes,
296
   LPLAYERPLANEDESCRIPTOR plpd )
297
{
298
   return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
299
}
300
 
301
WINGDIAPI int APIENTRY
302
wglSetLayerPaletteEntries(
303
   HDC hdc,
304
   int iLayerPlane,
305
   int iStart,
306
   int cEntries,
307
   CONST COLORREF *pcr )
308
{
309
   return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
310
}
311
 
312
WINGDIAPI int APIENTRY
313
wglGetLayerPaletteEntries(
314
   HDC hdc,
315
   int iLayerPlane,
316
   int iStart,
317
   int cEntries,
318
   COLORREF *pcr )
319
{
320
   return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
321
}
322
 
323
WINGDIAPI BOOL APIENTRY
324
wglRealizeLayerPalette(
325
   HDC hdc,
326
   int iLayerPlane,
327
   BOOL bRealize )
328
{
329
   (void) hdc;
330
   (void) iLayerPlane;
331
   (void) bRealize;
332
 
333
   assert( 0 );
334
 
335
   return FALSE;
336
}