diff options
author | Daniel Borca <[email protected]> | 2004-02-07 10:54:36 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2004-02-07 10:54:36 +0000 |
commit | d039b43e3074d14193944408ef211a9abf10608b (patch) | |
tree | e2f29f73426a37a6ce8d8dcd19e6b52ad8f9e8fb /src/mesa | |
parent | 07d6a983595b7ee52c8448fc579d952ce36472b8 (diff) |
added NUL driver for DMesa
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/Makefile.DJ | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dos/dmesa.c | 105 | ||||
-rw-r--r-- | src/mesa/drivers/dos/null.c | 222 | ||||
-rw-r--r-- | src/mesa/drivers/dos/null.h | 41 | ||||
-rw-r--r-- | src/mesa/drivers/dos/video.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxwgl.c | 134 |
6 files changed, 397 insertions, 114 deletions
diff --git a/src/mesa/Makefile.DJ b/src/mesa/Makefile.DJ index fdcc2ec5467..56cf315c726 100644 --- a/src/mesa/Makefile.DJ +++ b/src/mesa/Makefile.DJ @@ -171,6 +171,7 @@ DRIVER_SOURCES += \ drivers/dos/vesa.c \ drivers/dos/blit.S \ drivers/dos/vga.c \ + drivers/dos/null.c \ drivers/dos/dpmi.c endif diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index c8fd91864bd..e0744a88de8 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -69,11 +69,8 @@ */ struct dmesa_visual { GLvisual gl_visual; - GLboolean db_flag; /* double buffered? */ - GLboolean rgb_flag; /* RGB mode? */ GLboolean sw_alpha; /* use Mesa's alpha buffer? */ - GLuint depth; /* bits per pixel (1, 8, 24, etc) */ - int zbuffer; /* Z=buffer: 0=no, 1=SW, -1=HW */ + int z_buffer; /* Z=buffer: 0=no, 1=SW, -1=HW */ }; /* @@ -95,7 +92,7 @@ struct dmesa_buffer { struct dmesa_context { GLcontext gl_ctx; /* the core library context */ DMesaVisual visual; - DMesaBuffer Buffer; + DMesaBuffer buffer; GLuint ClearColor; GLuint ClearIndex; /* etc... */ @@ -107,10 +104,10 @@ struct dmesa_context { /**************************************************************************** * Read/Write pixels ***************************************************************************/ -#define FLIP(y) (dmesa->Buffer->height - (y) - 1) +#define FLIP(y) (dmesa->buffer->height - (y) - 1) #define FLIP2(y) (_b_ - (y)) -#define DSTRIDE dmesa->Buffer->width +#define DSTRIDE dmesa->buffer->width /**************************************************************************** * RGB[A] @@ -208,7 +205,7 @@ static void write_rgba_pixels (const GLcontext *ctx, const GLubyte rgba[][4], const GLubyte mask[]) { const DMesaContext dmesa = (DMesaContext)ctx; - GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; if (mask) { /* draw some pixels */ @@ -232,7 +229,7 @@ static void write_mono_rgba_pixels (const GLcontext *ctx, const GLchan color[4], const GLubyte mask[]) { const DMesaContext dmesa = (DMesaContext)ctx; - GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1, rgba = vl_mixrgba(color); + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1, rgba = vl_mixrgba(color); if (mask) { /* draw some pixels */ @@ -256,7 +253,7 @@ static void read_rgba_pixels (const GLcontext *ctx, GLubyte rgba[][4], const GLubyte mask[]) { const DMesaContext dmesa = (DMesaContext)ctx; - GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; if (mask) { /* read some pixels */ @@ -371,7 +368,7 @@ static void write_index_pixels (const GLcontext *ctx, const GLuint index[], const GLubyte mask[]) { const DMesaContext dmesa = (DMesaContext)ctx; - GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; if (mask) { /* draw some pixels */ @@ -395,7 +392,7 @@ static void write_mono_index_pixels (const GLcontext *ctx, GLuint colorIndex, const GLubyte mask[]) { const DMesaContext dmesa = (DMesaContext)ctx; - GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; if (mask) { /* draw some pixels */ @@ -419,7 +416,7 @@ static void read_index_pixels (const GLcontext *ctx, GLuint index[], const GLubyte mask[]) { const DMesaContext dmesa = (DMesaContext)ctx; - GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1; + GLuint i, _w_ = DSTRIDE, _b_ = dmesa->buffer->height - 1; if (mask) { /* read some pixels */ @@ -455,8 +452,8 @@ static void read_index_pixels (const GLcontext *ctx, #define SETUP_CODE \ const DMesaContext dmesa = (DMesaContext)ctx; \ - GLuint _b_ = dmesa->Buffer->height - 1; \ - GLuint _w_ = dmesa->Buffer->width; \ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ GLuint rgb = vl_mixrgb(v2->color); #define RENDER_SPAN(span) \ @@ -479,8 +476,8 @@ static void read_index_pixels (const GLcontext *ctx, #define SETUP_CODE \ const DMesaContext dmesa = (DMesaContext)ctx; \ - GLuint _b_ = dmesa->Buffer->height - 1; \ - GLuint _w_ = dmesa->Buffer->width; \ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ GLuint rgb = vl_mixrgb(v2->color); #define RENDER_SPAN(span) \ @@ -507,8 +504,8 @@ static void read_index_pixels (const GLcontext *ctx, #define SETUP_CODE \ const DMesaContext dmesa = (DMesaContext)ctx; \ - GLuint _b_ = dmesa->Buffer->height - 1; \ - GLuint _w_ = dmesa->Buffer->width; + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; #define RENDER_SPAN(span) \ GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \ @@ -534,8 +531,8 @@ static void read_index_pixels (const GLcontext *ctx, #define SETUP_CODE \ const DMesaContext dmesa = (DMesaContext)ctx; \ - GLuint _b_ = dmesa->Buffer->height - 1; \ - GLuint _w_ = dmesa->Buffer->width; + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; #define RENDER_SPAN(span) \ GLuint i, offset = FLIP2(span.y)*_w_ + span.x; \ @@ -616,8 +613,8 @@ static void dmesa_choose_tri (GLcontext *ctx) #define SETUP_CODE \ const DMesaContext dmesa = (DMesaContext)ctx; \ - GLuint _b_ = dmesa->Buffer->height - 1; \ - GLuint _w_ = dmesa->Buffer->width; \ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ GLuint rgb = vl_mixrgb(vert1->color); #define PLOT(X,Y) vl_putpixel(FLIP2(Y) * _w_ + X, rgb); @@ -638,8 +635,8 @@ static void dmesa_choose_tri (GLcontext *ctx) #define SETUP_CODE \ const DMesaContext dmesa = (DMesaContext)ctx; \ - GLuint _b_ = dmesa->Buffer->height - 1; \ - GLuint _w_ = dmesa->Buffer->width; \ + GLuint _b_ = dmesa->buffer->height - 1; \ + GLuint _w_ = dmesa->buffer->width; \ GLuint rgb = vl_mixrgb(vert1->color); #define PLOT(X,Y) \ @@ -751,7 +748,7 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all, /* we can't handle color or index masking */ if ((*colorMask == 0xffffffff) && (ctx->Color.IndexMask == 0xffffffff)) { if (mask & DD_BACK_LEFT_BIT) { - int color = c->visual->rgb_flag ? c->ClearColor : c->ClearIndex; + int color = ((GLvisual *)(c->visual))->rgbMode ? c->ClearColor : c->ClearIndex; if (all) { vl_clear(color); @@ -958,10 +955,6 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint redBits, greenBits, blueBits, alphaBits, indexBits; GLboolean sw_alpha; - if (!dbFlag) { - return NULL; - } - alphaBits = 0; if (!rgbFlag) { @@ -1017,6 +1010,9 @@ DMesaVisual DMesaCreateVisual (GLint width, alphaBits = alphaSize; sw_alpha = (alphaBits > 0); + if (!dbFlag) { + return NULL; + } if ((colDepth=vl_video_init(width, height, colDepth, rgbFlag, refresh)) <= 0) { return NULL; } @@ -1040,12 +1036,8 @@ DMesaVisual DMesaCreateVisual (GLint width, alphaBits?accumSize:0, /* accumAlpha */ 1); /* numSamples */ - v->depth = colDepth; - v->db_flag = dbFlag; - v->rgb_flag = rgbFlag; v->sw_alpha = sw_alpha; - - v->zbuffer = (depthSize > 0) ? 1 : 0; + v->z_buffer = (depthSize > 0) ? 1 : 0; } return v; @@ -1113,7 +1105,7 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual, if ((b=(DMesaBuffer)CALLOC_STRUCT(dmesa_buffer)) != NULL) { _mesa_initialize_framebuffer((GLframebuffer *)b, (GLvisual *)visual, - visual->zbuffer == 1, + visual->z_buffer == 1, ((GLvisual *)visual)->stencilBits > 0, ((GLvisual *)visual)->accumRedBits > 0, visual->sw_alpha); @@ -1134,7 +1126,9 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual, void DMesaDestroyBuffer (DMesaBuffer b) { #ifndef FX - free(b->the_window); + if (b->the_window != NULL) { + free(b->the_window); + } _mesa_destroy_framebuffer((GLframebuffer *)b); #endif } @@ -1179,7 +1173,7 @@ DMesaContext DMesaCreateContext (DMesaVisual visual, tnl = TNL_CONTEXT(c); tnl->Driver.RunPipeline = _tnl_run_pipeline; /* swrast setup */ - if (visual->rgb_flag) dmesa_register_swrast_functions(c); + if (((GLvisual *)visual)->rgbMode) dmesa_register_swrast_functions(c); dmesa_init_pointers(c); _swsetup_Wakeup(c); } @@ -1212,19 +1206,16 @@ GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos) { #ifndef FX GET_CURRENT_CONTEXT(ctx); - DMesaBuffer b = ((DMesaContext)ctx)->Buffer; + DMesaBuffer b = ((DMesaContext)ctx)->buffer; - if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) { - return GL_FALSE; - } else { + if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) == 0) { b->xpos = xpos; b->ypos = ypos; return GL_TRUE; } +#endif -#else return GL_FALSE; -#endif } @@ -1233,19 +1224,16 @@ GLboolean DMesaResizeBuffer (GLint width, GLint height) { #ifndef FX GET_CURRENT_CONTEXT(ctx); - DMesaBuffer b = ((DMesaContext)ctx)->Buffer; + DMesaBuffer b = ((DMesaContext)ctx)->buffer; - if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) { - return GL_FALSE; - } else { + if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) == 0) { b->width = width; b->height = height; return GL_TRUE; } +#endif -#else return GL_FALSE; -#endif } @@ -1261,7 +1249,7 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b) return GL_FALSE; } - c->Buffer = b; + c->buffer = b; _mesa_make_current((GLcontext *)c, (GLframebuffer *)b); if (((GLcontext *)c)->Viewport.Width == 0) { @@ -1391,6 +1379,21 @@ int DMesaGetIntegerv (GLenum pname, GLint *params) return n; } #endif + case DMESA_GET_BUFFER_ADDR: + #ifndef FX + { + DMesaContext c = (DMesaContext)DMesaGetCurrentContext(); + if (c != NULL) { + DMesaBuffer b = c->buffer; + if (b != NULL) { + params[0] = (GLint)b->the_window; + } + } + } + #else + return -1; + #endif + break; default: return -1; } diff --git a/src/mesa/drivers/dos/null.c b/src/mesa/drivers/dos/null.c new file mode 100644 index 00000000000..62e2c942ef9 --- /dev/null +++ b/src/mesa/drivers/dos/null.c @@ -0,0 +1,222 @@ +/* + * Mesa 3-D graphics library + * Version: 4.1 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.6 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : [email protected] + * Web : http://www.geocities.com/dborca + */ + + +#include <stdlib.h> +#include <sys/segments.h> + +#include "video.h" +#include "null.h" + + + +static vl_mode *modes; + +#define null_color_precision 8 + + + + +static void null_blit_nop (void) +{ +} + + + +/* Desc: Attempts to detect VGA, check video modes and create selectors. + * + * In : - + * Out : mode array + * + * Note: - + */ +static vl_mode *null_init (void) +{ + static int m[][2] = { + {320, 200}, + {320, 240}, + {400, 300}, + {512, 384}, + {640, 400}, + {640, 480}, + {800, 600}, + {1024, 768}, + {1280, 1024}, + {1600, 1200} + }; + static int b[] = { + 8, + 15, + 16, + 24, + 32 + }; + + unsigned int i, j, k; + + if (modes == NULL) { + modes = malloc(sizeof(vl_mode) * + (1 + (sizeof(m) / sizeof(m[0]) * sizeof(b) / sizeof(b[0])))); + + if (modes != NULL) { + for (k = 0, i = 0; i < sizeof(m) / sizeof(m[0]); i++) { + for (j = 0; j < sizeof(b) / sizeof(b[0]); j++, k++) { + modes[k].xres = m[i][0]; + modes[k].yres = m[i][1]; + modes[k].bpp = b[j]; + modes[k].mode = 0x4000; + modes[k].scanlen = m[i][0] * ((b[j] + 7) / 8); + modes[k].sel = -1; + modes[k].gran = -1; + } + } + modes[k].xres = -1; + modes[k].yres = -1; + modes[k].bpp = -1; + modes[k].mode = 0xffff; + modes[k].scanlen = -1; + modes[k].sel = -1; + modes[k].gran = -1; + } + } + + return modes; +} + + + +/* Desc: Frees all resources allocated by VGA init code. + * + * In : - + * Out : - + * + * Note: - + */ +static void null_fini (void) +{ +} + + + +/* Desc: Attempts to enter specified video mode. + * + * In : ptr to mode structure, refresh rate + * Out : 0 if success + * + * Note: - + */ +static int null_entermode (vl_mode *p, int refresh) +{ + NUL.blit = null_blit_nop; + + return 0; + + (void)(p && refresh); /* silence compiler warning */ +} + + + +/* Desc: Restores to the mode prior to first call to null_entermode. + * + * In : - + * Out : - + * + * Note: - + */ +static void null_restore (void) +{ +} + + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses integer values + */ +static void null_setCI_i (int index, int red, int green, int blue) +{ + (void)(index && red && green && blue); /* silence compiler warning */ +} + + + +/* Desc: set one palette entry + * + * In : color index, R, G, B + * Out : - + * + * Note: uses normalized values + */ +static void null_setCI_f (int index, float red, float green, float blue) +{ + float max = (1 << null_color_precision) - 1; + + null_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); +} + + + +/* Desc: state retrieval + * + * In : parameter name, ptr to storage + * Out : 0 if request successfully processed + * + * Note: - + */ +static int null_get (int pname, int *params) +{ + switch (pname) { + default: + params[0] = params[0]; /* silence compiler warning */ + return -1; + } + return 0; +} + + + +/* + * the driver + */ +vl_driver NUL = { + null_init, + null_entermode, + NULL, + null_setCI_f, + null_setCI_i, + null_get, + null_restore, + null_fini +}; diff --git a/src/mesa/drivers/dos/null.h b/src/mesa/drivers/dos/null.h new file mode 100644 index 00000000000..a38accc8570 --- /dev/null +++ b/src/mesa/drivers/dos/null.h @@ -0,0 +1,41 @@ +/* + * Mesa 3-D graphics library + * Version: 4.0 + * + * Copyright (C) 1999 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * DOS/DJGPP device driver v1.6 for Mesa + * + * Copyright (C) 2002 - Borca Daniel + * Email : [email protected] + * Web : http://www.geocities.com/dborca + */ + + +#ifndef NULL_H_included +#define NULL_H_included + +#include "internal.h" + +extern vl_driver NUL; + +#endif diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c index 41903ebe799..d3774e7c3e4 100644 --- a/src/mesa/drivers/dos/video.c +++ b/src/mesa/drivers/dos/video.c @@ -38,6 +38,7 @@ #include "internal.h" #include "vesa.h" #include "vga.h" +#include "null.h" #include "video.h" @@ -428,6 +429,13 @@ static vl_mode *v_init_hw (void) static vl_mode *q = NULL; if (q == NULL) { + /* are we forced to NUL driver? */ + if (getenv("DMESA_NULDRV")) { + if ((q = NUL.init()) != NULL) { + drv = &NUL; + } + return q; + } /* initialize hardware */ if ((q = VESA.init()) != NULL) { drv = &VESA; diff --git a/src/mesa/drivers/glide/fxwgl.c b/src/mesa/drivers/glide/fxwgl.c index c17560d7247..f8450b1b014 100644 --- a/src/mesa/drivers/glide/fxwgl.c +++ b/src/mesa/drivers/glide/fxwgl.c @@ -572,12 +572,12 @@ wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, DWORD numChars, bitDevice = CreateCompatibleDC(fontDevice); - // Swap fore and back colors so the bitmap has the right polarity + /* Swap fore and back colors so the bitmap has the right polarity */ tempColor = GetBkColor(bitDevice); SetBkColor(bitDevice, GetTextColor(bitDevice)); SetTextColor(bitDevice, tempColor); - // Place chars based on base line + /* Place chars based on base line */ SetTextAlign(bitDevice, TA_BASELINE); for (i = 0; i < (int)numChars; i++) { @@ -588,34 +588,34 @@ wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, DWORD numChars, HGDIOBJ origBmap; unsigned char *bmap; - curChar = (char)(i + firstChar); // [koolsmoky] explicit cast + curChar = (char)(i + firstChar); /* [koolsmoky] explicit cast */ - // Find how high/wide this character is + /* Find how high/wide this character is */ GetTextExtentPoint32(bitDevice, &curChar, 1, &size); - // Create the output bitmap + /* Create the output bitmap */ charWidth = size.cx; charHeight = size.cy; - bmapWidth = ((charWidth + 31) / 32) * 32; // Round up to the next multiple of 32 bits + bmapWidth = ((charWidth + 31) / 32) * 32; /* Round up to the next multiple of 32 bits */ bmapHeight = charHeight; bitObject = CreateCompatibleBitmap(bitDevice, bmapWidth, bmapHeight); - //VERIFY(bitObject); + /*VERIFY(bitObject);*/ - // Assign the output bitmap to the device + /* Assign the output bitmap to the device */ origBmap = SelectObject(bitDevice, bitObject); PatBlt(bitDevice, 0, 0, bmapWidth, bmapHeight, BLACKNESS); - // Use our source font on the device + /* Use our source font on the device */ SelectObject(bitDevice, GetCurrentObject(fontDevice, OBJ_FONT)); - // Draw the character + /* Draw the character */ TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1); - // Unselect our bmap object + /* Unselect our bmap object */ SelectObject(bitDevice, origBmap); - // Convert the display dependant representation to a 1 bit deep DIB + /* Convert the display dependant representation to a 1 bit deep DIB */ numBytes = (bmapWidth * bmapHeight) / 8; bmap = MALLOC(numBytes); dibInfo->bmiHeader.biWidth = bmapWidth; @@ -623,21 +623,21 @@ wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, DWORD numChars, res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap, dibInfo, DIB_RGB_COLORS); - // Create the GL object + /* Create the GL object */ glNewList(i + listBase, GL_COMPILE); glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent, charWidth, 0.0, bmap); glEndList(); - // CheckGL(); + /* CheckGL(); */ - // Destroy the bmap object + /* Destroy the bmap object */ DeleteObject(bitObject); - // Deallocate the bitmap data + /* Deallocate the bitmap data */ FREE(bmap); } - // Destroy the DC + /* Destroy the DC */ DeleteDC(bitDevice); FREE(dibInfo); @@ -695,87 +695,95 @@ GLAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR * ppfd) { int i, best = -1, qt_valid_pix; + PIXELFORMATDESCRIPTOR pfd = *ppfd; #if 0 FILE *pix_file; pix_file = fopen("pix_log.txt", "a"); if (pix_file) { fprintf(pix_file, "wglChoosePixelFormat\n"); - fprintf(pix_file, "nSize = %d\n",ppfd->nSize); - fprintf(pix_file, "nVersion = %d\n",ppfd->nVersion); - fprintf(pix_file, "dwFlags = %d\n",ppfd->dwFlags); - fprintf(pix_file, "iPixelType = %d\n",ppfd->iPixelType); - fprintf(pix_file, "cColorBits = %d\n",ppfd->cColorBits); - fprintf(pix_file, "cRedBits = %d\n",ppfd->cRedBits); - fprintf(pix_file, "cRedShift = %d\n",ppfd->cRedShift); - fprintf(pix_file, "cGreenBits = %d\n",ppfd->cGreenBits); - fprintf(pix_file, "cGreenShift = %d\n",ppfd->cGreenShift); - fprintf(pix_file, "cBlueBits = %d\n",ppfd->cBlueBits); - fprintf(pix_file, "cBlueShift = %d\n",ppfd->cBlueShift); - fprintf(pix_file, "cAlphaBits = %d\n",ppfd->cAlphaBits); - fprintf(pix_file, "cAlphaShift = %d\n",ppfd->cAlphaShift); - fprintf(pix_file, "cAccumBits = %d\n",ppfd->cAccumBits); - fprintf(pix_file, "cAccumRedBits = %d\n",ppfd->cAccumRedBits); - fprintf(pix_file, "cAccumGreenBits = %d\n",ppfd->cAccumGreenBits); - fprintf(pix_file, "cAccumBlueBits = %d\n",ppfd->cAccumBlueBits); - fprintf(pix_file, "cAccumAlphaBits = %d\n",ppfd->cAccumAlphaBits); - fprintf(pix_file, "cDepthBits = %d\n",ppfd->cDepthBits); - fprintf(pix_file, "cStencilBits = %d\n",ppfd->cStencilBits); - fprintf(pix_file, "cAuxBuffers = %d\n",ppfd->cAuxBuffers); - fprintf(pix_file, "iLayerType = %d\n",ppfd->iLayerType); - fprintf(pix_file, "bReserved = %d\n",ppfd->bReserved); - fprintf(pix_file, "dwLayerMask = %d\n",ppfd->dwLayerMask); - fprintf(pix_file, "dwVisibleMask = %d\n",ppfd->dwVisibleMask); - fprintf(pix_file, "dwDamageMask = %d\n",ppfd->dwDamageMask); + fprintf(pix_file, "nSize = %d\n",pfd.nSize); + fprintf(pix_file, "nVersion = %d\n",pfd.nVersion); + fprintf(pix_file, "dwFlags = %d\n",pfd.dwFlags); + fprintf(pix_file, "iPixelType = %d\n",pfd.iPixelType); + fprintf(pix_file, "cColorBits = %d\n",pfd.cColorBits); + fprintf(pix_file, "cRedBits = %d\n",pfd.cRedBits); + fprintf(pix_file, "cRedShift = %d\n",pfd.cRedShift); + fprintf(pix_file, "cGreenBits = %d\n",pfd.cGreenBits); + fprintf(pix_file, "cGreenShift = %d\n",pfd.cGreenShift); + fprintf(pix_file, "cBlueBits = %d\n",pfd.cBlueBits); + fprintf(pix_file, "cBlueShift = %d\n",pfd.cBlueShift); + fprintf(pix_file, "cAlphaBits = %d\n",pfd.cAlphaBits); + fprintf(pix_file, "cAlphaShift = %d\n",pfd.cAlphaShift); + fprintf(pix_file, "cAccumBits = %d\n",pfd.cAccumBits); + fprintf(pix_file, "cAccumRedBits = %d\n",pfd.cAccumRedBits); + fprintf(pix_file, "cAccumGreenBits = %d\n",pfd.cAccumGreenBits); + fprintf(pix_file, "cAccumBlueBits = %d\n",pfd.cAccumBlueBits); + fprintf(pix_file, "cAccumAlphaBits = %d\n",pfd.cAccumAlphaBits); + fprintf(pix_file, "cDepthBits = %d\n",pfd.cDepthBits); + fprintf(pix_file, "cStencilBits = %d\n",pfd.cStencilBits); + fprintf(pix_file, "cAuxBuffers = %d\n",pfd.cAuxBuffers); + fprintf(pix_file, "iLayerType = %d\n",pfd.iLayerType); + fprintf(pix_file, "bReserved = %d\n",pfd.bReserved); + fprintf(pix_file, "dwLayerMask = %d\n",pfd.dwLayerMask); + fprintf(pix_file, "dwVisibleMask = %d\n",pfd.dwVisibleMask); + fprintf(pix_file, "dwDamageMask = %d\n",pfd.dwDamageMask); fclose(pix_file); } #endif -#if 1 || QUAKE2 - if (ppfd->cColorBits == 24 && ppfd->cDepthBits == 32) { - ppfd->cColorBits = 16; - ppfd->cDepthBits = 16; + qt_valid_pix = pfd_tablen(); + +#if 1 || QUAKE2 || GORE + /* QUAKE2: 24+32 */ + /* GORE : 24+16 */ + if (pfd.cColorBits == 24) { + /* the first 2 entries are 16bit */ + pfd.cColorBits = (qt_valid_pix > 2) ? 32 : 16; + } + if (pfd.cColorBits == 32) { + pfd.cDepthBits = 24; + } else if (pfd.cColorBits == 16) { + pfd.cDepthBits = 16; } #endif - qt_valid_pix = pfd_tablen(); - - if (ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) { + if (pfd.nSize != sizeof(PIXELFORMATDESCRIPTOR) || pfd.nVersion != 1) { SetLastError(0); return (0); } for (i = 0; i < qt_valid_pix; i++) { - if (ppfd->cColorBits > 0 && pix[i].pfd.cColorBits != ppfd->cColorBits) + if (pfd.cColorBits > 0 && pix[i].pfd.cColorBits != pfd.cColorBits) continue; - if ((ppfd->dwFlags & PFD_DRAW_TO_WINDOW) + if ((pfd.dwFlags & PFD_DRAW_TO_WINDOW) && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW)) continue; - if ((ppfd->dwFlags & PFD_DRAW_TO_BITMAP) + if ((pfd.dwFlags & PFD_DRAW_TO_BITMAP) && !(pix[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP)) continue; - if ((ppfd->dwFlags & PFD_SUPPORT_GDI) + if ((pfd.dwFlags & PFD_SUPPORT_GDI) && !(pix[i].pfd.dwFlags & PFD_SUPPORT_GDI)) continue; - if ((ppfd->dwFlags & PFD_SUPPORT_OPENGL) + if ((pfd.dwFlags & PFD_SUPPORT_OPENGL) && !(pix[i].pfd.dwFlags & PFD_SUPPORT_OPENGL)) continue; - if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) - && ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != + if (!(pfd.dwFlags & PFD_DOUBLEBUFFER_DONTCARE) + && ((pfd.dwFlags & PFD_DOUBLEBUFFER) != (pix[i].pfd.dwFlags & PFD_DOUBLEBUFFER))) continue; - if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) - && ((ppfd->dwFlags & PFD_STEREO) != + if (!(pfd.dwFlags & PFD_STEREO_DONTCARE) + && ((pfd.dwFlags & PFD_STEREO) != (pix[i].pfd.dwFlags & PFD_STEREO))) continue; - if (ppfd->cDepthBits > 0 && pix[i].pfd.cDepthBits == 0) + if (pfd.cDepthBits > 0 && pix[i].pfd.cDepthBits == 0) continue; /* need depth buffer */ - if (ppfd->cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0) + if (pfd.cAlphaBits > 0 && pix[i].pfd.cAlphaBits == 0) continue; /* need alpha buffer */ #if 0 - if ((ppfd->cColorBits == 32) && (ppfd->cStencilBits > 0 && pix[i].pfd.cStencilBits == 0)) + if ((pfd.cColorBits == 32) && (pfd.cStencilBits > 0 && pix[i].pfd.cStencilBits == 0)) continue; /* need stencil */ #endif - if (ppfd->iPixelType == pix[i].pfd.iPixelType) { + if (pfd.iPixelType == pix[i].pfd.iPixelType) { best = i + 1; break; } |