1 /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
30 * Thank you for your contribution, David!
32 * Please make note of the above copyright/license statement. If you
33 * contributed code or bug fixes to this code under the previous (GNU
34 * Library) license and object to the new license, your code will be
35 * removed at your request. Please see the Mesa docs/COPYRIGHT file
36 * for more information.
38 * Additional Mesa/3Dfx driver developers:
39 * Daryll Strauss <daryll@precisioninsight.com>
40 * Keith Whitwell <keith@precisioninsight.com>
42 * See fxapi.h for more revision/author details.
47 /* fxwgl.c - Microsoft wgl functions emulation for
48 * 3Dfx VooDoo/Mesa interface
66 #include "GL/fxmesa.h"
69 #define MAX_MESA_ATTRS 20
77 struct __pixelformat__
79 PIXELFORMATDESCRIPTOR pfd
;
80 GLint mesaAttr
[MAX_MESA_ATTRS
];
83 WINGDIAPI
void GLAPIENTRY
gl3DfxSetPaletteEXT(GLuint
*);
85 static struct __extensions__ ext
[] = {
87 #ifdef GL_EXT_polygon_offset
88 { (PROC
)glPolygonOffsetEXT
, "glPolygonOffsetEXT" },
90 { (PROC
)glBlendEquationEXT
, "glBlendEquationEXT" },
91 { (PROC
)glBlendColorEXT
, "glBlendColorExt" },
92 { (PROC
)glVertexPointerEXT
, "glVertexPointerEXT" },
93 { (PROC
)glNormalPointerEXT
, "glNormalPointerEXT" },
94 { (PROC
)glColorPointerEXT
, "glColorPointerEXT" },
95 { (PROC
)glIndexPointerEXT
, "glIndexPointerEXT" },
96 { (PROC
)glTexCoordPointerEXT
, "glTexCoordPointer" },
97 { (PROC
)glEdgeFlagPointerEXT
, "glEdgeFlagPointerEXT" },
98 { (PROC
)glGetPointervEXT
, "glGetPointervEXT" },
99 { (PROC
)glArrayElementEXT
, "glArrayElementEXT" },
100 { (PROC
)glDrawArraysEXT
, "glDrawArrayEXT" },
101 { (PROC
)glAreTexturesResidentEXT
, "glAreTexturesResidentEXT" },
102 { (PROC
)glBindTextureEXT
, "glBindTextureEXT" },
103 { (PROC
)glDeleteTexturesEXT
, "glDeleteTexturesEXT" },
104 { (PROC
)glGenTexturesEXT
, "glGenTexturesEXT" },
105 { (PROC
)glIsTextureEXT
, "glIsTextureEXT" },
106 { (PROC
)glPrioritizeTexturesEXT
, "glPrioritizeTexturesEXT" },
107 { (PROC
)glCopyTexSubImage3DEXT
, "glCopyTexSubImage3DEXT" },
108 { (PROC
)glTexImage3DEXT
, "glTexImage3DEXT" },
109 { (PROC
)glTexSubImage3DEXT
, "glTexSubImage3DEXT" },
110 { (PROC
)gl3DfxSetPaletteEXT
, "3DFX_set_global_palette" },
111 { (PROC
)glColorTableEXT
, "glColorTableEXT" },
112 { (PROC
)glColorSubTableEXT
, "glColorSubTableEXT" },
113 { (PROC
)glGetColorTableEXT
, "glGetColorTableEXT" },
114 { (PROC
)glGetColorTableParameterfvEXT
, "glGetColorTableParameterfvEXT" },
115 { (PROC
)glGetColorTableParameterivEXT
, "glGetColorTableParameterivEXT" },
116 { (PROC
)glPointParameterfEXT
, "glPointParameterfEXT" },
117 { (PROC
)glPointParameterfvEXT
, "glPointParameterfvEXT" },
118 { (PROC
)glBlendFuncSeparateINGR
, "glBlendFuncSeparateINGR" },
119 { (PROC
)glActiveTextureARB
, "glActiveTextureARB" },
120 { (PROC
)glClientActiveTextureARB
, "glClientActiveTextureARB" },
121 { (PROC
)glMultiTexCoord1dARB
, "glMultiTexCoord1dARB" },
122 { (PROC
)glMultiTexCoord1dvARB
, "glMultiTexCoord1dvARB" },
123 { (PROC
)glMultiTexCoord1fARB
, "glMultiTexCoord1fARB" },
124 { (PROC
)glMultiTexCoord1fvARB
, "glMultiTexCoord1fvARB" },
125 { (PROC
)glMultiTexCoord1iARB
, "glMultiTexCoord1iARB" },
126 { (PROC
)glMultiTexCoord1ivARB
, "glMultiTexCoord1ivARB" },
127 { (PROC
)glMultiTexCoord1sARB
, "glMultiTexCoord1sARB" },
128 { (PROC
)glMultiTexCoord1svARB
, "glMultiTexCoord1svARB" },
129 { (PROC
)glMultiTexCoord2dARB
, "glMultiTexCoord2dARB" },
130 { (PROC
)glMultiTexCoord2dvARB
, "glMultiTexCoord2dvARB" },
131 { (PROC
)glMultiTexCoord2fARB
, "glMultiTexCoord2fARB" },
132 { (PROC
)glMultiTexCoord2fvARB
, "glMultiTexCoord2fvARB" },
133 { (PROC
)glMultiTexCoord2iARB
, "glMultiTexCoord2iARB" },
134 { (PROC
)glMultiTexCoord2ivARB
, "glMultiTexCoord2ivARB" },
135 { (PROC
)glMultiTexCoord2sARB
, "glMultiTexCoord2sARB" },
136 { (PROC
)glMultiTexCoord2svARB
, "glMultiTexCoord2svARB" },
137 { (PROC
)glMultiTexCoord3dARB
, "glMultiTexCoord3dARB" },
138 { (PROC
)glMultiTexCoord3dvARB
, "glMultiTexCoord3dvARB" },
139 { (PROC
)glMultiTexCoord3fARB
, "glMultiTexCoord3fARB" },
140 { (PROC
)glMultiTexCoord3fvARB
, "glMultiTexCoord3fvARB" },
141 { (PROC
)glMultiTexCoord3iARB
, "glMultiTexCoord3iARB" },
142 { (PROC
)glMultiTexCoord3ivARB
, "glMultiTexCoord3ivARB" },
143 { (PROC
)glMultiTexCoord3sARB
, "glMultiTexCoord3sARB" },
144 { (PROC
)glMultiTexCoord3svARB
, "glMultiTexCoord3svARB" },
145 { (PROC
)glMultiTexCoord4dARB
, "glMultiTexCoord4dARB" },
146 { (PROC
)glMultiTexCoord4dvARB
, "glMultiTexCoord4dvARB" },
147 { (PROC
)glMultiTexCoord4fARB
, "glMultiTexCoord4fARB" },
148 { (PROC
)glMultiTexCoord4fvARB
, "glMultiTexCoord4fvARB" },
149 { (PROC
)glMultiTexCoord4iARB
, "glMultiTexCoord4iARB" },
150 { (PROC
)glMultiTexCoord4ivARB
, "glMultiTexCoord4ivARB" },
151 { (PROC
)glMultiTexCoord4sARB
, "glMultiTexCoord4sARB" },
152 { (PROC
)glMultiTexCoord4svARB
, "glMultiTexCoord4svARB" },
153 { (PROC
)glLockArraysEXT
, "glLockArraysEXT" },
154 { (PROC
)glUnlockArraysEXT
, "glUnlockArraysEXT" }
157 static int qt_ext
= sizeof(ext
) / sizeof(ext
[0]);
159 struct __pixelformat__ pix
[] =
164 sizeof(PIXELFORMATDESCRIPTOR
), 1,
165 PFD_DRAW_TO_WINDOW
|PFD_SUPPORT_OPENGL
|
166 PFD_DOUBLEBUFFER
|PFD_SWAP_COPY
,
179 FXMESA_ALPHA_SIZE
, 0,
180 FXMESA_DEPTH_SIZE
, 0,
181 FXMESA_STENCIL_SIZE
, 0,
182 FXMESA_ACCUM_SIZE
, 0,
190 sizeof(PIXELFORMATDESCRIPTOR
), 1,
191 PFD_DRAW_TO_WINDOW
|PFD_SUPPORT_OPENGL
|
192 PFD_DOUBLEBUFFER
|PFD_SWAP_COPY
,
205 FXMESA_ALPHA_SIZE
, 8,
206 FXMESA_DEPTH_SIZE
, 0,
207 FXMESA_STENCIL_SIZE
, 0,
208 FXMESA_ACCUM_SIZE
, 0,
216 sizeof(PIXELFORMATDESCRIPTOR
), 1,
217 PFD_DRAW_TO_WINDOW
|PFD_SUPPORT_OPENGL
|
218 PFD_DOUBLEBUFFER
|PFD_SWAP_COPY
,
231 FXMESA_ALPHA_SIZE
, 0,
232 FXMESA_DEPTH_SIZE
, 16,
233 FXMESA_STENCIL_SIZE
, 0,
234 FXMESA_ACCUM_SIZE
, 0,
239 static int qt_pix
= sizeof(pix
) / sizeof(pix
[0]);
241 static fxMesaContext ctx
= NULL
;
242 static WNDPROC hWNDOldProc
;
243 static int curPFD
= 0;
247 static GLboolean haveDualHead
;
249 /* For the in-window-rendering hack */
251 static GLboolean gdiWindowHack
;
252 static GLboolean gdiWindowHackEna
;
253 static void *dibSurfacePtr
;
254 static BITMAPINFO
*dibBMI
;
255 static HBITMAP dibHBM
;
258 LONG GLAPIENTRY
__wglMonitor(HWND hwnd
,UINT message
,UINT wParam
,LONG lParam
)
261 long ret
; /* Now gives the resized window at the end to hWNDOldProc */
263 if(ctx
&& hwnd
== hWND
) {
268 case WM_DISPLAYCHANGE
:
270 if (wParam
!= SIZE_MINIMIZED
) {
271 static int moving
= 0;
273 if(fxQueryHardware()!=GR_SSTTYPE_VOODOO
) {
274 if(!FX_grSstControl(GR_CONTROL_RESIZE
)) {
276 SetWindowPos(hwnd
, 0, 0, 0, 300, 300, SWP_NOMOVE
|SWP_NOZORDER
);
278 if(!FX_grSstControl(GR_CONTROL_RESIZE
)) {
279 /*MessageBox(0,_T("Error changing windowsize"),_T("fxMESA"),MB_OK);*/
280 PostMessage(hWND
,WM_CLOSE
,0,0);
285 /* Do the clipping in the glide library */
286 FX_grClipWindow(0,0,FX_grSstScreenWidth(),FX_grSstScreenHeight());
287 /* And let the new size set in the context */
288 fxMesaUpdateScreenSize(ctx
);
293 if((fxQueryHardware()==GR_SSTTYPE_VOODOO
) &&
296 WORD fActive
= LOWORD(wParam
);
297 BOOL fMinimized
= (BOOL
) HIWORD(wParam
);
299 if((fActive
== WA_INACTIVE
) || fMinimized
)
300 FX_grSstControl(GR_CONTROL_DEACTIVATE
);
302 FX_grSstControl(GR_CONTROL_ACTIVATE
);
308 if(gdiWindowHackEna
&& (VK_RETURN
== wParam
)) {
310 gdiWindowHack
= GL_FALSE
;
311 FX_grSstControl(GR_CONTROL_ACTIVATE
);
313 gdiWindowHack
= GL_TRUE
;
314 FX_grSstControl(GR_CONTROL_DEACTIVATE
);
321 /* Finaly call the hWNDOldProc, which handles the resize witch the
322 now changed window sizes */
323 ret
= CallWindowProc( hWNDOldProc
, hwnd
, message
, wParam
, lParam
);
328 BOOL GLAPIENTRY
wglCopyContext(HGLRC hglrcSrc
,HGLRC hglrcDst
,UINT mask
)
333 HGLRC GLAPIENTRY
wglCreateContext(HDC hdc
)
344 if(!(hWnd
= WindowFromDC(hdc
))) {
354 if((oldProc
= (WNDPROC
)GetWindowLong(hWnd
,GWL_WNDPROC
)) != __wglMonitor
) {
355 hWNDOldProc
= oldProc
;
356 SetWindowLong(hWnd
,GWL_WNDPROC
,(LONG
)__wglMonitor
);
360 freopen("MESA.LOG","w",stderr
);
363 ShowWindow(hWnd
, SW_SHOWNORMAL
);
364 SetForegroundWindow(hWnd
);
365 Sleep(100); /* an hack for win95 */
367 if(fxQueryHardware() == GR_SSTTYPE_VOODOO
) {
370 GetClientRect(hWnd
,&cliRect
);
371 error
= !(ctx
= fxMesaCreateBestContext((GLuint
)hWnd
,cliRect
.right
,cliRect
.bottom
,
372 pix
[curPFD
- 1].mesaAttr
));
375 /* create the DIB section for windowed rendering */
382 dibBMI
= (BITMAPINFO
*) MALLOC( sizeof(BITMAPINFO
) + (256*sizeof(RGBQUAD
)));
384 memset(dibBMI
,0,sizeof(BITMAPINFO
) + (256*sizeof(RGBQUAD
)));
386 dibBMI
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
387 dibBMI
->bmiHeader
.biWidth
= ctx
->width
;
388 dibBMI
->bmiHeader
.biHeight
= -ctx
->height
;
389 dibBMI
->bmiHeader
.biPlanes
= (short)1;
390 dibBMI
->bmiHeader
.biBitCount
= (short)16;
391 dibBMI
->bmiHeader
.biCompression
= BI_BITFIELDS
;
392 dibBMI
->bmiHeader
.biSizeImage
= 0;
393 dibBMI
->bmiHeader
.biXPelsPerMeter
= 0;
394 dibBMI
->bmiHeader
.biYPelsPerMeter
= 0;
395 dibBMI
->bmiHeader
.biClrUsed
= 3;
396 dibBMI
->bmiHeader
.biClrImportant
= 3;
398 p
= (DWORD
*)dibBMI
->bmiColors
;
403 dibHBM
= CreateDIBSection(hDC
, dibBMI
, DIB_RGB_COLORS
, &dibSurfacePtr
, NULL
, 0);
405 ReleaseDC(dibWnd
, hDC
);
407 gdiWindowHackEna
= (dibHBM
!= NULL
? GL_TRUE
: GL_FALSE
);
409 if (!getenv("MESA_WGL_FX") || !strcmp(getenv("MESA_WGL_FX"),"fullscreen"))
410 gdiWindowHack
= GL_FALSE
;
412 gdiWindowHack
= GL_TRUE
;
413 FX_grSstControl(GR_CONTROL_DEACTIVATE
);
417 /* For the Voodoo Rush */
419 if(getenv("MESA_WGL_FX") && !strcmp(getenv("MESA_WGL_FX"),"fullscreen")) {
422 GetClientRect(hWnd
,&cliRect
);
423 error
= !(ctx
= fxMesaCreateBestContext((GLuint
)hWnd
,cliRect
.right
,cliRect
.bottom
,
424 pix
[curPFD
- 1].mesaAttr
));
426 error
= !(ctx
= fxMesaCreateContext((GLuint
)hWnd
,GR_RESOLUTION_NONE
,GR_REFRESH_75Hz
,
427 pix
[curPFD
- 1].mesaAttr
));
430 if(getenv("SST_DUALHEAD"))
431 haveDualHead
=((atoi(getenv("SST_DUALHEAD"))==1) ? GL_TRUE
:GL_FALSE
);
433 haveDualHead
=GL_FALSE
;
443 /* Required by the OpenGL Optimizer 1.1 (is it a Optimizer bug ?) */
444 wglMakeCurrent(hdc
,(HGLRC
)1);
449 HGLRC GLAPIENTRY
wglCreateLayerContext(HDC hdc
,int iLayerPlane
)
455 BOOL GLAPIENTRY
wglDeleteContext(HGLRC hglrc
)
457 if(ctx
&& hglrc
== (HGLRC
)1) {
458 if (gdiWindowHackEna
) {
459 DeleteObject(dibHBM
);
462 dibSurfacePtr
= NULL
;
468 fxMesaDestroyContext(ctx
);
470 SetWindowLong(WindowFromDC(hDC
),GWL_WNDPROC
,(LONG
)hWNDOldProc
);
482 HGLRC GLAPIENTRY
wglGetCurrentContext(VOID
)
491 HDC GLAPIENTRY
wglGetCurrentDC(VOID
)
500 PROC GLAPIENTRY
wglGetProcAddress(LPCSTR lpszProc
)
504 /*fprintf(stderr,"fxMesa: looking for extension %s\n",lpszProc);
507 for(i
= 0;i
< qt_ext
;i
++)
508 if(!strcmp(lpszProc
,ext
[i
].name
)) {
509 /*fprintf(stderr,"fxMesa: found extension %s\n",lpszProc);
518 BOOL GLAPIENTRY
wglMakeCurrent(HDC hdc
,HGLRC hglrc
)
520 if((hdc
==NULL
) && (hglrc
==NULL
))
523 if(!ctx
|| hglrc
!= (HGLRC
)1 || WindowFromDC(hdc
) != hWND
) {
530 fxMesaMakeCurrent(ctx
);
535 BOOL GLAPIENTRY
wglShareLists(HGLRC hglrc1
,HGLRC hglrc2
)
537 if(!ctx
|| hglrc1
!= (HGLRC
)1 || hglrc1
!= hglrc2
) {
545 BOOL GLAPIENTRY
wglUseFontBitmaps(HDC fontDevice
, DWORD firstChar
, DWORD numChars
, DWORD listBase
)
555 VERIFY(GetTextMetrics(fontDevice
, &metric
));
557 dibInfo
= (BITMAPINFO
*) calloc(sizeof(BITMAPINFO
) + sizeof(RGBQUAD
), 1);
558 dibInfo
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
559 dibInfo
->bmiHeader
.biPlanes
= 1;
560 dibInfo
->bmiHeader
.biBitCount
= 1;
561 dibInfo
->bmiHeader
.biCompression
= BI_RGB
;
563 bitDevice
= CreateCompatibleDC(fontDevice
);
564 // HDC bitDevice = CreateDC("DISPLAY", NULL, NULL, NULL);
565 // VERIFY(bitDevice);
567 // Swap fore and back colors so the bitmap has the right polarity
568 tempColor
= GetBkColor(bitDevice
);
569 SetBkColor(bitDevice
, GetTextColor(bitDevice
));
570 SetTextColor(bitDevice
, tempColor
);
572 // Place chars based on base line
573 VERIFY(SetTextAlign(bitDevice
, TA_BASELINE
) >= 0 ? 1 : 0);
575 for(i
= 0; i
< numChars
; i
++) {
578 int charWidth
,charHeight
,bmapWidth
,bmapHeight
,numBytes
,res
;
583 curChar
= i
+ firstChar
;
585 // Find how high/wide this character is
586 VERIFY(GetTextExtentPoint32(bitDevice
, &curChar
, 1, &size
));
588 // Create the output bitmap
590 charHeight
= size
.cy
;
591 bmapWidth
= ((charWidth
+ 31) / 32) * 32; // Round up to the next multiple of 32 bits
592 bmapHeight
= charHeight
;
593 bitObject
= CreateCompatibleBitmap(bitDevice
,
598 // Assign the output bitmap to the device
599 origBmap
= SelectObject(bitDevice
, bitObject
);
602 VERIFY( PatBlt( bitDevice
, 0, 0, bmapWidth
, bmapHeight
,BLACKNESS
) );
604 // Use our source font on the device
605 VERIFY(SelectObject(bitDevice
, GetCurrentObject(fontDevice
,OBJ_FONT
)));
607 // Draw the character
608 VERIFY(TextOut(bitDevice
, 0, metric
.tmAscent
, &curChar
, 1));
610 // Unselect our bmap object
611 VERIFY(SelectObject(bitDevice
, origBmap
));
613 // Convert the display dependant representation to a 1 bit deep DIB
614 numBytes
= (bmapWidth
* bmapHeight
) / 8;
615 bmap
= MALLOC(numBytes
);
616 dibInfo
->bmiHeader
.biWidth
= bmapWidth
;
617 dibInfo
->bmiHeader
.biHeight
= bmapHeight
;
618 res
= GetDIBits(bitDevice
, bitObject
, 0, bmapHeight
, bmap
,
623 // Create the GL object
624 glNewList(i
+ listBase
, GL_COMPILE
);
625 glBitmap(bmapWidth
, bmapHeight
, 0.0, metric
.tmDescent
,
631 // Destroy the bmap object
632 DeleteObject(bitObject
);
634 // Deallocate the bitmap data
639 VERIFY(DeleteDC(bitDevice
));
647 BOOL GLAPIENTRY
wglUseFontBitmapsW(HDC hdc
,DWORD first
,DWORD count
,DWORD listBase
)
652 BOOL GLAPIENTRY
wglUseFontOutlinesA(HDC hdc
,DWORD first
,DWORD count
,
653 DWORD listBase
,FLOAT deviation
,
654 FLOAT extrusion
,int format
,
655 LPGLYPHMETRICSFLOAT lpgmf
)
661 BOOL GLAPIENTRY
wglUseFontOutlinesW(HDC hdc
,DWORD first
,DWORD count
,
662 DWORD listBase
,FLOAT deviation
,
663 FLOAT extrusion
,int format
,
664 LPGLYPHMETRICSFLOAT lpgmf
)
671 BOOL GLAPIENTRY
wglSwapLayerBuffers(HDC hdc
,UINT fuPlanes
)
673 if(ctx
&& WindowFromDC(hdc
) == hWND
) {
683 int GLAPIENTRY
wglChoosePixelFormat(HDC hdc
,
684 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
686 int i
,best
=-1,qt_valid_pix
;
688 qt_valid_pix
= qt_pix
;
690 if(ppfd
->nSize
!= sizeof(PIXELFORMATDESCRIPTOR
) || ppfd
->nVersion
!= 1) {
695 for(i
= 0;i
< qt_valid_pix
;i
++) {
696 if((ppfd
->dwFlags
& PFD_DRAW_TO_WINDOW
) && !(pix
[i
].pfd
.dwFlags
& PFD_DRAW_TO_WINDOW
))
698 if((ppfd
->dwFlags
& PFD_DRAW_TO_BITMAP
) && !(pix
[i
].pfd
.dwFlags
& PFD_DRAW_TO_BITMAP
))
700 if((ppfd
->dwFlags
& PFD_SUPPORT_GDI
) && !(pix
[i
].pfd
.dwFlags
& PFD_SUPPORT_GDI
))
702 if((ppfd
->dwFlags
& PFD_SUPPORT_OPENGL
) && !(pix
[i
].pfd
.dwFlags
& PFD_SUPPORT_OPENGL
))
704 if(!(ppfd
->dwFlags
& PFD_DOUBLEBUFFER_DONTCARE
) &&
705 ((ppfd
->dwFlags
& PFD_DOUBLEBUFFER
) != (pix
[i
].pfd
.dwFlags
& PFD_DOUBLEBUFFER
)))
707 if(!(ppfd
->dwFlags
& PFD_STEREO_DONTCARE
) &&
708 ((ppfd
->dwFlags
& PFD_STEREO
) != (pix
[i
].pfd
.dwFlags
& PFD_STEREO
)))
711 if (ppfd
->cDepthBits
> 0 && pix
[i
].pfd
.cDepthBits
== 0)
712 continue; /* need depth buffer */
714 if (ppfd
->cAlphaBits
> 0 && pix
[i
].pfd
.cAlphaBits
== 0)
715 continue; /* need alpha buffer */
717 if(ppfd
->iPixelType
== pix
[i
].pfd
.iPixelType
) {
731 int GLAPIENTRY
ChoosePixelFormat(HDC hdc
,
732 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
734 return wglChoosePixelFormat(hdc
,ppfd
);
737 int GLAPIENTRY
wglDescribePixelFormat(HDC hdc
,int iPixelFormat
,UINT nBytes
,
738 LPPIXELFORMATDESCRIPTOR ppfd
)
742 qt_valid_pix
= qt_pix
;
744 if(iPixelFormat
< 1 || iPixelFormat
> qt_valid_pix
||
745 ((nBytes
!= sizeof(PIXELFORMATDESCRIPTOR
)) && (nBytes
!= 0))) {
751 *ppfd
= pix
[iPixelFormat
- 1].pfd
;
753 return(qt_valid_pix
);
756 int GLAPIENTRY
DescribePixelFormat(HDC hdc
,int iPixelFormat
,UINT nBytes
,
757 LPPIXELFORMATDESCRIPTOR ppfd
)
759 return wglDescribePixelFormat(hdc
,iPixelFormat
,nBytes
,ppfd
);
762 int GLAPIENTRY
wglGetPixelFormat(HDC hdc
)
772 int GLAPIENTRY
GetPixelFormat(HDC hdc
)
774 return wglGetPixelFormat(hdc
);
777 BOOL GLAPIENTRY
wglSetPixelFormat(HDC hdc
,int iPixelFormat
,
778 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
782 qt_valid_pix
= qt_pix
;
784 if(iPixelFormat
< 1 || iPixelFormat
> qt_valid_pix
|| ppfd
->nSize
!= sizeof(PIXELFORMATDESCRIPTOR
)) {
788 curPFD
= iPixelFormat
;
793 BOOL GLAPIENTRY
wglSwapBuffers(HDC hdc
)
803 GLuint width
=ctx
->width
;
804 GLuint height
=ctx
->height
;
806 HDC hdcScreen
= GetDC(dibWnd
);
807 HDC hdcDIBSection
= CreateCompatibleDC(hdcScreen
);
808 HBITMAP holdBitmap
= (HBITMAP
) SelectObject(hdcDIBSection
, dibHBM
);
810 FX_grLfbReadRegion(GR_BUFFER_FRONTBUFFER
, 0, 0,
815 /* Since the hardware is configured for GR_COLORFORMAT_ABGR the pixel data is
816 * going to come out as BGR 565, which is reverse of what we need for blitting
817 * to screen, so we need to convert it here pixel-by-pixel (ick). This loop would NOT
818 * be required if the color format was changed to GR_COLORFORMAT_ARGB, but I do
819 * not know the ramifications of that, so this will work until that is resolved.
821 * This routine CRIES out for MMX implementation, however since that's not
822 * guaranteed to be running on MMX enabled hardware so I'm not going to do
823 * that. I'm just going to try to make a reasonably efficient C
826 * This routine drops frame rate by <1 fps on a 200Mhz MMX processor with a 640x480
827 * display. Obviously, it's performance hit will be higher on larger displays and
828 * less on smaller displays. To support the window-hack display this is probably fine.
832 unsigned long *pixel
= dibSurfacePtr
;
833 unsigned long count
= (width
* height
) / 2;
837 *pixel
++ = (*pixel
& 0x07e007e0) /* greens */
838 | ((*pixel
& 0xf800f800) >> 11) /* swap blues */
839 | ((*pixel
& 0x001f001f) << 11) /* swap reds */
845 BitBlt(hdcScreen
, 0, 0,
850 ReleaseDC(dibWnd
, hdcScreen
);
851 SelectObject(hdcDIBSection
, holdBitmap
);
852 DeleteDC(hdcDIBSection
);
858 BOOL GLAPIENTRY
SetPixelFormat(HDC hdc
, int iPixelFormat
,
859 CONST PIXELFORMATDESCRIPTOR
*ppfd
)
861 return wglSetPixelFormat(hdc
,iPixelFormat
,ppfd
);
864 BOOL GLAPIENTRY
SwapBuffers(HDC hdc
)
866 return wglSwapBuffers(hdc
);