ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

wgl.c
Go to the documentation of this file.
00001 
00002 /*
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Library General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2 of the License, or (at your option) any later version.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public
00014  * License along with this library; if not, write to the Free
00015  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  *
00017  */
00018 
00019 /*
00020  * File name    : wgl.c
00021  * WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru
00022  * Some things originated from the 3Dfx WGL functions
00023  */
00024 
00025 /* 
00026  * This file contains the implementation of the wgl* functions for
00027  * Mesa on Windows.  Since these functions are provided by Windows in
00028  * GDI/OpenGL, we must supply our versions that work with Mesa here.
00029  */
00030 
00031 
00032 /* We're essentially building part of GDI here, so define this so that
00033  * we get the right export linkage. */
00034 #ifdef __MINGW32__
00035 
00036 #include <stdarg.h>
00037 #include <windef.h>
00038 #include <winbase.h>
00039 #include <wincon.h>
00040 
00041 #  if defined(BUILD_GL32)
00042 #    define WINGDIAPI __declspec(dllexport) 
00043 #  else
00044 #    define __W32API_USE_DLLIMPORT__
00045 #  endif
00046 
00047 #include <wingdi.h>
00048 #include "GL/mesa_wgl.h"
00049 #include <stdlib.h>
00050 
00051 #else
00052 
00053 #define _GDI32_
00054 #include <windows.h>
00055 
00056 #endif
00057 #include "config.h"
00058 #include "glapi.h"
00059 #include "GL/wmesa.h"   /* protos for wmesa* functions */
00060 
00061 /*
00062  * Pixel Format Descriptors
00063  */
00064 
00065 /* Extend the PFD to include DB flag */
00066 struct __pixelformat__
00067 {
00068     PIXELFORMATDESCRIPTOR pfd;
00069     GLboolean doubleBuffered;
00070 };
00071 
00072 
00073 
00074 /* These are the PFD's supported by this driver. */
00075 struct __pixelformat__  pfd[] =
00076 {
00077 #if 0 
00078     /* Double Buffer, alpha */
00079     {   
00080     {   
00081         sizeof(PIXELFORMATDESCRIPTOR),  1,
00082         PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
00083         PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
00084         PFD_TYPE_RGBA,
00085         24, 
00086         8, 0,   
00087         8, 8,   
00088         8, 16,  
00089         8, 24,
00090         0, 0, 0, 0, 0,  
00091         DEFAULT_SOFTWARE_DEPTH_BITS,    8,  
00092         0, 0, 0,    
00093         0, 0, 0 
00094     },
00095         GL_TRUE
00096     },
00097     /* Single Buffer, alpha */
00098     {   
00099     {   
00100         sizeof(PIXELFORMATDESCRIPTOR),  1,
00101         PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
00102         PFD_GENERIC_FORMAT,
00103         PFD_TYPE_RGBA,
00104         24, 
00105         8, 0,   
00106         8, 8,   
00107         8, 16,  
00108         8, 24,
00109         0, 0, 0, 0, 0,  
00110         DEFAULT_SOFTWARE_DEPTH_BITS,    8,  
00111         0, 0, 0,    
00112         0, 0, 0
00113     },
00114         GL_FALSE
00115     },
00116 #endif 
00117     /* Double Buffer, no alpha */
00118     {   
00119     {   
00120         sizeof(PIXELFORMATDESCRIPTOR),  1,
00121         PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
00122         PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
00123         PFD_TYPE_RGBA,
00124         24, 
00125         8, 0,
00126         8, 8,
00127         8, 16,
00128         0, 0,
00129         0, 0, 0, 0, 0,
00130         DEFAULT_SOFTWARE_DEPTH_BITS,    8,  
00131         0, 0, 0, 
00132         0, 0, 0 
00133     },
00134         GL_TRUE
00135     },
00136     /* Single Buffer, no alpha */
00137     {   
00138     {
00139         sizeof(PIXELFORMATDESCRIPTOR),  1,
00140         PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
00141         PFD_GENERIC_FORMAT,
00142         PFD_TYPE_RGBA,
00143         24, 
00144         8, 0,
00145         8, 8,
00146         8, 16,
00147         0, 0,
00148         0, 0, 0, 0, 0,
00149         DEFAULT_SOFTWARE_DEPTH_BITS,    8,  
00150         0, 0, 0,
00151         0, 0, 0 
00152     },
00153         GL_FALSE
00154     },
00155 };
00156 
00157 int npfd = sizeof(pfd) / sizeof(pfd[0]);
00158 
00159 
00160 /*
00161  * Contexts
00162  */
00163 
00164 typedef struct {
00165     WMesaContext ctx;
00166 } MesaWglCtx;
00167 
00168 #define MESAWGL_CTX_MAX_COUNT 20
00169 
00170 static MesaWglCtx wgl_ctx[MESAWGL_CTX_MAX_COUNT];
00171 
00172 static unsigned ctx_count = 0;
00173 static int ctx_current = -1;
00174 static unsigned curPFD = 0;
00175 
00176 static HDC CurrentHDC = 0;
00177 
00178 
00179 WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
00180 {
00181     int i = 0;
00182     if (!ctx_count) {
00183     for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++) {
00184         wgl_ctx[i].ctx = NULL;
00185     }
00186     }
00187     for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
00188         if ( wgl_ctx[i].ctx == NULL ) {
00189             wgl_ctx[i].ctx = 
00190         WMesaCreateContext(hdc, NULL, (GLboolean)GL_TRUE,
00191                    (GLboolean) (pfd[curPFD-1].doubleBuffered ?
00192                                    GL_TRUE : GL_FALSE), 
00193                    (GLboolean)(pfd[curPFD-1].pfd.cAlphaBits ? 
00194                    GL_TRUE : GL_FALSE) );
00195             if (wgl_ctx[i].ctx == NULL)
00196                 break;
00197             ctx_count++;
00198             return ((HGLRC)wgl_ctx[i].ctx);
00199         }
00200     }
00201     SetLastError(0);
00202     return(NULL);
00203 }
00204 
00205 WINGDIAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
00206 {
00207     int i;
00208     for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
00209         if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ){
00210             WMesaMakeCurrent((WMesaContext) hglrc, NULL);
00211             WMesaDestroyContext(wgl_ctx[i].ctx);
00212             wgl_ctx[i].ctx = NULL;
00213             ctx_count--;
00214             return(TRUE);
00215         }
00216     }
00217     SetLastError(0);
00218     return(FALSE);
00219 }
00220 
00221 WINGDIAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
00222 {
00223     if (ctx_current < 0)
00224     return 0;
00225     else
00226     return (HGLRC) wgl_ctx[ctx_current].ctx;
00227 }
00228 
00229 WINGDIAPI HDC GLAPIENTRY wglGetCurrentDC(VOID)
00230 {
00231     return CurrentHDC;
00232 }
00233 
00234 WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc, HGLRC hglrc)
00235 {
00236     int i;
00237     
00238     CurrentHDC = hdc;
00239 
00240     if (!hdc || !hglrc) {
00241     WMesaMakeCurrent(NULL, NULL);
00242     ctx_current = -1;
00243     return TRUE;
00244     }
00245     
00246     for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
00247     if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ) {
00248         WMesaMakeCurrent( (WMesaContext) hglrc, hdc );
00249         ctx_current = i;
00250         return TRUE;
00251     }
00252     }
00253     return FALSE;
00254 }
00255 
00256 
00257 WINGDIAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc,
00258                           CONST 
00259                           PIXELFORMATDESCRIPTOR *ppfd)
00260 {
00261     int     i,best = -1,bestdelta = 0x7FFFFFFF,delta;
00262     (void) hdc;
00263     
00264     if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1)
00265     {
00266         SetLastError(0);
00267         return(0);
00268     }
00269     for(i = 0; i < npfd;i++)
00270     {
00271         delta = 0;
00272         if(
00273         (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) &&
00274         !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW))
00275         continue;
00276         if(
00277         (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) &&
00278         !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP))
00279         continue;
00280         if(
00281         (ppfd->dwFlags & PFD_SUPPORT_GDI) &&
00282         !(pfd[i].pfd.dwFlags & PFD_SUPPORT_GDI))
00283         continue;
00284         if(
00285         (ppfd->dwFlags & PFD_SUPPORT_OPENGL) &&
00286         !(pfd[i].pfd.dwFlags & PFD_SUPPORT_OPENGL))
00287         continue;
00288         if(
00289         !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
00290         ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != 
00291          (pfd[i].pfd.dwFlags & PFD_DOUBLEBUFFER)))
00292         continue;
00293         if(
00294         !(ppfd->dwFlags & PFD_STEREO_DONTCARE) &&
00295         ((ppfd->dwFlags & PFD_STEREO) != 
00296          (pfd[i].pfd.dwFlags & PFD_STEREO)))
00297         continue;
00298         if(ppfd->iPixelType != pfd[i].pfd.iPixelType)
00299         delta++;
00300         if(ppfd->cAlphaBits != pfd[i].pfd.cAlphaBits)
00301         delta++;
00302         if(delta < bestdelta)
00303         {
00304             best = i + 1;
00305             bestdelta = delta;
00306             if(bestdelta == 0)
00307             break;
00308         }
00309     }
00310     if(best == -1)
00311     {
00312         SetLastError(0);
00313         return(0);
00314     }
00315     return(best);
00316 }
00317 
00318 WINGDIAPI int GLAPIENTRY wglDescribePixelFormat(HDC hdc,
00319                             int iPixelFormat,
00320                             UINT nBytes,
00321                             LPPIXELFORMATDESCRIPTOR ppfd)
00322 {
00323     (void) hdc;
00324     
00325     if(ppfd == NULL)
00326     return(npfd);
00327     if(iPixelFormat < 1 || iPixelFormat > npfd || 
00328        nBytes != sizeof(PIXELFORMATDESCRIPTOR))
00329     {
00330         SetLastError(0);
00331         return(0);
00332     }
00333     *ppfd = pfd[iPixelFormat - 1].pfd;
00334     return(npfd);
00335 }
00336 
00337 WINGDIAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc)
00338 {
00339     PROC p = (PROC) _glapi_get_proc_address((const char *) lpszProc);
00340     if (p)
00341     return p;
00342     
00343     SetLastError(0);
00344     return(NULL);
00345 }
00346 
00347 WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc)
00348 {
00349     (void) hdc;
00350     if(curPFD == 0) {
00351     SetLastError(0);
00352     return(0);
00353     }
00354     return(curPFD);
00355 }
00356 
00357 WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
00358                     const PIXELFORMATDESCRIPTOR *ppfd)
00359 {
00360     (void) hdc;
00361     
00362     if(iPixelFormat < 1 || iPixelFormat > npfd || 
00363        ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
00364     SetLastError(0);
00365     return(FALSE);
00366     }
00367     curPFD = iPixelFormat;
00368     return(TRUE);
00369 }
00370 
00371 WINGDIAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
00372 {
00373     WMesaSwapBuffers(hdc);
00374     return TRUE;
00375 }
00376 
00377 static FIXED FixedFromDouble(double d)
00378 {
00379    long l = (long) (d * 65536L);
00380    return *(FIXED *) (void *) &l;
00381 }
00382 
00383 
00384 /*
00385 ** This is cribbed from FX/fxwgl.c, and seems to implement support
00386 ** for bitmap fonts where the wglUseFontBitmapsA() code implements
00387 ** support for outline fonts.  In combination they hopefully give
00388 ** fairly generic support for fonts.
00389 */
00390 static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
00391                                  DWORD numChars, DWORD listBase)
00392 {
00393 #define VERIFY(a) a
00394     
00395     TEXTMETRIC metric;
00396     BITMAPINFO *dibInfo;
00397     HDC bitDevice;
00398     COLORREF tempColor;
00399     int i;
00400     
00401     VERIFY(GetTextMetrics(fontDevice, &metric));
00402     
00403     dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1);
00404     dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
00405     dibInfo->bmiHeader.biPlanes = 1;
00406     dibInfo->bmiHeader.biBitCount = 1;
00407     dibInfo->bmiHeader.biCompression = BI_RGB;
00408     
00409     bitDevice = CreateCompatibleDC(fontDevice);
00410     
00411     /* Swap fore and back colors so the bitmap has the right polarity */
00412     tempColor = GetBkColor(bitDevice);
00413     SetBkColor(bitDevice, GetTextColor(bitDevice));
00414     SetTextColor(bitDevice, tempColor);
00415     
00416     /* Place chars based on base line */
00417     VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0);
00418     
00419     for(i = 0; i < (int)numChars; i++) {
00420     SIZE size;
00421     char curChar;
00422     int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res;
00423     HBITMAP bitObject;
00424     HGDIOBJ origBmap;
00425     unsigned char *bmap;
00426     
00427     curChar = (char)(i + firstChar);
00428     
00429     /* Find how high/wide this character is */
00430     VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
00431     
00432     /* Create the output bitmap */
00433     charWidth = size.cx;
00434     charHeight = size.cy;
00435     /* Round up to the next multiple of 32 bits */
00436     bmapWidth = ((charWidth + 31) / 32) * 32;   
00437     bmapHeight = charHeight;
00438     bitObject = CreateCompatibleBitmap(bitDevice,
00439                        bmapWidth,
00440                        bmapHeight);
00441     /* VERIFY(bitObject); */
00442     
00443     /* Assign the output bitmap to the device */
00444     origBmap = SelectObject(bitDevice, bitObject);
00445     (void) VERIFY(origBmap);
00446     
00447     VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) );
00448     
00449     /* Use our source font on the device */
00450     VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT)));
00451     
00452     /* Draw the character */
00453     VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
00454     
00455     /* Unselect our bmap object */
00456     VERIFY(SelectObject(bitDevice, origBmap));
00457     
00458     /* Convert the display dependant representation to a 1 bit deep DIB */
00459     numBytes = (bmapWidth * bmapHeight) / 8;
00460     bmap = malloc(numBytes);
00461     dibInfo->bmiHeader.biWidth = bmapWidth;
00462     dibInfo->bmiHeader.biHeight = bmapHeight;
00463     res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
00464             dibInfo,
00465             DIB_RGB_COLORS);
00466     /* VERIFY(res); */
00467     
00468     /* Create the GL object */
00469     glNewList(i + listBase, GL_COMPILE);
00470     glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent,
00471          (GLfloat)charWidth, 0.0,
00472          bmap);
00473     glEndList();
00474     /* CheckGL(); */
00475     
00476     /* Destroy the bmap object */
00477     DeleteObject(bitObject);
00478     
00479     /* Deallocate the bitmap data */
00480     free(bmap);
00481     }
00482     
00483     /* Destroy the DC */
00484     VERIFY(DeleteDC(bitDevice));
00485     
00486     free(dibInfo);
00487     
00488     return TRUE;
00489 #undef VERIFY
00490 }
00491 
00492 WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first,
00493                          DWORD count, DWORD listBase)
00494 {
00495     int i;
00496     GLuint font_list;
00497     DWORD size;
00498     GLYPHMETRICS gm;
00499     HANDLE hBits;
00500     LPSTR lpBits;
00501     MAT2 mat;
00502     int  success = TRUE;
00503     
00504     if (count == 0)
00505     return FALSE;
00506     
00507     font_list = listBase;
00508     
00509     mat.eM11 = FixedFromDouble(1);
00510     mat.eM12 = FixedFromDouble(0);
00511     mat.eM21 = FixedFromDouble(0);
00512     mat.eM22 = FixedFromDouble(-1);
00513     
00514     memset(&gm,0,sizeof(gm));
00515     
00516     /*
00517     ** If we can't get the glyph outline, it may be because this is a fixed
00518     ** font.  Try processing it that way.
00519     */
00520     if( GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat)
00521     == GDI_ERROR ) {
00522     return wglUseFontBitmaps_FX( hdc, first, count, listBase );
00523     }
00524     
00525     /*
00526     ** Otherwise process all desired characters.
00527     */
00528     for (i = 0; i < (int)count; i++) {
00529     DWORD err;
00530     
00531     glNewList( font_list+i, GL_COMPILE );
00532     
00533     /* allocate space for the bitmap/outline */
00534     size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, 
00535                    &gm, 0, NULL, &mat);
00536     if (size == GDI_ERROR) {
00537         glEndList( );
00538         err = GetLastError();
00539         success = FALSE;
00540         continue;
00541     }
00542     
00543     hBits  = GlobalAlloc(GHND, size+1);
00544     lpBits = GlobalLock(hBits);
00545     
00546     err = 
00547         GetGlyphOutline(hdc,         /* handle to device context */
00548                 first + i,   /* character to query */
00549                 GGO_BITMAP,  /* format of data to return */
00550                 &gm,         /* ptr to structure for metrics*/
00551                 size,        /* size of buffer for data */
00552                 lpBits,      /* pointer to buffer for data */
00553                 &mat         /* pointer to transformation */
00554                 /* matrix structure */
00555         );
00556     
00557     if (err == GDI_ERROR) {
00558         GlobalUnlock(hBits);
00559         GlobalFree(hBits);
00560         
00561         glEndList( );
00562         err = GetLastError();
00563         success = FALSE;
00564         continue;
00565     }
00566     
00567     glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY,
00568          (GLfloat)-gm.gmptGlyphOrigin.x,
00569          (GLfloat)gm.gmptGlyphOrigin.y,
00570          (GLfloat)gm.gmCellIncX,
00571          (GLfloat)gm.gmCellIncY,
00572          (const GLubyte * )lpBits);
00573     
00574     GlobalUnlock(hBits);
00575     GlobalFree(hBits);
00576     
00577     glEndList( );
00578     }
00579     
00580     return success;
00581 }
00582 
00583 WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,
00584                     HGLRC hglrc2)
00585 {
00586     WMesaShareLists((WMesaContext)hglrc1, (WMesaContext)hglrc2);
00587     return(TRUE);
00588 }
00589 
00590 
00591 
00592 /* NOT IMPLEMENTED YET */
00593 WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc,
00594                      HGLRC hglrcDst,
00595                      UINT mask)
00596 {
00597     (void) hglrcSrc; (void) hglrcDst; (void) mask;
00598     return(FALSE);
00599 }
00600 
00601 WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,
00602                          int iLayerPlane)
00603 {
00604     SetLastError(0);
00605     if (iLayerPlane == 0)
00606         return wglCreateContext( hdc );
00607     return(NULL);
00608 }
00609 
00610 
00611 WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,
00612                          DWORD first,
00613                          DWORD count,
00614                          DWORD listBase)
00615 {
00616     (void) hdc; (void) first; (void) count; (void) listBase;
00617     return FALSE;
00618 }
00619 
00620 WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc,
00621                           DWORD first,
00622                           DWORD count,
00623                           DWORD listBase,
00624                           FLOAT deviation,
00625                           FLOAT extrusion,
00626                           int format,
00627                           LPGLYPHMETRICSFLOAT lpgmf)
00628 {
00629     (void) hdc; (void) first; (void) count;
00630     (void) listBase; (void) deviation; (void) extrusion; (void) format;
00631     (void) lpgmf;
00632     SetLastError(0);
00633     return(FALSE);
00634 }
00635 
00636 WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc,
00637                           DWORD first,
00638                           DWORD count,
00639                           DWORD listBase,
00640                           FLOAT deviation,
00641                           FLOAT extrusion,
00642                           int format,
00643                           LPGLYPHMETRICSFLOAT lpgmf)
00644 {
00645     (void) hdc; (void) first; (void) count;
00646     (void) listBase; (void) deviation; (void) extrusion; (void) format;
00647     (void) lpgmf;
00648     SetLastError(0);
00649     return(FALSE);
00650 }
00651 
00652 WINGDIAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc,
00653                         int iPixelFormat,
00654                         int iLayerPlane,
00655                         UINT nBytes,
00656                         LPLAYERPLANEDESCRIPTOR plpd)
00657 {
00658     (void) hdc; (void) iPixelFormat; (void) iLayerPlane; 
00659     (void) nBytes; (void) plpd;
00660     SetLastError(0);
00661     return(FALSE);
00662 }
00663 
00664 WINGDIAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc,
00665                            int iLayerPlane,
00666                            int iStart,
00667                            int cEntries,
00668                            CONST COLORREF *pcr)
00669 {
00670     (void) hdc; (void) iLayerPlane; (void) iStart; 
00671     (void) cEntries; (void) pcr;
00672     SetLastError(0);
00673     return(0);
00674 }
00675 
00676 WINGDIAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc,
00677                            int iLayerPlane,
00678                            int iStart,
00679                            int cEntries,
00680                            COLORREF *pcr)
00681 {
00682     (void) hdc; (void) iLayerPlane; (void) iStart; (void) cEntries; (void) pcr;
00683     SetLastError(0);
00684     return(0);
00685 }
00686 
00687 WINGDIAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc,
00688                          int iLayerPlane,
00689                          BOOL bRealize)
00690 {
00691     (void) hdc; (void) iLayerPlane; (void) bRealize;
00692     SetLastError(0);
00693     return(FALSE);
00694 }
00695 
00696 WINGDIAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc,
00697                           UINT fuPlanes)
00698 {
00699     (void) hdc; (void) fuPlanes;
00700     SetLastError(0);
00701     return(FALSE);
00702 }
00703 
00704 WINGDIAPI const char * GLAPIENTRY wglGetExtensionsStringARB(HDC hdc)
00705 {
00706      /* WGL_ARB_render_texture */
00707     return "WGL_ARB_extensions_string WGL_"
00708            "ARB_pixel_format WGL_ARB_multi"
00709            "sample WGL_EXT_swap_control WG"
00710            "L_ARB_pbuffer WGL_ARB_render_t"
00711            "exture WGL_ARB_make_current_re"
00712            "ad WGL_EXT_extensions_string W"
00713            "GL_ARB_buffer_region ";
00714 }
00715 
00716 GLAPI const char * GLAPIENTRY
00717 wglGetExtensionsStringEXT (void)
00718 {
00719     /* WGL_ARB_render_texture */
00720     return "WGL_ARB_extensions_string WGL_"
00721            "ARB_pixel_format WGL_ARB_multi"
00722            "sample WGL_EXT_swap_control WG"
00723            "L_ARB_pbuffer WGL_ARB_render_t"
00724            "exture WGL_ARB_make_current_re"
00725            "ad WGL_EXT_extensions_string W"
00726            "GL_ARB_buffer_region ";
00727 }
00728 
00729 GLAPI BOOL GLAPIENTRY
00730 wglChoosePixelFormatARB (HDC hdc,
00731                          const int *piAttribIList,
00732                          const FLOAT *pfAttribFList,
00733                          UINT nMaxFormats,
00734                          int *piFormats,
00735                          UINT *nNumFormats)
00736 {
00737    SetLastError(0);
00738    return FALSE;
00739 }
00740 
00741 GLAPI BOOL GLAPIENTRY
00742 wglSwapIntervalEXT (int interval)
00743 {
00744    /*
00745    WMesaContext ctx = wglGetCurrentContext();
00746    if (ctx == NULL) {
00747       return FALSE;
00748    }
00749    if (interval < 0) {
00750       interval = 0;
00751    } else if (interval > 3) {
00752       interval = 3;
00753    }
00754    ctx->gl_ctx.swapInterval = interval;
00755    return TRUE;
00756    */
00757     return FALSE;
00758 }
00759 
00760 GLAPI int GLAPIENTRY
00761 wglGetSwapIntervalEXT (void)
00762 {
00763     /*
00764 
00765    WMesaContext ctx = wglGetCurrentContext();
00766 
00767    if (ctx == NULL) {
00768       return -1;
00769    }
00770    return (int)ctx->gl_ctx.swapInterval;
00771    */
00772     return -1;
00773 }
00774 
00775 /* WGL_ARB_pixel_format */
00776 #define WGL_NUMBER_PIXEL_FORMATS_ARB    0x2000
00777 #define WGL_DRAW_TO_WINDOW_ARB          0x2001
00778 #define WGL_DRAW_TO_BITMAP_ARB          0x2002
00779 #define WGL_ACCELERATION_ARB            0x2003
00780 #define WGL_NEED_PALETTE_ARB            0x2004
00781 #define WGL_NEED_SYSTEM_PALETTE_ARB     0x2005
00782 #define WGL_SWAP_LAYER_BUFFERS_ARB      0x2006
00783 #define WGL_SWAP_METHOD_ARB             0x2007
00784 #define WGL_NUMBER_UNDERLAYS_ARB        0x2009
00785 #define WGL_TRANSPARENT_ARB             0x200A
00786 #define WGL_SHARE_DEPTH_ARB             0x200C
00787 #define WGL_SHARE_ACCUM_ARB             0x200E
00788 #define WGL_SUPPORT_GDI_ARB             0x200F
00789 #define WGL_SUPPORT_OPENGL_ARB          0x2010
00790 #define WGL_DOUBLE_BUFFER_ARB           0x2011
00791 #define WGL_STEREO_ARB                  0x2012
00792 #define WGL_PIXEL_TYPE_ARB              0x2013
00793 #define WGL_COLOR_BITS_ARB              0x2014
00794 #define WGL_RED_BITS_ARB                0x2015
00795 #define WGL_RED_SHIFT_ARB               0x2016
00796 #define WGL_GREEN_BITS_ARB              0x2017
00797 #define WGL_GREEN_SHIFT_ARB             0x2018
00798 #define WGL_BLUE_BITS_ARB               0x2019
00799 #define WGL_BLUE_SHIFT_ARB              0x201A
00800 #define WGL_ALPHA_BITS_ARB              0x201B
00801 #define WGL_ALPHA_SHIFT_ARB             0x201C
00802 #define WGL_ACCUM_BITS_ARB              0x201D
00803 #define WGL_ACCUM_RED_BITS_ARB          0x201E
00804 #define WGL_ACCUM_GREEN_BITS_ARB        0x201F
00805 #define WGL_ACCUM_BLUE_BITS_ARB         0x2020
00806 #define WGL_ACCUM_ALPHA_BITS_ARB        0x2021
00807 #define WGL_DEPTH_BITS_ARB              0x2022
00808 #define WGL_STENCIL_BITS_ARB            0x2023
00809 #define WGL_AUX_BUFFERS_ARB             0x2024
00810 #define WGL_NO_ACCELERATION_ARB         0x2025
00811 #define WGL_GENERIC_ACCELERATION_ARB    0x2026
00812 #define WGL_FULL_ACCELERATION_ARB       0x2027
00813 #define WGL_DRAW_TO_PBUFFER_ARB         0x202D
00814 #define WGL_MAX_PBUFFER_PIXELS_ARB      0x202E
00815 #define WGL_MAX_PBUFFER_WIDTH_ARB       0x202F
00816 #define WGL_MAX_PBUFFER_HEIGHT_ARB      0x2030
00817 #define WGL_SAMPLE_BUFFERS_ARB          0x2041
00818 #define WGL_SAMPLES_ARB                 0x2042
00819 
00820 
00821 GLAPI BOOL GLAPIENTRY
00822 wglGetPixelFormatAttribivARB (HDC hdc,
00823                               int iPixelFormat,
00824                               int iLayerPlane,
00825                               UINT nAttributes,
00826                               int *piAttributes,
00827                               int *piValues)
00828 {
00829     BOOL retVal = FALSE;
00830     BOOL Count = 0;
00831     int i;
00832 
00833     for (i=0;i<nAttributes;i++)
00834     {
00835         switch (piAttributes[i])
00836         {
00837 
00838             case WGL_ACCELERATION_ARB :
00839                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00840                 {
00841                     if ( ( pfd[iPixelFormat - 1].pfd.dwFlags & PFD_GENERIC_FORMAT ) == PFD_GENERIC_FORMAT)
00842                     {
00843                         piValues[i] = WGL_NO_ACCELERATION_ARB;  // or WGL_GENERIC_ACCELERATION_ARB ?
00844                     }
00845 
00846                     else if ( ( pfd[iPixelFormat - 1].pfd.dwFlags & PFD_GENERIC_FORMAT ) == PFD_GENERIC_ACCELERATED)
00847                     {
00848                         piValues[i] = WGL_GENERIC_ACCELERATION_ARB;  // or WGL_FULL_ACCELERATION_ARB ?
00849                     }
00850                     else
00851                     {
00852                         piValues[i] = WGL_FULL_ACCELERATION_ARB;  // or WGL_NO_ACCELERATION_ARB ?
00853                     }
00854                     Count++;
00855                 }
00856                 else
00857                 {
00858                      SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00859                 }
00860 
00861                 /* note from http://developer.3dlabs.com/documents/WGLmanpages/wglgetpixelformatattribarb.htm
00862                  *
00863                  * WGL_NO_ACCELERATION_ARB
00864                  * Only the software renderer supports this pixel format.
00865                  *
00866                  * WGL_GENERIC_ACCELERATION_ARB
00867                  * The pixel format is supported by an MCD driver.
00868                  *
00869                  * WGL_FULL_ACCELERATION_ARB
00870                  * The pixel format is supported by an ICD driver.  
00871                  */
00872                 break;
00873 
00874             case WGL_ACCUM_BITS_ARB :
00875                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00876                 {
00877                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumBits;
00878                     Count++;
00879                 }
00880                 else
00881                 {
00882                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00883                 }
00884                 break;
00885 
00886             case WGL_ACCUM_ALPHA_BITS_ARB :
00887                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00888                 {
00889                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumAlphaBits;
00890                     Count++;
00891                 }
00892                 else
00893                 {
00894                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00895                 }
00896                 break;
00897 
00898 
00899             case WGL_ACCUM_BLUE_BITS_ARB :
00900                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00901                 {
00902                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumBlueBits;
00903                     Count++;
00904                 }
00905                 else
00906                 {
00907                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00908                 }
00909                 break;
00910 
00911             case WGL_ACCUM_GREEN_BITS_ARB :
00912                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00913                 {
00914                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumGreenBits;
00915                     Count++;
00916                 }
00917                 else
00918                 {
00919                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00920                 }
00921                 break;
00922 
00923             case WGL_ACCUM_RED_BITS_ARB :
00924                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00925                 {
00926                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumRedBits;
00927                     Count++;
00928                 }
00929                 else
00930                 {
00931                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00932                 }
00933                 break;
00934 
00935             case WGL_ALPHA_BITS_ARB :
00936                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00937                 {
00938                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAlphaBits;
00939                     Count++;
00940                 }
00941                 else
00942                 {
00943                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00944                 }
00945                 break;
00946 
00947             case WGL_ALPHA_SHIFT_ARB :
00948                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00949                 {
00950                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAlphaShift;
00951                     Count++;
00952                 }
00953                 else
00954                 {
00955                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00956                 }
00957                 break;
00958 
00959             case WGL_AUX_BUFFERS_ARB :
00960                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00961                 {
00962                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAuxBuffers;
00963                     Count++;
00964                 }
00965                 else
00966                 {
00967                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00968                 }
00969                 break;
00970 
00971             case WGL_BLUE_BITS_ARB :
00972                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00973                 {
00974                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cBlueBits;
00975                     Count++;
00976                 }
00977                 else
00978                 {
00979                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00980                 }
00981                 break;
00982 
00983             case WGL_BLUE_SHIFT_ARB :
00984                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00985                 {
00986                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cBlueShift;
00987                     Count++;
00988                 }
00989                 else
00990                 {
00991                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
00992                 }
00993                 break;
00994 
00995             case WGL_COLOR_BITS_ARB :
00996                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
00997                 {
00998                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cColorBits;
00999                     Count++;
01000                 }
01001                 else
01002                 {
01003                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01004                 }
01005                 break;
01006 
01007             case WGL_DEPTH_BITS_ARB :
01008                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01009                 {
01010                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cDepthBits;
01011                     Count++;
01012                 }
01013                 else
01014                 {
01015                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01016                 }
01017 
01018                 break;
01019 
01020             case WGL_DRAW_TO_BITMAP_ARB :
01021                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01022                 {
01023                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.dwFlags & ~PFD_DRAW_TO_BITMAP;
01024                     Count++;
01025                 }
01026                 else
01027                 {
01028                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01029                 }
01030                 break;
01031 
01032             case WGL_DRAW_TO_WINDOW_ARB :
01033                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01034                 {
01035                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.dwFlags & ~PFD_DRAW_TO_WINDOW;
01036                     Count++;
01037                 }
01038                 else
01039                 {
01040                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01041                 }
01042 
01043                 break;
01044 
01045             case WGL_DRAW_TO_PBUFFER_ARB :
01046                 piValues[i] = GL_TRUE;
01047                 break;
01048 
01049             case WGL_DOUBLE_BUFFER_ARB :
01050                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01051                 {
01052                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_DOUBLEBUFFER) == PFD_DOUBLEBUFFER)
01053                     {
01054                         piValues[i] = GL_TRUE;
01055                     }
01056                     else
01057                     {
01058                         piValues[i] = GL_FALSE;
01059                     }
01060                     Count++;
01061                 }
01062                 else
01063                 {
01064                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01065                 }
01066                 break;
01067 
01068             case WGL_GREEN_BITS_ARB :
01069                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01070                 {
01071                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cGreenBits;
01072                     Count++;
01073                 }
01074                 else
01075                 {
01076                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01077                 }
01078                 break;
01079 
01080             case WGL_GREEN_SHIFT_ARB :
01081                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01082                 {
01083                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cGreenShift;
01084                     Count++;
01085                 }
01086                 else
01087                 {
01088                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01089                 }
01090                 break;
01091 
01092 
01093             case WGL_MAX_PBUFFER_PIXELS_ARB :
01094                 // FIXME
01095                 break;
01096 
01097             case WGL_MAX_PBUFFER_WIDTH_ARB :
01098                 // FIXME
01099                 break;
01100 
01101             case WGL_MAX_PBUFFER_HEIGHT_ARB :
01102                 // FIXME
01103                 break;
01104 
01105             case WGL_NEED_PALETTE_ARB :
01106                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01107                 {
01108                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_NEED_PALETTE) == PFD_NEED_PALETTE)
01109                     {
01110                         piValues[i] = GL_TRUE;
01111                     }
01112                     else
01113                     {
01114                         piValues[i] = GL_FALSE;
01115                     }
01116                     Count++;
01117                 }
01118                 else
01119                 {
01120                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01121                 }
01122                 break;
01123 
01124             case WGL_NEED_SYSTEM_PALETTE_ARB :
01125                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01126                 {
01127                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_NEED_PALETTE) == PFD_NEED_SYSTEM_PALETTE)
01128                     {
01129                         piValues[i] = GL_TRUE;
01130                     }
01131                     else
01132                     {
01133                         piValues[i] = GL_FALSE;
01134                     }
01135                     Count++;
01136                 }
01137                 else
01138                 {
01139                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01140                 }
01141                 break;
01142 
01143             case WGL_NUMBER_PIXEL_FORMATS_ARB :
01144                 piValues[i] = (int)npfd;
01145                 Count++;
01146                 break;
01147 
01148             case WGL_NUMBER_UNDERLAYS_ARB :
01149                 // FIXME
01150                 break;
01151 /*
01152             case WGL_OPTIMAL_PBUFFER_WIDTH_ARB
01153                 // FIXME
01154                 break;
01155 
01156             case WGL_OPTIMAL_PBUFFER_HEIGHT_ARB
01157                 // FIXME
01158                 break;
01159 */
01160             case WGL_PIXEL_TYPE_ARB :
01161                 // FIXME
01162                 break;
01163 
01164             case WGL_RED_BITS_ARB :
01165                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01166                 {
01167                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cRedBits;
01168                     Count++;
01169                 }
01170                 else
01171                 {
01172                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01173                 }
01174 
01175                 break;
01176 
01177             case WGL_RED_SHIFT_ARB :
01178                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01179                 {
01180                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cRedShift;
01181                     Count++;
01182                 }
01183                 else
01184                 {
01185                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01186                 }
01187 
01188                 break;
01189 
01190             case WGL_SAMPLES_ARB :
01191                 // FIXME
01192                 break;
01193 
01194             case WGL_SAMPLE_BUFFERS_ARB :
01195                 // FIXME
01196                 break;
01197 
01198             case WGL_SHARE_ACCUM_ARB :
01199                 // FIXME - True if the layer plane shares the accumulation buffer with the main planes. If iLayerPlane is zero, this is always true.
01200                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01201                 {
01202                     if (iLayerPlane == 0)
01203                     {
01204                         piValues[i] = GL_TRUE;
01205                     }
01206                     Count++;
01207                 }
01208                 else
01209                 {
01210                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01211                 }
01212                 break;
01213 
01214             case WGL_SHARE_DEPTH_ARB :
01215                 // FIXME - True if the layer plane shares the depth buffer with the main planes. If iLayerPlane is zero, this is always true.
01216                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01217                 {
01218                     if (iLayerPlane == 0)
01219                     {
01220                         piValues[i] = GL_TRUE;
01221                     }
01222                     Count++;
01223                 }
01224                 else
01225                 {
01226                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01227                 }
01228                 break;
01229                 break;
01230 
01231             case WGL_STENCIL_BITS_ARB :
01232                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01233                 {
01234                     piValues[i] = (int)pfd[iPixelFormat - 1].pfd.cStencilBits ;
01235                     Count++;
01236                 }
01237                 else
01238                 {
01239                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01240                 }
01241                 break;
01242 
01243             case WGL_STEREO_ARB :
01244                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01245                 {
01246                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_STEREO) == PFD_STEREO)
01247                     {
01248                         piValues[i] = GL_TRUE;
01249                     }
01250                     else
01251                     {
01252                         piValues[i] = GL_FALSE;
01253                     }
01254                     Count++;
01255                 }
01256                 else
01257                 {
01258                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01259                 }
01260                 break;
01261 
01262             case WGL_SUPPORT_GDI_ARB :
01263                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01264                 {
01265                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_SUPPORT_GDI) == PFD_SUPPORT_GDI)
01266                     {
01267                         piValues[i] = GL_TRUE;
01268                     }
01269                     else
01270                     {
01271                         piValues[i] = GL_FALSE;
01272                     }
01273                     Count++;
01274                 }
01275                 else
01276                 {
01277                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01278                 }
01279                 break;
01280 
01281             case WGL_SUPPORT_OPENGL_ARB :
01282                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01283                 {
01284                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_SUPPORT_OPENGL) == PFD_SUPPORT_OPENGL)
01285                     {
01286                         piValues[i] = GL_TRUE;
01287                     }
01288                     else
01289                     {
01290                         piValues[i] = GL_FALSE;
01291                     }
01292                     Count++;
01293                 }
01294                 else
01295                 {
01296                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01297                 }
01298                 break;
01299 
01300             case WGL_SWAP_LAYER_BUFFERS_ARB :
01301                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01302                 {
01303                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_SUPPORT_OPENGL) == PFD_SWAP_LAYER_BUFFERS)
01304                     {
01305                         piValues[i] = GL_TRUE;
01306                     }
01307                     else
01308                     {
01309                         piValues[i] = GL_FALSE;
01310                     }
01311                     Count++;
01312                 }
01313                 else
01314                 {
01315                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01316                 }
01317                 break;
01318 
01319             case WGL_SWAP_METHOD_ARB :
01320                 // FIXME
01321                 break;
01322 
01323             case WGL_TRANSPARENT_ARB :
01324                 //FIXME after WGL_TRANSPARENT_VALUE been implement piValues[i] = GL_TRUE;
01325                 piValues[i] = GL_FALSE;
01326                 Count++;
01327                 break;
01328 
01329             default :
01330                 SetLastError(0);
01331                 break;
01332         }
01333     }
01334 
01335     if(GetObjectType(hdc) != OBJ_DC)
01336     {
01337         SetLastError(ERROR_DC_NOT_FOUND);
01338     }
01339     else if (Count == nAttributes)
01340     {
01341        retVal = TRUE;
01342     }
01343     
01344 
01345     return retVal;
01346 }
01347 
01348 GLAPI BOOL GLAPIENTRY
01349 wglGetPixelFormatAttribfvARB (HDC hdc,
01350                               int iPixelFormat,
01351                               int iLayerPlane,
01352                               UINT nAttributes,
01353                               int *piAttributes,
01354                               FLOAT *pfValues)
01355 {
01356     BOOL retVal = FALSE;
01357     BOOL Count = 0;
01358     int i;
01359 
01360     for (i=0;i<nAttributes;i++)
01361     {
01362         switch (piAttributes[i])
01363         {
01364 
01365             case WGL_ACCELERATION_ARB :
01366                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01367                 {
01368                     if ( ( pfd[iPixelFormat - 1].pfd.dwFlags & PFD_GENERIC_FORMAT ) == PFD_GENERIC_FORMAT)
01369                     {
01370                         pfValues[i] = WGL_NO_ACCELERATION_ARB;  // or WGL_GENERIC_ACCELERATION_ARB ?
01371                     }
01372 
01373                     else if ( ( pfd[iPixelFormat - 1].pfd.dwFlags & PFD_GENERIC_FORMAT ) == PFD_GENERIC_ACCELERATED)
01374                     {
01375                         pfValues[i] = WGL_GENERIC_ACCELERATION_ARB;  // or WGL_FULL_ACCELERATION_ARB ?
01376                     }
01377                     else
01378                     {
01379                         pfValues[i] = WGL_FULL_ACCELERATION_ARB;  // or WGL_NO_ACCELERATION_ARB ?
01380                     }
01381                     Count++;
01382                 }
01383                 else
01384                 {
01385                      SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01386                 }
01387 
01388                 /* note from http://developer.3dlabs.com/documents/WGLmanpages/wglgetpixelformatattribarb.htm
01389                  *
01390                  * WGL_NO_ACCELERATION_ARB
01391                  * Only the software renderer supports this pixel format.
01392                  *
01393                  * WGL_GENERIC_ACCELERATION_ARB
01394                  * The pixel format is supported by an MCD driver.
01395                  *
01396                  * WGL_FULL_ACCELERATION_ARB
01397                  * The pixel format is supported by an ICD driver.  
01398                  */
01399                 break;
01400 
01401             case WGL_ACCUM_BITS_ARB :
01402                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01403                 {
01404                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumBits;
01405                     Count++;
01406                 }
01407                 else
01408                 {
01409                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01410                 }
01411                 break;
01412 
01413             case WGL_ACCUM_ALPHA_BITS_ARB :
01414                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01415                 {
01416                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumAlphaBits;
01417                     Count++;
01418                 }
01419                 else
01420                 {
01421                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01422                 }
01423                 break;
01424 
01425 
01426             case WGL_ACCUM_BLUE_BITS_ARB :
01427                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01428                 {
01429                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumBlueBits;
01430                     Count++;
01431                 }
01432                 else
01433                 {
01434                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01435                 }
01436                 break;
01437 
01438             case WGL_ACCUM_GREEN_BITS_ARB :
01439                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01440                 {
01441                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumGreenBits;
01442                     Count++;
01443                 }
01444                 else
01445                 {
01446                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01447                 }
01448                 break;
01449 
01450             case WGL_ACCUM_RED_BITS_ARB :
01451                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01452                 {
01453                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAccumRedBits;
01454                     Count++;
01455                 }
01456                 else
01457                 {
01458                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01459                 }
01460                 break;
01461 
01462             case WGL_ALPHA_BITS_ARB :
01463                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01464                 {
01465                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAlphaBits;
01466                     Count++;
01467                 }
01468                 else
01469                 {
01470                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01471                 }
01472                 break;
01473 
01474             case WGL_ALPHA_SHIFT_ARB :
01475                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01476                 {
01477                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAlphaShift;
01478                     Count++;
01479                 }
01480                 else
01481                 {
01482                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01483                 }
01484                 break;
01485 
01486             case WGL_AUX_BUFFERS_ARB :
01487                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01488                 {
01489                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cAuxBuffers;
01490                     Count++;
01491                 }
01492                 else
01493                 {
01494                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01495                 }
01496                 break;
01497 
01498             case WGL_BLUE_BITS_ARB :
01499                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01500                 {
01501                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cBlueBits;
01502                     Count++;
01503                 }
01504                 else
01505                 {
01506                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01507                 }
01508                 break;
01509 
01510             case WGL_BLUE_SHIFT_ARB :
01511                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01512                 {
01513                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cBlueShift;
01514                     Count++;
01515                 }
01516                 else
01517                 {
01518                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01519                 }
01520                 break;
01521 
01522             case WGL_COLOR_BITS_ARB :
01523                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01524                 {
01525                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cColorBits;
01526                     Count++;
01527                 }
01528                 else
01529                 {
01530                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01531                 }
01532                 break;
01533 
01534             case WGL_DEPTH_BITS_ARB :
01535                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01536                 {
01537                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cDepthBits;
01538                     Count++;
01539                 }
01540                 else
01541                 {
01542                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01543                 }
01544 
01545                 break;
01546 
01547             case WGL_DRAW_TO_BITMAP_ARB :
01548                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01549                 {
01550                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.dwFlags & ~PFD_DRAW_TO_BITMAP;
01551                     Count++;
01552                 }
01553                 else
01554                 {
01555                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01556                 }
01557                 break;
01558 
01559             case WGL_DRAW_TO_WINDOW_ARB :
01560                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01561                 {
01562                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.dwFlags & ~PFD_DRAW_TO_WINDOW;
01563                     Count++;
01564                 }
01565                 else
01566                 {
01567                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01568                 }
01569 
01570                 break;
01571 
01572             case WGL_DRAW_TO_PBUFFER_ARB :
01573                 pfValues[i] = GL_TRUE;
01574                 break;
01575 
01576             case WGL_DOUBLE_BUFFER_ARB :
01577                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01578                 {
01579                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_DOUBLEBUFFER) == PFD_DOUBLEBUFFER)
01580                     {
01581                         pfValues[i] = GL_TRUE;
01582                     }
01583                     else
01584                     {
01585                         pfValues[i] = GL_FALSE;
01586                     }
01587                     Count++;
01588                 }
01589                 else
01590                 {
01591                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01592                 }
01593                 break;
01594 
01595             case WGL_GREEN_BITS_ARB :
01596                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01597                 {
01598                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cGreenBits;
01599                     Count++;
01600                 }
01601                 else
01602                 {
01603                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01604                 }
01605                 break;
01606 
01607             case WGL_GREEN_SHIFT_ARB :
01608                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01609                 {
01610                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cGreenShift;
01611                     Count++;
01612                 }
01613                 else
01614                 {
01615                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01616                 }
01617                 break;
01618 
01619 
01620             case WGL_MAX_PBUFFER_PIXELS_ARB :
01621                 // FIXME
01622                 break;
01623 
01624             case WGL_MAX_PBUFFER_WIDTH_ARB :
01625                 // FIXME
01626                 break;
01627 
01628             case WGL_MAX_PBUFFER_HEIGHT_ARB :
01629                 // FIXME
01630                 break;
01631 
01632             case WGL_NEED_PALETTE_ARB :
01633                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01634                 {
01635                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_NEED_PALETTE) == PFD_NEED_PALETTE)
01636                     {
01637                         pfValues[i] = GL_TRUE;
01638                     }
01639                     else
01640                     {
01641                         pfValues[i] = GL_FALSE;
01642                     }
01643                     Count++;
01644                 }
01645                 else
01646                 {
01647                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01648                 }
01649                 break;
01650 
01651             case WGL_NEED_SYSTEM_PALETTE_ARB :
01652                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01653                 {
01654                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_NEED_PALETTE) == PFD_NEED_SYSTEM_PALETTE)
01655                     {
01656                         pfValues[i] = GL_TRUE;
01657                     }
01658                     else
01659                     {
01660                         pfValues[i] = GL_FALSE;
01661                     }
01662                     Count++;
01663                 }
01664                 else
01665                 {
01666                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01667                 }
01668                 break;
01669 
01670             case WGL_NUMBER_PIXEL_FORMATS_ARB :
01671                 pfValues[i] = (int)npfd;
01672                 Count++;
01673                 break;
01674 
01675             case WGL_NUMBER_UNDERLAYS_ARB :
01676                 // FIXME
01677                 break;
01678 /*
01679             case WGL_OPTIMAL_PBUFFER_WIDTH_ARB
01680                 // FIXME
01681                 break;
01682 
01683             case WGL_OPTIMAL_PBUFFER_HEIGHT_ARB
01684                 // FIXME
01685                 break;
01686 */
01687             case WGL_PIXEL_TYPE_ARB :
01688                 // FIXME
01689                 break;
01690 
01691             case WGL_RED_BITS_ARB :
01692                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01693                 {
01694                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cRedBits;
01695                     Count++;
01696                 }
01697                 else
01698                 {
01699                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01700                 }
01701 
01702                 break;
01703 
01704             case WGL_RED_SHIFT_ARB :
01705                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01706                 {
01707                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cRedShift;
01708                     Count++;
01709                 }
01710                 else
01711                 {
01712                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01713                 }
01714 
01715                 break;
01716 
01717             case WGL_SAMPLES_ARB :
01718                 // FIXME
01719                 break;
01720 
01721             case WGL_SAMPLE_BUFFERS_ARB :
01722                 // FIXME
01723                 break;
01724 
01725             case WGL_SHARE_ACCUM_ARB :
01726                 // FIXME - True if the layer plane shares the accumulation buffer with the main planes. If iLayerPlane is zero, this is always true.
01727                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01728                 {
01729                     if (iLayerPlane == 0)
01730                     {
01731                         pfValues[i] = GL_TRUE;
01732                     }
01733                     Count++;
01734                 }
01735                 else
01736                 {
01737                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01738                 }
01739                 break;
01740 
01741             case WGL_SHARE_DEPTH_ARB :
01742                 // FIXME - True if the layer plane shares the depth buffer with the main planes. If iLayerPlane is zero, this is always true.
01743                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01744                 {
01745                     if (iLayerPlane == 0)
01746                     {
01747                         pfValues[i] = GL_TRUE;
01748                     }
01749                     Count++;
01750                 }
01751                 else
01752                 {
01753                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01754                 }
01755                 break;
01756 
01757             case WGL_STENCIL_BITS_ARB :
01758                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01759                 {
01760                     pfValues[i] = (int)pfd[iPixelFormat - 1].pfd.cStencilBits ;
01761                     Count++;
01762                 }
01763                 else
01764                 {
01765                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01766                 }
01767                 break;
01768 
01769             case WGL_STEREO_ARB :
01770                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01771                 {
01772                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_STEREO) == PFD_STEREO)
01773                     {
01774                         pfValues[i] = GL_TRUE;
01775                     }
01776                     else
01777                     {
01778                         pfValues[i] = GL_FALSE;
01779                     }
01780                     Count++;
01781                 }
01782                 else
01783                 {
01784                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01785                 }
01786                 break;
01787 
01788             case WGL_SUPPORT_GDI_ARB :
01789                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01790                 {
01791                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_SUPPORT_GDI) == PFD_SUPPORT_GDI)
01792                     {
01793                         pfValues[i] = GL_TRUE;
01794                     }
01795                     else
01796                     {
01797                         pfValues[i] = GL_FALSE;
01798                     }
01799                     Count++;
01800                 }
01801                 else
01802                 {
01803                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01804                 }
01805                 break;
01806 
01807             case WGL_SUPPORT_OPENGL_ARB :
01808                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01809                 {
01810                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_SUPPORT_OPENGL) == PFD_SUPPORT_OPENGL)
01811                     {
01812                         pfValues[i] = GL_TRUE;
01813                     }
01814                     else
01815                     {
01816                         pfValues[i] = GL_FALSE;
01817                     }
01818                     Count++;
01819                 }
01820                 else
01821                 {
01822                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01823                 }
01824                 break;
01825 
01826             case WGL_SWAP_LAYER_BUFFERS_ARB :
01827                 if ((iPixelFormat > 0) &&  (iPixelFormat<=npfd))
01828                 {
01829                     if ((pfd[iPixelFormat - 1].pfd.dwFlags & PFD_SUPPORT_OPENGL) == PFD_SWAP_LAYER_BUFFERS)
01830                     {
01831                         pfValues[i] = GL_TRUE;
01832                     }
01833                     else
01834                     {
01835                         pfValues[i] = GL_FALSE;
01836                     }
01837                     Count++;
01838                 }
01839                 else
01840                 {
01841                     SetLastError(ERROR_INVALID_PIXEL_FORMAT);
01842                 }
01843                 break;
01844 
01845             case WGL_SWAP_METHOD_ARB :
01846                 // FIXME
01847                 break;
01848 
01849             case WGL_TRANSPARENT_ARB :
01850                 //FIXME after WGL_TRANSPARENT_VALUE been implement piValues[i] = GL_TRUE;
01851                 pfValues[i] = GL_FALSE;
01852                 Count++;
01853                 break;
01854 
01855             default :
01856                 SetLastError(0);
01857                 break;
01858         }
01859     }
01860 
01861     if(GetObjectType(hdc) != OBJ_DC)
01862     {
01863         SetLastError(ERROR_DC_NOT_FOUND);
01864     }
01865     else if (Count == nAttributes)
01866     {
01867        retVal = TRUE;
01868     }
01869 
01870     return retVal;
01871 }
01872 
01873 
01874 GLAPI BOOL GLAPIENTRY
01875 wglMakeContextCurrentARB(HDC hDrawDC,
01876                          HDC hReadDC,
01877                          HGLRC hglrc)
01878 {
01879    SetLastError(0);
01880    return FALSE;
01881 }
01882 
01883 GLAPI HANDLE GLAPIENTRY
01884 wglGetCurrentReadDCARB(void)
01885 {
01886    SetLastError(0);
01887    return NULL;
01888 }
01889 
01890 typedef void *HPBUFFERARB;
01891 
01892 /* WGL_ARB_pbuffer */
01893 GLAPI HPBUFFERARB GLAPIENTRY
01894 wglCreatePbufferARB (HDC hDC,
01895                      int iPixelFormat,
01896                      int iWidth,
01897                      int iHeight,
01898                      const int *piAttribList)
01899 {
01900    SetLastError(0);
01901    return NULL;
01902 }
01903 
01904 GLAPI HDC GLAPIENTRY
01905 wglGetPbufferDCARB (HPBUFFERARB hPbuffer)
01906 {
01907    SetLastError(0);
01908    return NULL;
01909 }
01910 
01911 GLAPI int GLAPIENTRY
01912 wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC)
01913 {
01914    SetLastError(0);
01915    return -1;
01916 }
01917 
01918 GLAPI BOOL GLAPIENTRY
01919 wglDestroyPbufferARB (HPBUFFERARB hPbuffer)
01920 {
01921    SetLastError(0);
01922    return FALSE;
01923 }
01924 
01925 GLAPI BOOL GLAPIENTRY
01926 wglQueryPbufferARB (HPBUFFERARB hPbuffer,
01927                     int iAttribute,
01928                     int *piValue)
01929 {
01930    SetLastError(0);
01931    return FALSE;
01932 }
01933 
01934 GLAPI HANDLE GLAPIENTRY
01935 wglCreateBufferRegionARB(HDC hDC,
01936                          int iLayerPlane,
01937                          UINT uType)
01938 {
01939    SetLastError(0);
01940    return NULL;
01941 }
01942 
01943 GLAPI VOID GLAPIENTRY
01944 wglDeleteBufferRegionARB(HANDLE hRegion)
01945 {
01946    SetLastError(0);
01947    return;
01948 }
01949 
01950 GLAPI BOOL GLAPIENTRY
01951 wglSaveBufferRegionARB(HANDLE hRegion,
01952                        int x,
01953                        int y,
01954                        int width,
01955                        int height)
01956 {
01957    SetLastError(0);
01958    return FALSE;
01959 }
01960 
01961 GLAPI BOOL GLAPIENTRY
01962 wglRestoreBufferRegionARB(HANDLE hRegion,
01963                           int x,
01964                           int y,
01965                           int width,
01966                           int height,
01967                           int xSrc,
01968                           int ySrc)
01969 {
01970    SetLastError(0);
01971    return FALSE;
01972 }
01973 
01974 /* WGL_ARB_render_texture */
01975 GLAPI BOOL GLAPIENTRY
01976 wglSetPbufferAttribARB (HPBUFFERARB hPbuffer,
01977                         const int *piAttribList)
01978 {
01979    SetLastError(0);
01980    return FALSE;
01981 }
01982 
01983 GLAPI BOOL GLAPIENTRY
01984 wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer)
01985 {
01986    SetLastError(0);
01987    return FALSE;
01988 }
01989 
01990 GLAPI BOOL GLAPIENTRY
01991 wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer)
01992 {
01993    SetLastError(0);
01994    return FALSE;
01995 }
01996 
01997 
01998 
01999 

Generated on Sun May 27 2012 04:19:57 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.