⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fxwgl.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
      if (pfd.cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0)         continue;              /* need alpha buffer */#if 0                           /* regression bug? */      if (pfd.cStencilBits > 0 && pix[i].pfd.cStencilBits == 0)         continue;              /* need stencil buffer */#endif      if (pfd.iPixelType == pix[i].pfd.iPixelType) {         best = i + 1;         break;      }   }   if (best == -1) {      FILE *err = fopen("MESA.LOG", "w");      if (err != NULL) {         fprintf(err, "wglChoosePixelFormat failed\n");         fprintf(err, "\tnSize           = %d\n", ppfd->nSize);         fprintf(err, "\tnVersion        = %d\n", ppfd->nVersion);         fprintf(err, "\tdwFlags         = %lu\n", ppfd->dwFlags);         fprintf(err, "\tiPixelType      = %d\n", ppfd->iPixelType);         fprintf(err, "\tcColorBits      = %d\n", ppfd->cColorBits);         fprintf(err, "\tcRedBits        = %d\n", ppfd->cRedBits);         fprintf(err, "\tcRedShift       = %d\n", ppfd->cRedShift);         fprintf(err, "\tcGreenBits      = %d\n", ppfd->cGreenBits);         fprintf(err, "\tcGreenShift     = %d\n", ppfd->cGreenShift);         fprintf(err, "\tcBlueBits       = %d\n", ppfd->cBlueBits);         fprintf(err, "\tcBlueShift      = %d\n", ppfd->cBlueShift);         fprintf(err, "\tcAlphaBits      = %d\n", ppfd->cAlphaBits);         fprintf(err, "\tcAlphaShift     = %d\n", ppfd->cAlphaShift);         fprintf(err, "\tcAccumBits      = %d\n", ppfd->cAccumBits);         fprintf(err, "\tcAccumRedBits   = %d\n", ppfd->cAccumRedBits);         fprintf(err, "\tcAccumGreenBits = %d\n", ppfd->cAccumGreenBits);         fprintf(err, "\tcAccumBlueBits  = %d\n", ppfd->cAccumBlueBits);         fprintf(err, "\tcAccumAlphaBits = %d\n", ppfd->cAccumAlphaBits);         fprintf(err, "\tcDepthBits      = %d\n", ppfd->cDepthBits);         fprintf(err, "\tcStencilBits    = %d\n", ppfd->cStencilBits);         fprintf(err, "\tcAuxBuffers     = %d\n", ppfd->cAuxBuffers);         fprintf(err, "\tiLayerType      = %d\n", ppfd->iLayerType);         fprintf(err, "\tbReserved       = %d\n", ppfd->bReserved);         fprintf(err, "\tdwLayerMask     = %lu\n", ppfd->dwLayerMask);         fprintf(err, "\tdwVisibleMask   = %lu\n", ppfd->dwVisibleMask);         fprintf(err, "\tdwDamageMask    = %lu\n", ppfd->dwDamageMask);         fclose(err);      }      SetLastError(0);      return 0;   }   return best;}GLAPI int GLAPIENTRYChoosePixelFormat (HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd){   return wglChoosePixelFormat(hdc, ppfd);}GLAPI int GLAPIENTRYwglDescribePixelFormat (HDC hdc, int iPixelFormat, UINT nBytes,                        LPPIXELFORMATDESCRIPTOR ppfd){   int qt_valid_pix;   qt_valid_pix = pfd_tablen();   if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix ||       ((nBytes != sizeof(PIXELFORMATDESCRIPTOR)) && (nBytes != 0))) {      SetLastError(0);      return qt_valid_pix;   }   if (nBytes != 0)      *ppfd = pix[iPixelFormat - 1].pfd;   return qt_valid_pix;}GLAPI int GLAPIENTRYDescribePixelFormat (HDC hdc, int iPixelFormat, UINT nBytes,                     LPPIXELFORMATDESCRIPTOR ppfd){   return wglDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);}GLAPI int GLAPIENTRYwglGetPixelFormat (HDC hdc){   if (curPFD == 0) {      SetLastError(0);      return 0;   }   return curPFD;}GLAPI int GLAPIENTRYGetPixelFormat (HDC hdc){   return wglGetPixelFormat(hdc);}GLAPI BOOL GLAPIENTRYwglSetPixelFormat (HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd){   int qt_valid_pix;   qt_valid_pix = pfd_tablen();   if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix) {      if (ppfd == NULL) {         PIXELFORMATDESCRIPTOR my_pfd;         if (!wglDescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &my_pfd)) {            SetLastError(0);            return FALSE;         }      } else if (ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {         SetLastError(0);         return FALSE;      }   }   curPFD = iPixelFormat;   return TRUE;}GLAPI BOOL GLAPIENTRYwglSwapBuffers (HDC hdc){   if (!ctx) {      SetLastError(0);      return FALSE;   }   fxMesaSwapBuffers();   return TRUE;}GLAPI BOOL GLAPIENTRYSetPixelFormat (HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd){   return wglSetPixelFormat(hdc, iPixelFormat, ppfd);}GLAPI BOOL GLAPIENTRYSwapBuffers(HDC hdc){   return wglSwapBuffers(hdc);}static FIXEDFixedFromDouble (double d){   struct {      FIXED f;      long l;   } pun;   pun.l = (long)(d * 65536L);   return pun.f;}/*** This was yanked from windows/gdi/wgl.c*/GLAPI BOOL GLAPIENTRYwglUseFontBitmapsA (HDC hdc, DWORD first, DWORD count, DWORD listBase){   int i;   GLuint font_list;   DWORD size;   GLYPHMETRICS gm;   HANDLE hBits;   LPSTR lpBits;   MAT2 mat;   int success = TRUE;   font_list = listBase;   mat.eM11 = FixedFromDouble(1);   mat.eM12 = FixedFromDouble(0);   mat.eM21 = FixedFromDouble(0);   mat.eM22 = FixedFromDouble(-1);   memset(&gm, 0, sizeof(gm));   /*    ** If we can't get the glyph outline, it may be because this is a fixed    ** font.  Try processing it that way.    */   if (GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat) == GDI_ERROR) {      return wglUseFontBitmaps_FX(hdc, first, count, listBase);   }   /*    ** Otherwise process all desired characters.    */   for (i = 0; i < count; i++) {      DWORD err;      glNewList(font_list + i, GL_COMPILE);      /* allocate space for the bitmap/outline */      size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, &gm, 0, NULL, &mat);      if (size == GDI_ERROR) {         glEndList();         err = GetLastError();         success = FALSE;         continue;      }      hBits = GlobalAlloc(GHND, size + 1);      lpBits = GlobalLock(hBits);      err = GetGlyphOutline(hdc,        /* handle to device context */                            first + i,  /* character to query */                            GGO_BITMAP, /* format of data to return */                            &gm,        /* pointer to structure for metrics */                            size,       /* size of buffer for data */                            lpBits,     /* pointer to buffer for data */                            &mat        /* pointer to transformation */                                        /* matrix structure */          );      if (err == GDI_ERROR) {         GlobalUnlock(hBits);         GlobalFree(hBits);         glEndList();         err = GetLastError();         success = FALSE;         continue;      }      glBitmap(gm.gmBlackBoxX, gm.gmBlackBoxY,               -gm.gmptGlyphOrigin.x,               gm.gmptGlyphOrigin.y,               gm.gmCellIncX, gm.gmCellIncY,               (const GLubyte *)lpBits);      GlobalUnlock(hBits);      GlobalFree(hBits);      glEndList();   }   return success;}GLAPI BOOL GLAPIENTRYwglDescribeLayerPlane (HDC hdc, int iPixelFormat, int iLayerPlane,                       UINT nBytes, LPLAYERPLANEDESCRIPTOR ppfd){   SetLastError(0);   return FALSE;}GLAPI int GLAPIENTRYwglGetLayerPaletteEntries (HDC hdc, int iLayerPlane, int iStart,                           int cEntries, COLORREF *pcr){   SetLastError(0);   return FALSE;}GLAPI BOOL GLAPIENTRYwglRealizeLayerPalette (HDC hdc, int iLayerPlane, BOOL bRealize){   SetLastError(0);   return FALSE;}GLAPI int GLAPIENTRYwglSetLayerPaletteEntries (HDC hdc, int iLayerPlane, int iStart,                           int cEntries, CONST COLORREF *pcr){   SetLastError(0);   return FALSE;}/*************************************************************************** * [dBorca] simplistic ICD implementation, based on ICD code by Gregor Anich */typedef struct _icdTable {   DWORD size;   PROC table[336];} ICDTABLE, *PICDTABLE;#ifdef USE_MGL_NAMESPACE#define GL_FUNC(func) mgl##func#else#define GL_FUNC(func) gl##func#endifstatic ICDTABLE icdTable = { 336, {#define ICD_ENTRY(func) (PROC)GL_FUNC(func),#include "../icd/icdlist.h"#undef ICD_ENTRY} };GLAPI BOOL GLAPIENTRYDrvCopyContext (HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask){   return wglCopyContext(hglrcSrc, hglrcDst, mask);}GLAPI HGLRC GLAPIENTRYDrvCreateContext (HDC hdc){   return wglCreateContext(hdc);}GLAPI BOOL GLAPIENTRYDrvDeleteContext (HGLRC hglrc){   return wglDeleteContext(hglrc);}GLAPI HGLRC GLAPIENTRYDrvCreateLayerContext (HDC hdc, int iLayerPlane){   return wglCreateContext(hdc);}GLAPI PICDTABLE GLAPIENTRYDrvSetContext (HDC hdc, HGLRC hglrc, void *callback){   return wglMakeCurrent(hdc, hglrc) ? &icdTable : NULL;}GLAPI BOOL GLAPIENTRYDrvReleaseContext (HGLRC hglrc){   return TRUE;}GLAPI BOOL GLAPIENTRYDrvShareLists (HGLRC hglrc1, HGLRC hglrc2){   return wglShareLists(hglrc1, hglrc2);}GLAPI BOOL GLAPIENTRYDrvDescribeLayerPlane (HDC hdc, int iPixelFormat,                       int iLayerPlane, UINT nBytes,                       LPLAYERPLANEDESCRIPTOR plpd){   return wglDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);}GLAPI int GLAPIENTRYDrvSetLayerPaletteEntries (HDC hdc, int iLayerPlane,                           int iStart, int cEntries, CONST COLORREF *pcr){   return wglSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);}GLAPI int GLAPIENTRYDrvGetLayerPaletteEntries (HDC hdc, int iLayerPlane,                           int iStart, int cEntries, COLORREF *pcr){   return wglGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);}GLAPI BOOL GLAPIENTRYDrvRealizeLayerPalette (HDC hdc, int iLayerPlane, BOOL bRealize){   return wglRealizeLayerPalette(hdc, iLayerPlane, bRealize);}GLAPI BOOL GLAPIENTRYDrvSwapLayerBuffers (HDC hdc, UINT fuPlanes){   return wglSwapLayerBuffers(hdc, fuPlanes);}GLAPI int GLAPIENTRYDrvDescribePixelFormat (HDC hdc, int iPixelFormat, UINT nBytes,                        LPPIXELFORMATDESCRIPTOR ppfd){   return wglDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);}GLAPI PROC GLAPIENTRYDrvGetProcAddress (LPCSTR lpszProc){   return wglGetProcAddress(lpszProc);}GLAPI BOOL GLAPIENTRYDrvSetPixelFormat (HDC hdc, int iPixelFormat){   return wglSetPixelFormat(hdc, iPixelFormat, NULL);}GLAPI BOOL GLAPIENTRYDrvSwapBuffers (HDC hdc){   return wglSwapBuffers(hdc);}GLAPI BOOL GLAPIENTRYDrvValidateVersion (DWORD version){   (void)version;   return TRUE;}#if (_MSC_VER >= 1200)#pragma warning( pop )#endif#endif /* FX */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -