| 1 | /* $Id: wgl.c,v 1.4 2000-05-23 20:41:04 jeroen Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * This library is free software; you can redistribute it and/or
|
|---|
| 5 | * modify it under the terms of the GNU Library General Public
|
|---|
| 6 | * License as published by the Free Software Foundation; either
|
|---|
| 7 | * version 2 of the License, or (at your option) any later version.
|
|---|
| 8 | *
|
|---|
| 9 | * This library is distributed in the hope that it will be useful,
|
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 12 | * Library General Public License for more details.
|
|---|
| 13 | *
|
|---|
| 14 | * You should have received a copy of the GNU Library General Public
|
|---|
| 15 | * License along with this library; if not, write to the Free
|
|---|
| 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 17 | *
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | * File name : wgl.c
|
|---|
| 22 | * WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru
|
|---|
| 23 | * Some things originated from the 3Dfx WGL functions
|
|---|
| 24 | */
|
|---|
| 25 |
|
|---|
| 26 | #if defined(WIN32) || defined(__WIN32OS2__)
|
|---|
| 27 |
|
|---|
| 28 | #ifdef __cplusplus
|
|---|
| 29 | extern "C" {
|
|---|
| 30 | #endif
|
|---|
| 31 | #include <windows.h>
|
|---|
| 32 | #include <winerror.h>
|
|---|
| 33 |
|
|---|
| 34 | #ifdef __cplusplus
|
|---|
| 35 | }
|
|---|
| 36 | #endif
|
|---|
| 37 |
|
|---|
| 38 | #include "glheader.h"
|
|---|
| 39 | #include "types.h"
|
|---|
| 40 | #include "context.h"
|
|---|
| 41 | #include "wmesadef.h"
|
|---|
| 42 | #include "wmesa.h"
|
|---|
| 43 |
|
|---|
| 44 | #define MAX_MESA_ATTRS 20
|
|---|
| 45 |
|
|---|
| 46 | struct __extensions__
|
|---|
| 47 | {
|
|---|
| 48 | PROC proc;
|
|---|
| 49 | char *name;
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 | struct __pixelformat__
|
|---|
| 53 | {
|
|---|
| 54 | PIXELFORMATDESCRIPTOR pfd;
|
|---|
| 55 | GLboolean doubleBuffered;
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | struct __extensions__ ext[] = {
|
|---|
| 59 |
|
|---|
| 60 | #ifdef GL_EXT_polygon_offset
|
|---|
| 61 | { (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" },
|
|---|
| 62 | #endif
|
|---|
| 63 | { (PROC)glBlendEquationEXT, "glBlendEquationEXT" },
|
|---|
| 64 | { (PROC)glBlendColorEXT, "glBlendColorExt" },
|
|---|
| 65 | { (PROC)glVertexPointerEXT, "glVertexPointerEXT" },
|
|---|
| 66 | { (PROC)glNormalPointerEXT, "glNormalPointerEXT" },
|
|---|
| 67 | { (PROC)glColorPointerEXT, "glColorPointerEXT" },
|
|---|
| 68 | { (PROC)glIndexPointerEXT, "glIndexPointerEXT" },
|
|---|
| 69 | { (PROC)glTexCoordPointerEXT, "glTexCoordPointer" },
|
|---|
| 70 | { (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" },
|
|---|
| 71 | { (PROC)glGetPointervEXT, "glGetPointervEXT" },
|
|---|
| 72 | { (PROC)glArrayElementEXT, "glArrayElementEXT" },
|
|---|
| 73 | { (PROC)glDrawArraysEXT, "glDrawArrayEXT" },
|
|---|
| 74 | { (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" },
|
|---|
| 75 | { (PROC)glBindTextureEXT, "glBindTextureEXT" },
|
|---|
| 76 | { (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" },
|
|---|
| 77 | { (PROC)glGenTexturesEXT, "glGenTexturesEXT" },
|
|---|
| 78 | { (PROC)glIsTextureEXT, "glIsTextureEXT" },
|
|---|
| 79 | { (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" },
|
|---|
| 80 | { (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" },
|
|---|
| 81 | { (PROC)glTexImage3DEXT, "glTexImage3DEXT" },
|
|---|
| 82 | { (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" },
|
|---|
| 83 | { (PROC)glColorTableEXT, "glColorTableEXT" },
|
|---|
| 84 | { (PROC)glColorSubTableEXT, "glColorSubTableEXT" },
|
|---|
| 85 | { (PROC)glGetColorTableEXT, "glGetColorTableEXT" },
|
|---|
| 86 | { (PROC)glGetColorTableParameterfvEXT, "glGetColorTableParameterfvEXT" },
|
|---|
| 87 | { (PROC)glGetColorTableParameterivEXT, "glGetColorTableParameterivEXT" },
|
|---|
| 88 | { (PROC)glPointParameterfEXT, "glPointParameterfEXT" },
|
|---|
| 89 | { (PROC)glPointParameterfvEXT, "glPointParameterfvEXT" },
|
|---|
| 90 | { (PROC)glBlendFuncSeparateINGR, "glBlendFuncSeparateINGR" },
|
|---|
| 91 | { (PROC)glLockArraysEXT, "glLockArraysEXT" },
|
|---|
| 92 | { (PROC)glUnlockArraysEXT, "glUnlockArraysEXT" }
|
|---|
| 93 | };
|
|---|
| 94 |
|
|---|
| 95 | int qt_ext = sizeof(ext) / sizeof(ext[0]);
|
|---|
| 96 |
|
|---|
| 97 | struct __pixelformat__ pix[] =
|
|---|
| 98 | {
|
|---|
| 99 | { { sizeof(PIXELFORMATDESCRIPTOR), 1,
|
|---|
| 100 | PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
|
|---|
| 101 | PFD_TYPE_RGBA,
|
|---|
| 102 | 24, 8, 0, 8, 8, 8, 16, 8, 24,
|
|---|
| 103 | 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
|
|---|
| 104 | GL_TRUE
|
|---|
| 105 | },
|
|---|
| 106 | { { sizeof(PIXELFORMATDESCRIPTOR), 1,
|
|---|
| 107 | PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
|
|---|
| 108 | PFD_TYPE_RGBA,
|
|---|
| 109 | 24, 8, 0, 8, 8, 8, 16, 8, 24,
|
|---|
| 110 | 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
|
|---|
| 111 | GL_FALSE
|
|---|
| 112 | },
|
|---|
| 113 | };
|
|---|
| 114 |
|
|---|
| 115 | int qt_pix = sizeof(pix) / sizeof(pix[0]);
|
|---|
| 116 |
|
|---|
| 117 | typedef struct {
|
|---|
| 118 | WMesaContext ctx;
|
|---|
| 119 | HDC hdc;
|
|---|
| 120 | } MesaWglCtx;
|
|---|
| 121 |
|
|---|
| 122 | #define MESAWGL_CTX_MAX_COUNT 20
|
|---|
| 123 |
|
|---|
| 124 | static MesaWglCtx wgl_ctx[MESAWGL_CTX_MAX_COUNT];
|
|---|
| 125 |
|
|---|
| 126 | static unsigned ctx_count = 0;
|
|---|
| 127 | static unsigned ctx_current = -1;
|
|---|
| 128 | static unsigned curPFD = 0;
|
|---|
| 129 |
|
|---|
| 130 | GLAPI BOOL GLWINAPI wglCopyContext(HGLRC hglrcSrc,HGLRC hglrcDst,UINT mask)
|
|---|
| 131 | {
|
|---|
| 132 | return(FALSE);
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | GLAPI HGLRC GLWINAPI wglCreateContext(HDC hdc)
|
|---|
| 136 | {
|
|---|
| 137 | HWND hWnd;
|
|---|
| 138 | int i = 0;
|
|---|
| 139 | if(!(hWnd = WindowFromDC(hdc)))
|
|---|
| 140 | {
|
|---|
| 141 | SetLastError(0);
|
|---|
| 142 | return(NULL);
|
|---|
| 143 | }
|
|---|
| 144 | if (!ctx_count)
|
|---|
| 145 | {
|
|---|
| 146 | for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++)
|
|---|
| 147 | {
|
|---|
| 148 | wgl_ctx[i].ctx = NULL;
|
|---|
| 149 | wgl_ctx[i].hdc = NULL;
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 | for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ )
|
|---|
| 153 | {
|
|---|
| 154 | if ( wgl_ctx[i].ctx == NULL )
|
|---|
| 155 | {
|
|---|
| 156 | wgl_ctx[i].ctx = WMesaCreateContext( hWnd, NULL, GL_TRUE,
|
|---|
| 157 | pix[curPFD-1].doubleBuffered );
|
|---|
| 158 | if (wgl_ctx[i].ctx == NULL)
|
|---|
| 159 | break;
|
|---|
| 160 | wgl_ctx[i].hdc = hdc;
|
|---|
| 161 | ctx_count++;
|
|---|
| 162 | return ((HGLRC)wgl_ctx[i].ctx);
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 | SetLastError(0);
|
|---|
| 166 | return(NULL);
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | GLAPI BOOL GLWINAPI wglDeleteContext(HGLRC hglrc)
|
|---|
| 170 | {
|
|---|
| 171 | int i;
|
|---|
| 172 | for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ )
|
|---|
| 173 | {
|
|---|
| 174 | if ( wgl_ctx[i].ctx == (PWMC) hglrc )
|
|---|
| 175 | {
|
|---|
| 176 | WMesaMakeCurrent((PWMC) hglrc);
|
|---|
| 177 | WMesaDestroyContext();
|
|---|
| 178 | wgl_ctx[i].ctx = NULL;
|
|---|
| 179 | wgl_ctx[i].hdc = NULL;
|
|---|
| 180 | ctx_count--;
|
|---|
| 181 | return(TRUE);
|
|---|
| 182 | }
|
|---|
| 183 | }
|
|---|
| 184 | SetLastError(0);
|
|---|
| 185 | return(FALSE);
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | GLAPI HGLRC GLWINAPI wglCreateLayerContext(HDC hdc,int iLayerPlane)
|
|---|
| 189 | {
|
|---|
| 190 | SetLastError(0);
|
|---|
| 191 | return(NULL);
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | GLAPI HGLRC GLWINAPI wglGetCurrentContext(VOID)
|
|---|
| 195 | {
|
|---|
| 196 | if (ctx_current < 0)
|
|---|
| 197 | return 0;
|
|---|
| 198 | else
|
|---|
| 199 | return (HGLRC) wgl_ctx[ctx_current].ctx;
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | GLAPI HDC GLWINAPI wglGetCurrentDC(VOID)
|
|---|
| 203 | {
|
|---|
| 204 | if (ctx_current < 0)
|
|---|
| 205 | return 0;
|
|---|
| 206 | else
|
|---|
| 207 | return wgl_ctx[ctx_current].hdc;
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | GLAPI BOOL GLWINAPI wglMakeCurrent(HDC hdc,HGLRC hglrc)
|
|---|
| 211 | {
|
|---|
| 212 | int i;
|
|---|
| 213 |
|
|---|
| 214 | /* new code suggested by Andy Sy */
|
|---|
| 215 | if (!hdc || !hglrc) {
|
|---|
| 216 | WMesaMakeCurrent(NULL);
|
|---|
| 217 | ctx_current = -1;
|
|---|
| 218 | return TRUE;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ )
|
|---|
| 222 | {
|
|---|
| 223 | if ( wgl_ctx[i].ctx == (PWMC) hglrc )
|
|---|
| 224 | {
|
|---|
| 225 | wgl_ctx[i].hdc = hdc;
|
|---|
| 226 | WMesaMakeCurrent( (WMesaContext) hglrc );
|
|---|
| 227 | ctx_current = i;
|
|---|
| 228 | return TRUE;
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| 231 | return FALSE;
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | GLAPI BOOL GLWINAPI wglShareLists(HGLRC hglrc1,HGLRC hglrc2)
|
|---|
| 235 | {
|
|---|
| 236 | return(TRUE);
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 | static FIXED FixedFromDouble(double d)
|
|---|
| 241 | {
|
|---|
| 242 | long l = (long) (d * 65536L);
|
|---|
| 243 | return *(FIXED *)&l;
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | GLAPI BOOL GLWINAPI wglUseFontBitmapsA(HDC hdc, DWORD first,
|
|---|
| 248 | DWORD count, DWORD listBase)
|
|---|
| 249 | {
|
|---|
| 250 | int i;
|
|---|
| 251 | GLuint font_list;
|
|---|
| 252 | DWORD size;
|
|---|
| 253 | GLYPHMETRICS gm;
|
|---|
| 254 | HANDLE hBits;
|
|---|
| 255 | LPSTR lpBits;
|
|---|
| 256 | MAT2 mat;
|
|---|
| 257 |
|
|---|
| 258 | if (first<0)
|
|---|
| 259 | return FALSE;
|
|---|
| 260 | if (count<0)
|
|---|
| 261 | return FALSE;
|
|---|
| 262 | if (listBase<0)
|
|---|
| 263 | return FALSE;
|
|---|
| 264 |
|
|---|
| 265 | font_list = glGenLists( count );
|
|---|
| 266 | if(font_list == 0)
|
|---|
| 267 | return FALSE;
|
|---|
| 268 |
|
|---|
| 269 | mat.eM11 = FixedFromDouble(1);
|
|---|
| 270 | mat.eM12 = FixedFromDouble(0);
|
|---|
| 271 | mat.eM21 = FixedFromDouble(0);
|
|---|
| 272 | mat.eM22 = FixedFromDouble(1);
|
|---|
| 273 |
|
|---|
| 274 | memset(&gm,0,sizeof(gm));
|
|---|
| 275 |
|
|---|
| 276 | for (i = 0; i < count; i++)
|
|---|
| 277 | {
|
|---|
| 278 | glNewList( font_list+i, GL_COMPILE );
|
|---|
| 279 |
|
|---|
| 280 | /* allocate space for the bitmap/outline */
|
|---|
| 281 | size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm, 0, NULL, &mat);
|
|---|
| 282 | if (size == GDI_ERROR)
|
|---|
| 283 | {
|
|---|
| 284 | DWORD err;
|
|---|
| 285 | err = GetLastError();
|
|---|
| 286 | return(FALSE);
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | hBits = GlobalAlloc(GHND, size);
|
|---|
| 290 | lpBits = (LPSTR)GlobalLock(hBits);
|
|---|
| 291 |
|
|---|
| 292 | GetGlyphOutline(hdc, /* handle to device context*/
|
|---|
| 293 | first + i, /* character to query*/
|
|---|
| 294 | GGO_BITMAP, /* format of data to return*/
|
|---|
| 295 | &gm, /* pointer to structure for metrics*/
|
|---|
| 296 | size, /* size of buffer for data*/
|
|---|
| 297 | lpBits, /* pointer to buffer for data*/
|
|---|
| 298 | &mat /* pointer to transformation*/
|
|---|
| 299 | /* matrix structure */
|
|---|
| 300 | );
|
|---|
| 301 | if (*lpBits == GDI_ERROR)
|
|---|
| 302 | {
|
|---|
| 303 | DWORD err;
|
|---|
| 304 | err = GetLastError();
|
|---|
| 305 |
|
|---|
| 306 | GlobalUnlock(hBits);
|
|---|
| 307 | GlobalFree(hBits);
|
|---|
| 308 |
|
|---|
| 309 | return(FALSE);
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY,
|
|---|
| 313 | gm.gmptGlyphOrigin.x,
|
|---|
| 314 | gm.gmptGlyphOrigin.y,
|
|---|
| 315 | gm.gmCellIncX,gm.gmCellIncY,
|
|---|
| 316 | (const GLubyte * )lpBits);
|
|---|
| 317 |
|
|---|
| 318 | GlobalUnlock(hBits);
|
|---|
| 319 | GlobalFree(hBits);
|
|---|
| 320 |
|
|---|
| 321 | glEndList( );
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | return TRUE;
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | GLAPI BOOL GLWINAPI wglUseFontBitmapsW(HDC hdc,DWORD first,DWORD count,DWORD listBase)
|
|---|
| 328 | {
|
|---|
| 329 | return FALSE;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | GLAPI BOOL GLWINAPI wglUseFontOutlinesA(HDC hdc,DWORD first,DWORD count,
|
|---|
| 333 | DWORD listBase,FLOAT deviation,
|
|---|
| 334 | FLOAT extrusion,int format,
|
|---|
| 335 | LPGLYPHMETRICSFLOAT lpgmf)
|
|---|
| 336 | {
|
|---|
| 337 | SetLastError(0);
|
|---|
| 338 | return(FALSE);
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | GLAPI BOOL GLWINAPI wglUseFontOutlinesW(HDC hdc,DWORD first,DWORD count,
|
|---|
| 342 | DWORD listBase,FLOAT deviation,
|
|---|
| 343 | FLOAT extrusion,int format,
|
|---|
| 344 | LPGLYPHMETRICSFLOAT lpgmf)
|
|---|
| 345 | {
|
|---|
| 346 | SetLastError(0);
|
|---|
| 347 | return(FALSE);
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | GLAPI BOOL GLWINAPI wglDescribeLayerPlane(HDC hdc,int iPixelFormat,
|
|---|
| 351 | int iLayerPlane,UINT nBytes,
|
|---|
| 352 | LAYERPLANEDESCRIPTOR *plpd)
|
|---|
| 353 | {
|
|---|
| 354 | SetLastError(0);
|
|---|
| 355 | return(FALSE);
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | GLAPI int GLWINAPI wglSetLayerPaletteEntries(HDC hdc,int iLayerPlane,
|
|---|
| 359 | int iStart,int cEntries,
|
|---|
| 360 | CONST COLORREF *pcr)
|
|---|
| 361 | {
|
|---|
| 362 | SetLastError(0);
|
|---|
| 363 | return(0);
|
|---|
| 364 | }
|
|---|
| 365 |
|
|---|
| 366 | GLAPI int GLWINAPI wglGetLayerPaletteEntries(HDC hdc,int iLayerPlane,
|
|---|
| 367 | int iStart,int cEntries,
|
|---|
| 368 | COLORREF *pcr)
|
|---|
| 369 | {
|
|---|
| 370 | SetLastError(0);
|
|---|
| 371 | return(0);
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | GLAPI BOOL GLWINAPI wglRealizeLayerPalette(HDC hdc,int iLayerPlane,BOOL bRealize)
|
|---|
| 375 | {
|
|---|
| 376 | SetLastError(0);
|
|---|
| 377 | return(FALSE);
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | GLAPI BOOL GLWINAPI wglSwapLayerBuffers(HDC hdc,UINT fuPlanes)
|
|---|
| 381 | {
|
|---|
| 382 | if( !hdc )
|
|---|
| 383 | {
|
|---|
| 384 | WMesaSwapBuffers();
|
|---|
| 385 | return(TRUE);
|
|---|
| 386 | }
|
|---|
| 387 | SetLastError(0);
|
|---|
| 388 | return(FALSE);
|
|---|
| 389 | }
|
|---|
| 390 |
|
|---|
| 391 | GLAPI int GLWINAPI wglChoosePixelFormat(HDC hdc,
|
|---|
| 392 | CONST PIXELFORMATDESCRIPTOR *ppfd)
|
|---|
| 393 | {
|
|---|
| 394 | int i,best = -1,bestdelta = 0x7FFFFFFF,delta,qt_valid_pix;
|
|---|
| 395 |
|
|---|
| 396 | qt_valid_pix = qt_pix;
|
|---|
| 397 | if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1)
|
|---|
| 398 | {
|
|---|
| 399 | SetLastError(0);
|
|---|
| 400 | return(0);
|
|---|
| 401 | }
|
|---|
| 402 | for(i = 0;i < qt_valid_pix;i++)
|
|---|
| 403 | {
|
|---|
| 404 | delta = 0;
|
|---|
| 405 | if(
|
|---|
| 406 | (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) &&
|
|---|
| 407 | !(pix[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW))
|
|---|
| 408 | continue;
|
|---|
| 409 | if(
|
|---|
| 410 | (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) &&
|
|---|
| 411 | !(pix[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP))
|
|---|
| 412 | continue;
|
|---|
| 413 | if(
|
|---|
| 414 | (ppfd->dwFlags & PFD_SUPPORT_GDI) &&
|
|---|
| 415 | !(pix[i].pfd.dwFlags & PFD_SUPPORT_GDI))
|
|---|
| 416 | continue;
|
|---|
| 417 | if(
|
|---|
| 418 | (ppfd->dwFlags & PFD_SUPPORT_OPENGL) &&
|
|---|
| 419 | !(pix[i].pfd.dwFlags & PFD_SUPPORT_OPENGL))
|
|---|
| 420 | continue;
|
|---|
| 421 | if(
|
|---|
| 422 | !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
|
|---|
| 423 | ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != (pix[i].pfd.dwFlags & PFD_DOUBLEBUFFER)))
|
|---|
| 424 | continue;
|
|---|
| 425 | if(
|
|---|
| 426 | !(ppfd->dwFlags & PFD_STEREO_DONTCARE) &&
|
|---|
| 427 | ((ppfd->dwFlags & PFD_STEREO) != (pix[i].pfd.dwFlags & PFD_STEREO)))
|
|---|
| 428 | continue;
|
|---|
| 429 | if(ppfd->iPixelType != pix[i].pfd.iPixelType)
|
|---|
| 430 | delta++;
|
|---|
| 431 | if(delta < bestdelta)
|
|---|
| 432 | {
|
|---|
| 433 | best = i + 1;
|
|---|
| 434 | bestdelta = delta;
|
|---|
| 435 | if(bestdelta == 0)
|
|---|
| 436 | break;
|
|---|
| 437 | }
|
|---|
| 438 | }
|
|---|
| 439 | if(best == -1)
|
|---|
| 440 | {
|
|---|
| 441 | SetLastError(0);
|
|---|
| 442 | return(0);
|
|---|
| 443 | }
|
|---|
| 444 | return(best);
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | GLAPI int GLWINAPI wglDescribePixelFormat(HDC hdc,int iPixelFormat,UINT nBytes,
|
|---|
| 448 | LPPIXELFORMATDESCRIPTOR ppfd)
|
|---|
| 449 | {
|
|---|
| 450 | int qt_valid_pix;
|
|---|
| 451 |
|
|---|
| 452 | qt_valid_pix = qt_pix;
|
|---|
| 453 | if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || nBytes != sizeof(PIXELFORMATDESCRIPTOR))
|
|---|
| 454 | {
|
|---|
| 455 | SetLastError(0);
|
|---|
| 456 | return(0);
|
|---|
| 457 | }
|
|---|
| 458 | *ppfd = pix[iPixelFormat - 1].pfd;
|
|---|
| 459 | return(qt_valid_pix);
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | /*
|
|---|
| 463 | * GetProcAddress - return the address of an appropriate extension
|
|---|
| 464 | */
|
|---|
| 465 | GLAPI PROC GLWINAPI wglGetProcAddress(LPCSTR lpszProc)
|
|---|
| 466 | {
|
|---|
| 467 | int i;
|
|---|
| 468 | for(i = 0;i < qt_ext;i++)
|
|---|
| 469 | if(!strcmp(lpszProc,ext[i].name))
|
|---|
| 470 | return(ext[i].proc);
|
|---|
| 471 |
|
|---|
| 472 | SetLastError(0);
|
|---|
| 473 | return(NULL);
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | GLAPI int GLWINAPI wglGetPixelFormat(HDC hdc)
|
|---|
| 477 | {
|
|---|
| 478 | if(curPFD == 0)
|
|---|
| 479 | {
|
|---|
| 480 | SetLastError(0);
|
|---|
| 481 | return(0);
|
|---|
| 482 | }
|
|---|
| 483 | return(curPFD);
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | GLAPI BOOL GLWINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat,
|
|---|
| 487 | PIXELFORMATDESCRIPTOR *ppfd)
|
|---|
| 488 | {
|
|---|
| 489 | int qt_valid_pix;
|
|---|
| 490 |
|
|---|
| 491 | qt_valid_pix = qt_pix;
|
|---|
| 492 | #ifdef __WIN32OS2__
|
|---|
| 493 | if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || (ppfd && ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)))
|
|---|
| 494 | #else
|
|---|
| 495 | if(iPixelFormat < 1 || iPixelFormat > qt_valid_pix || ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR))
|
|---|
| 496 | #endif
|
|---|
| 497 | {
|
|---|
| 498 | SetLastError(0);
|
|---|
| 499 | return(FALSE);
|
|---|
| 500 | }
|
|---|
| 501 | curPFD = iPixelFormat;
|
|---|
| 502 | return(TRUE);
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | GLAPI BOOL GLWINAPI wglSwapBuffers(HDC hdc)
|
|---|
| 506 | {
|
|---|
| 507 | _heap_check();
|
|---|
| 508 |
|
|---|
| 509 | if (ctx_current < 0)
|
|---|
| 510 | return FALSE;
|
|---|
| 511 |
|
|---|
| 512 | if(wgl_ctx[ctx_current].ctx == NULL) {
|
|---|
| 513 | SetLastError(0);
|
|---|
| 514 | return(FALSE);
|
|---|
| 515 | }
|
|---|
| 516 | WMesaSwapBuffers();
|
|---|
| 517 | return(TRUE);
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | #endif /* WIN32 or __WIN32OS2__ */
|
|---|