1 /* fxwgl.c - Microsoft wgl functions emulation for
2 * 3Dfx VooDoo/Mesa interface
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * See the file fxapi.c for more informations about authors
38 #include "GL/fxmesa.h"
41 #define MAX_MESA_ATTRS 20
49 struct __pixelformat__
51 PIXELFORMATDESCRIPTOR pfd
;
52 GLint mesaAttr
[MAX_MESA_ATTRS
];
55 WINGDIAPI
void GLAPIENTRY
gl3DfxSetPaletteEXT(GLuint
*);
57 static struct __extensions__ ext
[] = {
59 #ifdef GL_EXT_polygon_offset
60 { (PROC
)glPolygonOffsetEXT
, "glPolygonOffsetEXT" },
62 { (PROC
)glBlendEquationEXT
, "glBlendEquationEXT" },
63 { (PROC
)glBlendColorEXT
, "glBlendColorExt" },
64 { (PROC
)glVertexPointerEXT
, "glVertexPointerEXT" },
65 { (PROC
)glNormalPointerEXT
, "glNormalPointerEXT" },
66 { (PROC
)glColorPointerEXT
, "glColorPointerEXT" },
67 { (PROC
)glIndexPointerEXT
, "glIndexPointerEXT" },
68 { (PROC
)glTexCoordPointerEXT
, "glTexCoordPointer" },
69 { (PROC
)glEdgeFlagPointerEXT
, "glEdgeFlagPointerEXT" },
70 { (PROC
)glGetPointervEXT
, "glGetPointervEXT" },
71 { (PROC
)glArrayElementEXT
, "glArrayElementEXT" },
72 { (PROC
)glDrawArraysEXT
, "glDrawArrayEXT" },
73 { (PROC
)glAreTexturesResidentEXT
, "glAreTexturesResidentEXT" },
74 { (PROC
)glBindTextureEXT
, "glBindTextureEXT" },
75 { (PROC
)glDeleteTexturesEXT
, "glDeleteTexturesEXT" },
76 { (PROC
)glGenTexturesEXT
, "glGenTexturesEXT" },
77 { (PROC
)glIsTextureEXT
, "glIsTextureEXT" },
78 { (PROC
)glPrioritizeTexturesEXT
, "glPrioritizeTexturesEXT" },
79 { (PROC
)glCopyTexSubImage3DEXT
, "glCopyTexSubImage3DEXT" },
80 { (PROC
)glTexImage3DEXT
, "glTexImage3DEXT" },
81 { (PROC
)glTexSubImage3DEXT
, "glTexSubImage3DEXT" },
82 { (PROC
)gl3DfxSetPaletteEXT
, "3DFX_set_global_palette" },
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
)glActiveTextureARB
, "glActiveTextureARB" },
92 { (PROC
)glClientActiveTextureARB
, "glClientActiveTextureARB" },
93 { (PROC
)glMultiTexCoord1dARB
, "glMultiTexCoord1dARB" },
94 { (PROC
)glMultiTexCoord1dvARB
, "glMultiTexCoord1dvARB" },
95 { (PROC
)glMultiTexCoord1fARB
, "glMultiTexCoord1fARB" },
96 { (PROC
)glMultiTexCoord1fvARB
, "glMultiTexCoord1fvARB" },
97 { (PROC
)glMultiTexCoord1iARB
, "glMultiTexCoord1iARB" },
98 { (PROC
)glMultiTexCoord1ivARB
, "glMultiTexCoord1ivARB" },
99 { (PROC
)glMultiTexCoord1sARB
, "glMultiTexCoord1sARB" },
100 { (PROC
)glMultiTexCoord1svARB
, "glMultiTexCoord1svARB" },
101 { (PROC
)glMultiTexCoord2dARB
, "glMultiTexCoord2dARB" },
102 { (PROC
)glMultiTexCoord2dvARB
, "glMultiTexCoord2dvARB" },
103 { (PROC
)glMultiTexCoord2fARB
, "glMultiTexCoord2fARB" },
104 { (PROC
)glMultiTexCoord2fvARB
, "glMultiTexCoord2fvARB" },
105 { (PROC
)glMultiTexCoord2iARB
, "glMultiTexCoord2iARB" },
106 { (PROC
)glMultiTexCoord2ivARB
, "glMultiTexCoord2ivARB" },
107 { (PROC
)glMultiTexCoord2sARB
, "glMultiTexCoord2sARB" },
108 { (PROC
)glMultiTexCoord2svARB
, "glMultiTexCoord2svARB" },
109 { (PROC
)glMultiTexCoord3dARB
, "glMultiTexCoord3dARB" },
110 { (PROC
)glMultiTexCoord3dvARB
, "glMultiTexCoord3dvARB" },
111 { (PROC
)glMultiTexCoord3fARB
, "glMultiTexCoord3fARB" },
112 { (PROC
)glMultiTexCoord3fvARB
, "glMultiTexCoord3fvARB" },
113 { (PROC
)glMultiTexCoord3iARB
, "glMultiTexCoord3iARB" },
114 { (PROC
)glMultiTexCoord3ivARB
, "glMultiTexCoord3ivARB" },
115 { (PROC
)glMultiTexCoord3sARB
, "glMultiTexCoord3sARB" },
116 { (PROC
)glMultiTexCoord3svARB
, "glMultiTexCoord3svARB" },
117 { (PROC
)glMultiTexCoord4dARB
, "glMultiTexCoord4dARB" },
118 { (PROC
)glMultiTexCoord4dvARB
, "glMultiTexCoord4dvARB" },
119 { (PROC
)glMultiTexCoord4fARB
, "glMultiTexCoord4fARB" },
120 { (PROC
)glMultiTexCoord4fvARB
, "glMultiTexCoord4fvARB" },
121 { (PROC
)glMultiTexCoord4iARB
, "glMultiTexCoord4iARB" },
122 { (PROC
)glMultiTexCoord4ivARB
, "glMultiTexCoord4ivARB" },
123 { (PROC
)glMultiTexCoord4sARB
, "glMultiTexCoord4sARB" },
124 { (PROC
)glMultiTexCoord4svARB
, "glMultiTexCoord4svARB" },
125 { (PROC
)glLockArraysEXT
, "glLockArraysEXT" },
126 { (PROC
)glUnlockArraysEXT
, "glUnlockArraysEXT" }
129 static int qt_ext
= sizeof(ext
) / sizeof(ext
[0]);
131 struct __pixelformat__ pix
[] =
136 sizeof(PIXELFORMATDESCRIPTOR
), 1,
137 PFD_DRAW_TO_WINDOW
|PFD_SUPPORT_OPENGL
|
138 PFD_DOUBLEBUFFER
|PFD_SWAP_COPY
,
151 FXMESA_ALPHA_SIZE
, 0,
152 FXMESA_DEPTH_SIZE
, 0,
153 FXMESA_STENCIL_SIZE
, 0,
154 FXMESA_ACCUM_SIZE
, 0,
162 sizeof(PIXELFORMATDESCRIPTOR
), 1,
163 PFD_DRAW_TO_WINDOW
|PFD_SUPPORT_OPENGL
|
164 PFD_DOUBLEBUFFER
|PFD_SWAP_COPY
,
177 FXMESA_ALPHA_SIZE
, 8,
178 FXMESA_DEPTH_SIZE
, 0,
179 FXMESA_STENCIL_SIZE
, 0,
180 FXMESA_ACCUM_SIZE
, 0,
188 sizeof(PIXELFORMATDESCRIPTOR
), 1,
189 PFD_DRAW_TO_WINDOW
|PFD_SUPPORT_OPENGL
|
190 PFD_DOUBLEBUFFER
|PFD_SWAP_COPY
,
203 FXMESA_ALPHA_SIZE
, 0,
204 FXMESA_DEPTH_SIZE
, 16,
205 FXMESA_STENCIL_SIZE
, 0,
206 FXMESA_ACCUM_SIZE
, 0,
211 static int qt_pix
= sizeof(pix
) / sizeof(pix
[0]);
213 static fxMesaContext ctx
= NULL
;
214 static WNDPROC hWNDOldProc
;
215 static int curPFD
= 0;
219 static GLboolean haveDualHead
;
221 /* For the in-window-rendering hack */
223 static GLboolean gdiWindowHack
;
224 static GLboolean gdiWindowHackEna
;
225 static void *dibSurfacePtr
;
226 static BITMAPINFO
*dibBMI
;
227 static HBITMAP dibHBM
;
230 LONG GLAPIENTRY
__wglMonitor(HWND hwnd
,UINT message
,UINT wParam
,LONG lParam
)
233 long ret
; /* Now gives the resized window at the end to hWNDOldProc */
235 if(ctx
&& hwnd
== hWND
) {
240 case WM_DISPLAYCHANGE
:
242 if (wParam
!= SIZE_MINIMIZED
) {
243 static int moving
= 0;
245 if(fxQueryHardware()!=GR_SSTTYPE_VOODOO
) {
246 if(!grSstControl(GR_CONTROL_RESIZE
)) {
248 SetWindowPos(hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOZORDER
);
250 if(!grSstControl(GR_CONTROL_RESIZE
)) {
251 /*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK);*/
252 PostMessage(hWND
,WM_CLOSE
,0,0);
257 /* Do the clipping in the glide library */
258 grClipWindow(0,0,grSstScreenWidth(),grSstScreenHeight());
259 /* And let the new size set in the context */
260 fxMesaUpdateScreenSize(ctx
);
265 if((fxQueryHardware()==GR_SSTTYPE_VOODOO
) &&
268 WORD fActive
= LOWORD(wParam
);
269 BOOL fMinimized
= (BOOL
) HIWORD(wParam
);
271 if((fActive
== WA_INACTIVE
) || fMinimized
)
272 grSstControl(GR_CONTROL_DEACTIVATE
);
274 grSstControl(GR_CONTROL_ACTIVATE
);
280 if(gdiWindowHackEna
&& (VK_RETURN
== wParam
)) {
282 gdiWindowHack
= GL_FALSE
;
283 grSstControl(GR_CONTROL_ACTIVATE
);
285 gdiWindowHack
= GL_TRUE
;
286 grSstControl(GR_CONTROL_DEACTIVATE
);
293 /* Finaly call the hWNDOldProc, which handles the resize witch the
294 now changed window sizes */
295 ret
= CallWindowProc( hWNDOldProc
, hwnd
, message
, wParam
, lParam
);
300 BOOL GLAPIENTRY
wglCopyContext(HGLRC hglrcSrc
,HGLRC hglrcDst
,UINT mask
)
305 HGLRC GLAPIENTRY
wglCreateContext(HDC hdc
)
316 if(!(hWnd
= WindowFromDC(hdc
))) {
326 if((oldProc
= (WNDPROC
)GetWindowLong(hWnd
,GWL_WNDPROC
)) != __wglMonitor
) {
327 hWNDOldProc
= oldProc
;
328 SetWindowLong(hWnd
,GWL_WNDPROC
,(LONG
)__wglMonitor
);
332 freopen("MESA.LOG","w",stderr
);
335 ShowWindow(hWnd
, SW_SHOWNORMAL
);
336 SetForegroundWindow(hWnd
);
337 Sleep(100); /* an hack for win95 */
339 if(fxQueryHardware() == GR_SSTTYPE_VOODOO
) {
342 GetClientRect(hWnd
,&cliRect
);
343 error
= !(ctx
= fxMesaCreateBestContext((GLuint
)hWnd
,cliRect
.right
,cliRect
.bottom
,
344 pix
[curPFD
- 1].mesaAttr
));
347 /* create the DIB section for windowed rendering */
354 dibBMI
= (BITMAPINFO
*) MALLOC( sizeof(BITMAPINFO
) + (256*sizeof(RGBQUAD
)));
356 memset(dibBMI
,0,sizeof(BITMAPINFO
) + (256*sizeof(RGBQUAD
)));
358 dibBMI
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
359 dibBMI
->bmiHeader
.biWidth
= ctx
->width
;
360 dibBMI
->bmiHeader
.biHeight
= -ctx
->height
;
361 dibBMI
->bmiHeader
.biPlanes
= (short)1;
362 dibBMI
->bmiHeader
.biBitCount
= (short)16;
363 dibBMI
->bmiHeader
.biCompression
= BI_BITFIELDS
;
364 dibBMI
->bmiHeader
.biSizeImage
= 0;
365 dibBMI
->bmiHeader
.biXPelsPerMeter
= 0;
366 dibBMI
->bmiHeader
.biYPelsPerMeter
= 0;
367 dibBMI
->bmiHeader
.biClrUsed
= 3;
368 dibBMI
->bmiHeader
.biClrImportant
= 3;
370 p
= (DWORD
*)dibBMI
->bmiColors
;
375 dibHBM
= CreateDIBSection(hDC
, dibBMI
, DIB_RGB_COLORS
, &dibSurfacePtr
, NULL
, 0);
377 ReleaseDC(dibWnd
, hDC
);
379 gdiWindowHackEna
= (dibHBM
!= NULL
? GL_TRUE
: GL_FALSE
);
381 if (!getenv("MESA_WGL_FX") || !strcmp(getenv("MESA_WGL_FX"),"fullscreen"))
382 gdiWindowHack
= GL_FALSE
;
384 gdiWindowHack
= GL_TRUE
;
385 grSstControl(GR_CONTROL_DEACTIVATE
);
389 /* For the Voodoo Rush */
391 if(getenv("MESA_WGL_FX") && !strcmp(getenv("MESA_WGL_FX"),"fullscreen")) {
394 GetClientRect(hWnd
,&cliRect
);
395 error
= !(ctx
= fxMesaCreateBestContext((GLuint
)hWnd
,cliRect
.right
,cliRect
.bottom
,
396 pix
[curPFD
- 1].mesaAttr
));
398 error
= !(ctx
= fxMesaCreateContext((GLuint
)hWnd
,GR_RESOLUTION_NONE
,GR_REFRESH_75Hz
,
399 pix
[curPFD
- 1].mesaAttr
));
402 if(getenv("SST_DUALHEAD"))
403 haveDualHead
=((atoi(getenv("SST_DUALHEAD"))==1) ? GL_TRUE
:GL_FALSE
);
405 haveDualHead
=GL_FALSE
;
415 /* Required by the OpenGL Optimizer 1.1 (is it a Optimizer bug ?) */
416 wglMakeCurrent(hdc
,(HGLRC
)1);
421 HGLRC GLAPIENTRY
wglCreateLayerContext(HDC hdc
,int iLayerPlane
)
427 BOOL GLAPIENTRY
wglDeleteContext(HGLRC hglrc
)
429 if(ctx
&& hglrc
== (HGLRC
)1) {
430 if (gdiWindowHackEna
) {
431 DeleteObject(dibHBM
);
434 dibSurfacePtr
= NULL
;
440 fxMesaDestroyContext(ctx
);
442 SetWindowLong(WindowFromDC(hDC
),GWL_WNDPROC
,(LONG
)hWNDOldProc
);
454 HGLRC GLAPIENTRY
wglGetCurrentContext(VOID
)
463 HDC GLAPIENTRY
wglGetCurrentDC(VOID
)
472 PROC GLAPIENTRY
wglGetProcAddress(LPCSTR lpszProc
)
476 /*fprintf(stderr,"fxMesa: looking for extension %s\n",lpszProc);
479 for(i
= 0;i
< qt_ext
;i
++)
480 if(!strcmp(lpszProc
,ext
[i
].name
)) {
481 /*fprintf(stderr,"fxMesa: found extension %s\n",lpszProc);
490 BOOL GLAPIENTRY
wglMakeCurrent(HDC hdc
,HGLRC hglrc
)
492 if((hdc
==NULL
) && (hglrc
==NULL
))
495 if(!ctx
|| hglrc
!= (HGLRC
)1 || WindowFromDC(hdc
) != hWND
) {
502 fxMesaMakeCurrent(ctx
);
507 BOOL GLAPIENTRY
wglShareLists(HGLRC hglrc1
,HGLRC hglrc2
)
509 if(!ctx
|| hglrc1
!= (HGLRC
)1 || hglrc1
!= hglrc2
) {
517 BOOL GLAPIENTRY
wglUseFontBitmaps(HDC fontDevice
, DWORD firstChar
, DWORD numChars
, DWORD listBase
)
527 VERIFY(GetTextMetrics(fontDevice
, &metric
));
529 dibInfo
= (BITMAPINFO
*) calloc(sizeof(BITMAPINFO
) + sizeof(RGBQUAD
), 1);
530 dibInfo
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
531 dibInfo
->bmiHeader
.biPlanes
= 1;
532 dibInfo
->bmiHeader
.biBitCount
= 1;
533 dibInfo
->bmiHeader
.biCompression
= BI_RGB
;
535 bitDevice
= CreateCompatibleDC(fontDevice
);
536 // HDC bitDevice = CreateDC("DISPLAY", NULL, NULL, NULL);
537 // VERIFY(bitDevice);
539 // Swap fore and back colors so the bitmap has the right polarity
540 tempColor
= GetBkColor(bitDevice
);
541 SetBkColor(bitDevice
, GetTextColor(bitDevice
));
542 SetTextColor(bitDevice
, tempColor
);
544 // Place chars based on base line
545 VERIFY(SetTextAlign(bitDevice
, TA_BASELINE
) >= 0 ? 1 : 0);
547 for(i
= 0; i
< numChars
; i
++) {
550 int charWidth
,charHeight
,bmapWidth
,bmapHeight
,numBytes
,res
;
555 curChar
= i
+ firstChar
;
557 // Find how high/wide this character is
558 VERIFY(GetTextExtentPoint32(bitDevice
, &curChar
, 1, &size
));
560 // Create the output bitmap
562 charHeight
= size
.cy
;
563 bmapWidth
= ((charWidth
+ 31) / 32) * 32; // Round up to the next multiple of 32 bits
564 bmapHeight
= charHeight
;
565 bitObject
= CreateCompatibleBitmap(bitDevice
,
570 // Assign the output bitmap to the device
571 origBmap
= SelectObject(bitDevice
, bitObject
);
574 VERIFY( PatBlt( bitDevice
, 0, 0, bmapWidth
, bmapHeight
,BLACKNESS
) );
576 // Use our source font on the device
577 VERIFY(SelectObject(bitDevice
, GetCurrentObject(fontDevice
,OBJ_FONT
)));
579 // Draw the character
580 VERIFY(TextOut(bitDevice
, 0, metric
.tmAscent
, &curChar
, 1));
582 // Unselect our bmap object
583 VERIFY(SelectObject(bitDevice
, origBmap
));
585 // Convert the display dependant representation to a 1 bit deep DIB
586 numBytes
= (bmapWidth
* bmapHeight
) / 8;
587 bmap
= MALLOC(numBytes
);
588 dibInfo
->bmiHeader
.biWidth
= bmapWidth
;
589 dibInfo
->bmiHeader
.biHeight
= bmapHeight
;
590 res
= GetDIBits(bitDevice
, bitObject
, 0, bmapHeight
, bmap
,
595 // Create the GL object
596 glNewList(i
+ listBase
, GL_COMPILE
);
597 glBitmap(bmapWidth
, bmapHeight
, 0.0, metric
.tmDescent
,
603 // Destroy the bmap object
604 DeleteObject(bitObject
);
606 // Deallocate the bitmap data
611 VERIFY(DeleteDC(bitDevice
));
619 BOOL GLAPIENTRY
wglUseFontBitmapsW(HDC hdc
,DWORD first
,DWORD count
,DWORD listBase
)
624 BOOL GLAPIENTRY
wglUseFontOutlinesA(HDC hdc
,DWORD first
,DWORD count
,
625 DWORD listBase
,FLOAT deviation
,
626 FLOAT extrusion
,int format
,
627 LPGLYPHMETRICSFLOAT lpgmf
)
633 BOOL GLAPIENTRY
wglUseFontOutlinesW(HDC hdc
,DWORD first
,DWORD count
,
634 DWORD listBase
,FLOAT deviation
,
635 FLOAT extrusion
,int format
,
636 LPGLYPHMETRICSFLOAT lpgmf
)
643 BOOL GLAPIENTRY
wglSwapLayerBuffers(HDC hdc
,UINT fuPlanes
)
645 if(ctx
&& WindowFromDC(hdc
) == hWND
) {
655 int GLAPIENTRY
wglChoosePixelFormat(HDC hdc
,
656 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
658 int i
,best
=-1,qt_valid_pix
;
660 qt_valid_pix
= qt_pix
;
662 if(ppfd
->nSize
!= sizeof(PIXELFORMATDESCRIPTOR
) || ppfd
->nVersion
!= 1) {
667 for(i
= 0;i
< qt_valid_pix
;i
++) {
668 if((ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
) && !(pix
[i
].pfd
.dwFlags
& PFD_DRAW_TO_WINDOW
))
670 if((ppfd
->dwFlags
& PFD_DRAW_TO_BITMAP
) && !(pix
[i
].pfd
.dwFlags
& PFD_DRAW_TO_BITMAP
))
672 if((ppfd
->dwFlags
& PFD_SUPPORT_GDI
) && !(pix
[i
].pfd
.dwFlags
& PFD_SUPPORT_GDI
))
674 if((ppfd
->dwFlags
& PFD_SUPPORT_OPENGL
) && !(pix
[i
].pfd
.dwFlags
& PFD_SUPPORT_OPENGL
))
676 if(!(ppfd
->dwFlags
& PFD_DOUBLEBUFFER_DONTCARE
) &&
677 ((ppfd
->dwFlags
& PFD_DOUBLEBUFFER
) != (pix
[i
].pfd
.dwFlags
& PFD_DOUBLEBUFFER
)))
679 if(!(ppfd
->dwFlags
& PFD_STEREO_DONTCARE
) &&
680 ((ppfd
->dwFlags
& PFD_STEREO
) != (pix
[i
].pfd
.dwFlags
& PFD_STEREO
)))
683 if (ppfd
->cDepthBits
> 0 && pix
[i
].pfd
.cDepthBits
== 0)
684 continue; /* need depth buffer */
686 if (ppfd
->cAlphaBits
> 0 && pix
[i
].pfd
.cAlphaBits
== 0)
687 continue; /* need alpha buffer */
689 if(ppfd
->iPixelType
== pix
[i
].pfd
.iPixelType
) {
703 int GLAPIENTRY
ChoosePixelFormat(HDC hdc
,
704 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
706 return wglChoosePixelFormat(hdc
,ppfd
);
709 int GLAPIENTRY
wglDescribePixelFormat(HDC hdc
,int iPixelFormat
,UINT nBytes
,
710 LPPIXELFORMATDESCRIPTOR ppfd
)
714 qt_valid_pix
= qt_pix
;
716 if(iPixelFormat
< 1 || iPixelFormat
> qt_valid_pix
||
717 ((nBytes
!= sizeof(PIXELFORMATDESCRIPTOR
)) && (nBytes
!= 0))) {
723 *ppfd
= pix
[iPixelFormat
- 1].pfd
;
725 return(qt_valid_pix
);
728 int GLAPIENTRY
DescribePixelFormat(HDC hdc
,int iPixelFormat
,UINT nBytes
,
729 LPPIXELFORMATDESCRIPTOR ppfd
)
731 return wglDescribePixelFormat(hdc
,iPixelFormat
,nBytes
,ppfd
);
734 int GLAPIENTRY
wglGetPixelFormat(HDC hdc
)
744 int GLAPIENTRY
GetPixelFormat(HDC hdc
)
746 return wglGetPixelFormat(hdc
);
749 BOOL GLAPIENTRY
wglSetPixelFormat(HDC hdc
,int iPixelFormat
,
750 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
754 qt_valid_pix
= qt_pix
;
756 if(iPixelFormat
< 1 || iPixelFormat
> qt_valid_pix
|| ppfd
->nSize
!= sizeof(PIXELFORMATDESCRIPTOR
)) {
760 curPFD
= iPixelFormat
;
765 BOOL GLAPIENTRY
wglSwapBuffers(HDC hdc
)
775 GLuint width
=ctx
->width
;
776 GLuint height
=ctx
->height
;
778 HDC hdcScreen
= GetDC(dibWnd
);
779 HDC hdcDIBSection
= CreateCompatibleDC(hdcScreen
);
780 HBITMAP holdBitmap
= (HBITMAP
) SelectObject(hdcDIBSection
, dibHBM
);
782 grLfbReadRegion(GR_BUFFER_FRONTBUFFER
, 0, 0,
787 /* Since the hardware is configured for GR_COLORFORMAT_ABGR the pixel data is
788 * going to come out as BGR 565, which is reverse of what we need for blitting
789 * to screen, so we need to convert it here pixel-by-pixel (ick). This loop would NOT
790 * be required if the color format was changed to GR_COLORFORMAT_ARGB, but I do
791 * not know the ramifications of that, so this will work until that is resolved.
793 * This routine CRIES out for MMX implementation, however since that's not
794 * guaranteed to be running on MMX enabled hardware so I'm not going to do
795 * that. I'm just going to try to make a reasonably efficient C
798 * This routine drops frame rate by <1 fps on a 200Mhz MMX processor with a 640x480
799 * display. Obviously, it's performance hit will be higher on larger displays and
800 * less on smaller displays. To support the window-hack display this is probably fine.
803 unsigned long *pixel
= dibSurfacePtr
;
804 unsigned long count
= (width
* height
) / 2;
808 *pixel
++ = (*pixel
& 0x07e007e0) /* greens */
809 | ((*pixel
& 0xf800f800) >> 11) /* swap blues */
810 | ((*pixel
& 0x001f001f) << 11) /* swap reds */
815 BitBlt(hdcScreen
, 0, 0,
820 ReleaseDC(dibWnd
, hdcScreen
);
821 SelectObject(hdcDIBSection
, holdBitmap
);
822 DeleteDC(hdcDIBSection
);
828 BOOL GLAPIENTRY
SetPixelFormat(HDC hdc
, int iPixelFormat
,
829 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
831 return wglSetPixelFormat(hdc
,iPixelFormat
,ppfd
);
834 BOOL GLAPIENTRY
SwapBuffers(HDC hdc
)
836 return wglSwapBuffers(hdc
);