Merge branch 'mesa_7_6_branch' of git+ssh://agd5f@git.freedesktop.org/git/mesa/mesa
[mesa.git] / src / mesa / drivers / windows / gldirect / dglpf.c
1 /****************************************************************************
2 *
3 * Mesa 3-D graphics library
4 * Direct3D Driver Interface
5 *
6 * ========================================================================
7 *
8 * Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 *
28 * ========================================================================
29 *
30 * Language: ANSI C
31 * Environment: Windows 9x (Win32)
32 *
33 * Description: Pixel Formats.
34 *
35 ****************************************************************************/
36
37 #include "dglpf.h"
38
39 #ifdef _USE_GLD3_WGL
40 #include "gld_driver.h"
41 #endif
42
43 // ***********************************************************************
44
45 char szColorDepthWarning[] =
46 "GLDirect does not support the current desktop\n\
47 color depth.\n\n\
48 You may need to change the display resolution to\n\
49 16 bits per pixel or higher color depth using\n\
50 the Windows Display Settings control panel\n\
51 before running this OpenGL application.\n";
52
53 // ***********************************************************************
54 // This pixel format will be used as a template when compiling the list
55 // of pixel formats supported by the hardware. Many fields will be
56 // filled in at runtime.
57 // PFD flag defaults are upgraded to match ChoosePixelFormat() -- DaveM
58 DGL_pixelFormat pfTemplateHW =
59 {
60 {
61 sizeof(PIXELFORMATDESCRIPTOR), // Size of the data structure
62 1, // Structure version - should be 1
63 // Flags:
64 PFD_DRAW_TO_WINDOW | // The buffer can draw to a window or device surface.
65 PFD_DRAW_TO_BITMAP | // The buffer can draw to a bitmap. (DaveM)
66 PFD_SUPPORT_GDI | // The buffer supports GDI drawing. (DaveM)
67 PFD_SUPPORT_OPENGL | // The buffer supports OpenGL drawing.
68 PFD_DOUBLEBUFFER | // The buffer is double-buffered.
69 0, // Placeholder for easy commenting of above flags
70 PFD_TYPE_RGBA, // Pixel type RGBA.
71 16, // Total colour bitplanes (excluding alpha bitplanes)
72 5, 0, // Red bits, shift
73 5, 5, // Green bits, shift
74 5, 10, // Blue bits, shift
75 0, 0, // Alpha bits, shift (destination alpha)
76 0, // Accumulator bits (total)
77 0, 0, 0, 0, // Accumulator bits: Red, Green, Blue, Alpha
78 0, // Depth bits
79 0, // Stencil bits
80 0, // Number of auxiliary buffers
81 0, // Layer type
82 0, // Specifies the number of overlay and underlay planes.
83 0, // Layer mask
84 0, // Specifies the transparent color or index of an underlay plane.
85 0 // Damage mask
86 },
87 -1, // No depth/stencil buffer
88 };
89
90 // ***********************************************************************
91 // Return the count of the number of bits in a Bit Mask.
92 int BitCount(
93 DWORD dw)
94 {
95 int i;
96
97 if (dw == 0)
98 return 0; // account for non-RGB mode
99
100 for (i=0; dw; dw=dw>>1)
101 i += (dw & 1);
102 return i;
103 }
104
105 // ***********************************************************************
106
107 DWORD BitShift(
108 DWORD dwMaskIn)
109 {
110 DWORD dwShift, dwMask;
111
112 if (dwMaskIn == 0)
113 return 0; // account for non-RGB mode
114
115 for (dwShift=0, dwMask=dwMaskIn; !(dwMask&1); dwShift++, dwMask>>=1);
116
117 return dwShift;
118 }
119
120 // ***********************************************************************
121
122 BOOL IsValidPFD(int iPFD)
123 {
124 DGL_pixelFormat *lpPF;
125
126 // Validate license
127 if (!dglValidate())
128 return FALSE;
129
130 if ((glb.lpPF == NULL) ||
131 (glb.nPixelFormatCount == 0))
132 return FALSE;
133
134 // Check PFD range
135 if ( (iPFD < 1) || (iPFD > glb.nPixelFormatCount) ) {
136 ddlogMessage(DDLOG_ERROR, "PFD out of range\n");
137 return FALSE; // PFD is invalid
138 }
139
140 // Make a pointer to the pixel format
141 lpPF = &glb.lpPF[iPFD-1];
142
143 // Check size
144 if (lpPF->pfd.nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
145 ddlogMessage(DDLOG_ERROR, "Bad PFD size\n");
146 return FALSE; // PFD is invalid
147 }
148
149 // Check version
150 if (lpPF->pfd.nVersion != 1) {
151 ddlogMessage(DDLOG_ERROR, "PFD is not Version 1\n");
152 return FALSE; // PFD is invalid
153 }
154
155 return TRUE; // PFD is valid
156 }
157
158 // ***********************************************************************
159
160 #ifndef _USE_GLD3_WGL
161
162 int iEnumCount; // Enumeration count
163 DWORD dwDisplayBitDepth; // Bit depth of current display mode
164
165 // ***********************************************************************
166
167 HRESULT WINAPI EnumDisplayModesCallback(
168 DDSURFACEDESC2* pddsd,
169 void *pvContext)
170 {
171 DWORD dwModeDepth;
172 DDSURFACEDESC2 *lpDisplayMode;
173 char buf[32];
174
175 // Check parameters
176 if (pddsd == NULL)
177 return DDENUMRET_CANCEL;
178
179 dwModeDepth = pddsd->ddpfPixelFormat.dwRGBBitCount;
180 lpDisplayMode = (DDSURFACEDESC2 *)pvContext;
181
182 // Check mode for compatability with device.
183 if (dwModeDepth != dwDisplayBitDepth)
184 return DDENUMRET_OK;
185
186 if (lpDisplayMode != NULL) {
187 memcpy(&lpDisplayMode[iEnumCount], pddsd, sizeof(DDSURFACEDESC2));
188 sprintf(buf, TEXT("Mode: %ld x %ld x %ld\n"),
189 pddsd->dwWidth, pddsd->dwHeight, dwModeDepth);
190 ddlogMessage(DDLOG_INFO, buf);
191 }
192
193 iEnumCount++;
194
195 return DDENUMRET_OK;
196 }
197
198 // ***********************************************************************
199
200 HRESULT CALLBACK d3dEnumZBufferFormatsCallback(
201 DDPIXELFORMAT* pddpf,
202 VOID* lpZBufferPF )
203 {
204 char buf[64];
205
206 if(pddpf == NULL)
207 return D3DENUMRET_CANCEL;
208
209 if (pddpf->dwFlags & DDPF_ZBUFFER) {
210 if (lpZBufferPF == NULL) {
211 // Pass 1. Merely counting the PF
212 glb.nZBufferPFCount++;
213 } else {
214 // Pass 2. Save the PF
215 if (pddpf->dwFlags & DDPF_STENCILBUFFER) {
216 sprintf(buf, " %d: Z=%d S=%d\n",
217 iEnumCount,
218 pddpf->dwZBufferBitDepth,
219 pddpf->dwStencilBitDepth);
220 } else {
221 sprintf(buf, " %d: Z=%d S=0\n",
222 iEnumCount,
223 pddpf->dwZBufferBitDepth);
224 }
225 ddlogMessage(DDLOG_INFO, buf);
226
227 memcpy(&glb.lpZBufferPF[iEnumCount++],
228 pddpf,
229 sizeof(DDPIXELFORMAT));
230 }
231 }
232
233 return D3DENUMRET_OK;
234 }
235 #endif // _USE_GLD3_WGL
236
237 // ***********************************************************************
238
239 BOOL IsStencilSupportBroken(LPDIRECTDRAW4 lpDD4)
240 {
241 DDDEVICEIDENTIFIER dddi; // DX6 device identifier
242 BOOL bBroken = FALSE;
243
244 // Microsoft really fucked up with the GetDeviceIdentifier function
245 // on Windows 2000, since it locks up on stock driers on the CD. Updated
246 // drivers from vendors appear to work, but we can't identify the drivers
247 // without this function!!! For now we skip these tests on Windows 2000.
248 if ((GetVersion() & 0x80000000UL) == 0)
249 return FALSE;
250
251 // Obtain device info
252 if (FAILED(IDirectDraw4_GetDeviceIdentifier(lpDD4, &dddi, 0)))
253 return FALSE;
254
255 // Matrox G400 stencil buffer support does not draw anything in AutoCAD,
256 // but ordinary Z buffers draw shaded models fine. (DaveM)
257 if (dddi.dwVendorId == 0x102B) { // Matrox
258 if (dddi.dwDeviceId == 0x0525) { // G400
259 bBroken = TRUE;
260 }
261 }
262
263 return bBroken;
264 }
265
266 // ***********************************************************************
267
268 void dglBuildPixelFormatList()
269 {
270 int i;
271 char buf[128];
272 char cat[8];
273 DGL_pixelFormat *lpPF;
274
275 #ifdef _USE_GLD3_WGL
276 _gldDriver.BuildPixelformatList();
277 #else
278 HRESULT hRes;
279 IDirectDraw *lpDD1 = NULL;
280 IDirectDraw4 *lpDD4 = NULL;
281 IDirect3D3 *lpD3D3 = NULL;
282 DDSURFACEDESC2 ddsdDisplayMode;
283
284 DWORD dwRb, dwGb, dwBb, dwAb; // Bit counts
285 DWORD dwRs, dwGs, dwBs, dwAs; // Bit shifts
286 DWORD dwPixelType; // RGB or color index
287
288 // Set defaults
289 glb.nPixelFormatCount = 0;
290 glb.lpPF = NULL;
291 glb.nZBufferPFCount = 0;
292 glb.lpZBufferPF = NULL;
293 glb.nDisplayModeCount = 0;
294 glb.lpDisplayModes = NULL;
295
296 //
297 // Examine the hardware for depth and stencil
298 //
299
300 if (glb.bPrimary)
301 hRes = DirectDrawCreate(NULL, &lpDD1, NULL);
302 else
303 hRes = DirectDrawCreate(&glb.ddGuid, &lpDD1, NULL);
304
305 if (FAILED(hRes)) {
306 ddlogError(DDLOG_ERROR, "dglBPFL: DirectDrawCreate failed", hRes);
307 return;
308 }
309
310 // Query for DX6 IDirectDraw4.
311 hRes = IDirectDraw_QueryInterface(
312 lpDD1,
313 &IID_IDirectDraw4,
314 (void**)&lpDD4);
315 if (FAILED(hRes)) {
316 ddlogError(DDLOG_ERROR, "dglBPFL: QueryInterface (DD4) failed", hRes);
317 goto clean_up;
318 }
319
320
321 // Retrieve caps of current display mode
322 ZeroMemory(&ddsdDisplayMode, sizeof(ddsdDisplayMode));
323 ddsdDisplayMode.dwSize = sizeof(ddsdDisplayMode);
324 hRes = IDirectDraw4_GetDisplayMode(lpDD4, &ddsdDisplayMode);
325 if (FAILED(hRes))
326 goto clean_up;
327
328 dwDisplayBitDepth = ddsdDisplayMode.ddpfPixelFormat.dwRGBBitCount;
329 dwPixelType = (dwDisplayBitDepth <= 8) ? PFD_TYPE_COLORINDEX : PFD_TYPE_RGBA;
330 dwRb = BitCount(ddsdDisplayMode.ddpfPixelFormat.dwRBitMask);
331 dwGb = BitCount(ddsdDisplayMode.ddpfPixelFormat.dwGBitMask);
332 dwBb = BitCount(ddsdDisplayMode.ddpfPixelFormat.dwBBitMask);
333 dwRs = BitShift(ddsdDisplayMode.ddpfPixelFormat.dwRBitMask);
334 dwGs = BitShift(ddsdDisplayMode.ddpfPixelFormat.dwGBitMask);
335 dwBs = BitShift(ddsdDisplayMode.ddpfPixelFormat.dwBBitMask);
336
337 if (BitCount(ddsdDisplayMode.ddpfPixelFormat.dwRGBAlphaBitMask)) {
338 dwAb = BitCount(ddsdDisplayMode.ddpfPixelFormat.dwRGBAlphaBitMask);
339 dwAs = BitShift(ddsdDisplayMode.ddpfPixelFormat.dwRGBAlphaBitMask);
340 } else {
341 dwAb = 0;
342 dwAs = 0;
343 }
344
345 // Query for available display modes
346 ddlogMessage(DDLOG_INFO, "\n");
347 ddlogMessage(DDLOG_INFO, "Display Modes:\n");
348
349 // Pass 1: Determine count
350 iEnumCount = 0;
351 hRes = IDirectDraw4_EnumDisplayModes(
352 lpDD4,
353 0,
354 NULL,
355 NULL,
356 EnumDisplayModesCallback);
357 if (FAILED(hRes)) {
358 ddlogError(DDLOG_ERROR, "dglBPFL: EnumDisplayModes failed", hRes);
359 goto clean_up;
360 }
361 if (iEnumCount == 0) {
362 ddlogMessage(DDLOG_ERROR, "dglBPFL: No display modes found");
363 goto clean_up;
364 }
365 glb.lpDisplayModes = (DDSURFACEDESC2 *)calloc(iEnumCount,
366 sizeof(DDSURFACEDESC2));
367 if (glb.lpDisplayModes == NULL) {
368 ddlogMessage(DDLOG_ERROR, "dglBPFL: DDSURFACEDESC2 calloc failed");
369 goto clean_up;
370 }
371 glb.nDisplayModeCount = iEnumCount;
372 // Pass 2: Save modes
373 iEnumCount = 0;
374 hRes = IDirectDraw4_EnumDisplayModes(
375 lpDD4,
376 0,
377 NULL,
378 (void *)glb.lpDisplayModes,
379 EnumDisplayModesCallback);
380 if (FAILED(hRes)) {
381 ddlogError(DDLOG_ERROR, "dglBPFL: EnumDisplayModes failed", hRes);
382 goto clean_up;
383 }
384 // Query for IDirect3D3 interface
385 hRes = IDirectDraw4_QueryInterface(
386 lpDD4,
387 &IID_IDirect3D3,
388 (void**)&lpD3D3);
389 if (FAILED(hRes)) {
390 ddlogError(DDLOG_ERROR, "dglBPFL: QueryInterface (D3D3) failed", hRes);
391 goto clean_up;
392 }
393
394 ddlogMessage(DDLOG_INFO, "\n");
395 ddlogMessage(DDLOG_INFO, "ZBuffer formats:\n");
396
397 // Pass 1. Count the ZBuffer pixel formats
398 hRes = IDirect3D3_EnumZBufferFormats(
399 lpD3D3,
400 &glb.d3dGuid,
401 d3dEnumZBufferFormatsCallback,
402 NULL);
403
404 if (FAILED(hRes))
405 goto clean_up;
406
407 if (glb.nZBufferPFCount) {
408 glb.lpZBufferPF = (DDPIXELFORMAT *)calloc(glb.nZBufferPFCount,
409 sizeof(DDPIXELFORMAT));
410 if(glb.lpZBufferPF == NULL)
411 goto clean_up;
412
413 // Pass 2. Cache the ZBuffer pixel formats
414 iEnumCount = 0; // (Used by the enum function)
415 hRes = IDirect3D3_EnumZBufferFormats(
416 lpD3D3,
417 &glb.d3dGuid,
418 d3dEnumZBufferFormatsCallback,
419 glb.lpZBufferPF);
420
421 if (FAILED(hRes))
422 goto clean_up;
423 }
424
425 // Remove stencil support for boards which don't work for AutoCAD;
426 // Matrox G400 does not work, but NVidia TNT2 and ATI Rage128 do... (DaveM)
427 if (IsStencilSupportBroken(lpDD4)) {
428 for (i=0; i<iEnumCount; i++)
429 if (glb.lpZBufferPF[i].dwFlags & DDPF_STENCILBUFFER)
430 glb.nZBufferPFCount--;
431 }
432
433 // One each for every ZBuffer pixel format (including no depth buffer)
434 // Times-two because duplicated for single buffering (as opposed to double)
435 glb.nPixelFormatCount = 2 * (glb.nZBufferPFCount + 1);
436 glb.lpPF = (DGL_pixelFormat *)calloc(glb.nPixelFormatCount,
437 sizeof(DGL_pixelFormat));
438 if (glb.lpPF == NULL)
439 goto clean_up;
440 //
441 // Fill in the pixel formats
442 // Note: Depth buffer bits are really (dwZBufferBitDepth-dwStencilBitDepth)
443 // but this will pass wierd numbers to the OpenGL app. (?)
444 //
445
446 pfTemplateHW.pfd.iPixelType = dwPixelType;
447 pfTemplateHW.pfd.cColorBits = dwDisplayBitDepth;
448 pfTemplateHW.pfd.cRedBits = dwRb;
449 pfTemplateHW.pfd.cGreenBits = dwGb;
450 pfTemplateHW.pfd.cBlueBits = dwBb;
451 pfTemplateHW.pfd.cAlphaBits = dwAb;
452 pfTemplateHW.pfd.cRedShift = dwRs;
453 pfTemplateHW.pfd.cGreenShift = dwGs;
454 pfTemplateHW.pfd.cBlueShift = dwBs;
455 pfTemplateHW.pfd.cAlphaShift = dwAs;
456
457 lpPF = glb.lpPF;
458
459 // Fill in the double-buffered pixel formats
460 for (i=0; i<(glb.nZBufferPFCount + 1); i++, lpPF++) {
461 memcpy(lpPF, &pfTemplateHW, sizeof(DGL_pixelFormat));
462 if (i) {
463 lpPF->iZBufferPF = i-1;
464 lpPF->pfd.cDepthBits = glb.lpZBufferPF[i-1].dwZBufferBitDepth;
465 lpPF->pfd.cStencilBits = glb.lpZBufferPF[i-1].dwStencilBitDepth;
466 }
467 }
468 // Fill in the single-buffered pixel formats
469 for (i=0; i<(glb.nZBufferPFCount + 1); i++, lpPF++) {
470 memcpy(lpPF, &pfTemplateHW, sizeof(DGL_pixelFormat));
471 if (i) {
472 lpPF->iZBufferPF = i-1;
473 lpPF->pfd.cDepthBits = glb.lpZBufferPF[i-1].dwZBufferBitDepth;
474 lpPF->pfd.cStencilBits = glb.lpZBufferPF[i-1].dwStencilBitDepth;
475 }
476 // Remove double-buffer flag. Could use XOR instead...
477 lpPF->pfd.dwFlags &= (~(PFD_DOUBLEBUFFER));
478 // Insert GDI flag for single buffered format only.
479 lpPF->pfd.dwFlags |= PFD_SUPPORT_GDI;
480 }
481 #endif // _USE_GLD3_WGL
482
483 // Lets dump the list to the log
484 // ** Based on "wglinfo" by Nate Robins **
485 ddlogMessage(DDLOG_INFO, "\n");
486 ddlogMessage(DDLOG_INFO, "Pixel Formats:\n");
487 ddlogMessage(DDLOG_INFO,
488 " visual x bf lv rg d st r g b a ax dp st accum buffs ms\n");
489 ddlogMessage(DDLOG_INFO,
490 " id dep cl sp sz l ci b ro sz sz sz sz bf th cl r g b a ns b\n");
491 ddlogMessage(DDLOG_INFO,
492 "-----------------------------------------------------------------\n");
493 for (i=0, lpPF = glb.lpPF; i<glb.nPixelFormatCount; i++, lpPF++) {
494 sprintf(buf, "0x%02x ", i+1);
495
496 sprintf(cat, "%2d ", lpPF->pfd.cColorBits);
497 strcat(buf, cat);
498 if(lpPF->pfd.dwFlags & PFD_DRAW_TO_WINDOW) sprintf(cat, "wn ");
499 else if(lpPF->pfd.dwFlags & PFD_DRAW_TO_BITMAP) sprintf(cat, "bm ");
500 else sprintf(cat, ". ");
501 strcat(buf, cat);
502
503 /* should find transparent pixel from LAYERPLANEDESCRIPTOR */
504 sprintf(cat, " . ");
505 strcat(buf, cat);
506
507 sprintf(cat, "%2d ", lpPF->pfd.cColorBits);
508 strcat(buf, cat);
509
510 /* bReserved field indicates number of over/underlays */
511 if(lpPF->pfd.bReserved) sprintf(cat, " %d ", lpPF->pfd.bReserved);
512 else sprintf(cat, " . ");
513 strcat(buf, cat);
514
515 sprintf(cat, " %c ", lpPF->pfd.iPixelType == PFD_TYPE_RGBA ? 'r' : 'c');
516 strcat(buf, cat);
517
518 sprintf(cat, "%c ", lpPF->pfd.dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.');
519 strcat(buf, cat);
520
521 sprintf(cat, " %c ", lpPF->pfd.dwFlags & PFD_STEREO ? 'y' : '.');
522 strcat(buf, cat);
523
524 if(lpPF->pfd.cRedBits && lpPF->pfd.iPixelType == PFD_TYPE_RGBA)
525 sprintf(cat, "%2d ", lpPF->pfd.cRedBits);
526 else sprintf(cat, " . ");
527 strcat(buf, cat);
528
529 if(lpPF->pfd.cGreenBits && lpPF->pfd.iPixelType == PFD_TYPE_RGBA)
530 sprintf(cat, "%2d ", lpPF->pfd.cGreenBits);
531 else sprintf(cat, " . ");
532 strcat(buf, cat);
533
534 if(lpPF->pfd.cBlueBits && lpPF->pfd.iPixelType == PFD_TYPE_RGBA)
535 sprintf(cat, "%2d ", lpPF->pfd.cBlueBits);
536 else sprintf(cat, " . ");
537 strcat(buf, cat);
538
539 if(lpPF->pfd.cAlphaBits && lpPF->pfd.iPixelType == PFD_TYPE_RGBA)
540 sprintf(cat, "%2d ", lpPF->pfd.cAlphaBits);
541 else sprintf(cat, " . ");
542 strcat(buf, cat);
543
544 if(lpPF->pfd.cAuxBuffers) sprintf(cat, "%2d ", lpPF->pfd.cAuxBuffers);
545 else sprintf(cat, " . ");
546 strcat(buf, cat);
547
548 if(lpPF->pfd.cDepthBits) sprintf(cat, "%2d ", lpPF->pfd.cDepthBits);
549 else sprintf(cat, " . ");
550 strcat(buf, cat);
551
552 if(lpPF->pfd.cStencilBits) sprintf(cat, "%2d ", lpPF->pfd.cStencilBits);
553 else sprintf(cat, " . ");
554 strcat(buf, cat);
555
556 if(lpPF->pfd.cAccumRedBits) sprintf(cat, "%2d ", lpPF->pfd.cAccumRedBits);
557 else sprintf(cat, " . ");
558 strcat(buf, cat);
559
560 if(lpPF->pfd.cAccumGreenBits) sprintf(cat, "%2d ", lpPF->pfd.cAccumGreenBits);
561 else sprintf(cat, " . ");
562 strcat(buf, cat);
563
564 if(lpPF->pfd.cAccumBlueBits) sprintf(cat, "%2d ", lpPF->pfd.cAccumBlueBits);
565 else sprintf(cat, " . ");
566 strcat(buf, cat);
567
568 if(lpPF->pfd.cAccumAlphaBits) sprintf(cat, "%2d ", lpPF->pfd.cAccumAlphaBits);
569 else sprintf(cat, " . ");
570 strcat(buf, cat);
571
572 /* no multisample in Win32 */
573 sprintf(cat, " . .\n");
574 strcat(buf, cat);
575
576 ddlogMessage(DDLOG_INFO, buf);
577 }
578 ddlogMessage(DDLOG_INFO,
579 "-----------------------------------------------------------------\n");
580 ddlogMessage(DDLOG_INFO, "\n");
581
582 #ifndef _USE_GLD3_WGL
583 clean_up:
584 // Release COM objects
585 RELEASE(lpD3D3);
586 RELEASE(lpDD4);
587 RELEASE(lpDD1);
588
589 // Popup warning message if non RGB color mode
590 if (dwDisplayBitDepth <= 8) {
591 ddlogPrintf(DDLOG_WARN, "Current Color Depth %d bpp is not supported", dwDisplayBitDepth);
592 MessageBox(NULL, szColorDepthWarning, "GLDirect", MB_OK | MB_ICONWARNING);
593 }
594 #endif // _USE_GLD3_WGL
595 }
596
597 // ***********************************************************************
598
599 void dglReleasePixelFormatList()
600 {
601 glb.nPixelFormatCount = 0;
602 if (glb.lpPF) {
603 free(glb.lpPF);
604 glb.lpPF = NULL;
605 }
606 #ifndef _USE_GLD3_WGL
607 glb.nZBufferPFCount = 0;
608 if (glb.lpZBufferPF) {
609 free(glb.lpZBufferPF);
610 glb.lpZBufferPF = NULL;
611 }
612 glb.nDisplayModeCount = 0;
613 if (glb.lpDisplayModes) {
614 free(glb.lpDisplayModes);
615 glb.lpDisplayModes = NULL;
616 }
617 #endif // _USE_GLD3_WGL
618 }
619
620 // ***********************************************************************