-/* $Id: wmesa.h,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
+/* $Id: wmesa.h,v 1.2 2002/04/23 18:23:32 kschultz Exp $ */
/*
* Mesa 3-D graphics library
/*
* $Log: wmesa.h,v $
- * Revision 1.1 1999/08/19 00:55:40 jtg
- * Initial revision
+ * Revision 1.2 2002/04/23 18:23:32 kschultz
+ * Fix up alpha buffer handling for Windows.
+ * - add two new Pixel Format Descriptors that do not have alpha bits to
+ * mirror the two that do.
+ * - add logic to wglChoosePixelFormat to match PFD's with respect to alpha.
+ * - Create/clear software alpha buffer as required.
+ * Now a wgl or GLUT program can control the creation of a software alpha
+ * buffer via the PFD or GLUT parms, respectively.
+ *
+ * Revision 1.1.1.1 1999/08/19 00:55:40 jtg
+ * Imported sources
*
* Revision 3.2 1999/01/03 02:54:45 brianp
* updated per Ted Jump
* GL_FALSE = color index mode
* db_flag - GL_TRUE = double-buffered,
* GL_FALSE = single buffered
+ * alpha_flag - GL_TRUE = create software alpha buffer,
+ * GL_FALSE = no software alpha buffer
*
* Note: Indexed mode requires double buffering under Windows.
*
* Return: a WMesa_context or NULL if error.
*/
extern WMesaContext WMesaCreateContext(HWND hWnd,HPALETTE* pPal,
- GLboolean rgb_flag,GLboolean db_flag);
+ GLboolean rgb_flag,
+ GLboolean db_flag,
+ GLboolean alpha_flag);
/*
-/* $Id: wgl.c,v 1.9 2001/09/18 16:39:38 kschultz Exp $ */
+/* $Id: wgl.c,v 1.10 2002/04/23 18:23:33 kschultz Exp $ */
/*
* This library is free software; you can redistribute it and/or
struct __pixelformat__ pix[] =
{
+ /* Double Buffer, alpha */
{ { sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
PFD_TYPE_RGBA,
0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
GL_TRUE
},
+ /* Single Buffer, alpha */
{ { sizeof(PIXELFORMATDESCRIPTOR), 1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
PFD_TYPE_RGBA,
0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
GL_FALSE
},
+ /* Double Buffer, no alpha */
+ { { sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY,
+ PFD_TYPE_RGBA,
+ 24, 8, 0, 8, 8, 8, 16, 0, 0,
+ 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
+ GL_TRUE
+ },
+ /* Single Buffer, no alpha */
+ { { sizeof(PIXELFORMATDESCRIPTOR), 1,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_GENERIC_FORMAT,
+ PFD_TYPE_RGBA,
+ 24, 8, 0, 8, 8, 8, 16, 0, 0,
+ 0, 0, 0, 0, 0, 16, 8, 0, 0, 0, 0, 0, 0 },
+ GL_FALSE
+ },
};
int qt_pix = sizeof(pix) / sizeof(pix[0]);
if ( wgl_ctx[i].ctx == NULL )
{
wgl_ctx[i].ctx = WMesaCreateContext( hWnd, NULL, GL_TRUE,
- pix[curPFD-1].doubleBuffered );
+ pix[curPFD-1].doubleBuffered,
+ pix[curPFD-1].pfd.cAlphaBits ? GL_TRUE : GL_FALSE);
if (wgl_ctx[i].ctx == NULL)
break;
wgl_ctx[i].hdc = hdc;
continue;
if(ppfd->iPixelType != pix[i].pfd.iPixelType)
delta++;
+ if(ppfd->cAlphaBits != pix[i].pfd.cAlphaBits)
+ delta++;
if(delta < bestdelta)
{
best = i + 1;
-/* $Id: wmesa.c,v 1.26 2002/03/16 00:53:15 brianp Exp $ */
+/* $Id: wmesa.c,v 1.27 2002/04/23 18:23:33 kschultz Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
/* sanity check - can't have right(stereo) buffers */
assert((mask & (DD_FRONT_RIGHT_BIT | DD_BACK_RIGHT_BIT)) == 0);
+ /* clear alpha */
+ if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_RIGHT_BIT)) &&
+ ctx->DrawBuffer->UseSoftwareAlphaBuffers &&
+ ctx->Color.ColorMask[ACOMP]) {
+ _mesa_clear_alpha_buffers( ctx );
+ }
+
if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
if (mask & DD_BACK_LEFT_BIT) {
#if defined(USE_GDI_TO_CLEAR)
WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
GLboolean rgb_flag,
- GLboolean db_flag )
+ GLboolean db_flag,
+ GLboolean alpha_flag )
{
RECT CR;
WMesaContext c;
c->gl_visual = _mesa_create_visual(rgb_flag,
db_flag, /* db_flag */
GL_FALSE, /* stereo */
- 8,8,8,8, /* r, g, b, a bits */
+ 8,8,8, /* r, g, b bits */
+ alpha_flag ? 8 : 0, /* alpha bits */
0, /* index bits */
16, /* depth_bits */
8, /* stencil_bits */
c->gl_visual->depthBits > 0,
c->gl_visual->stencilBits > 0,
c->gl_visual->accumRedBits > 0,
- GL_FALSE /* s/w alpha */ );
+ alpha_flag /* s/w alpha */ );
if (!c->gl_buffer) {
_mesa_destroy_visual( c->gl_visual );
_mesa_free_context_data( c->gl_ctx );