summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/GL/wmesa.h21
-rw-r--r--src/mesa/drivers/windows/wgl.c25
-rw-r--r--src/mesa/drivers/windows/wmesa.c17
3 files changed, 53 insertions, 10 deletions
diff --git a/include/GL/wmesa.h b/include/GL/wmesa.h
index 94b61974c37..67ca17f7a4a 100644
--- a/include/GL/wmesa.h
+++ b/include/GL/wmesa.h
@@ -1,4 +1,4 @@
-/* $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
@@ -24,8 +24,17 @@
/*
* $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
@@ -101,13 +110,17 @@ typedef struct wmesa_context *WMesaContext;
* 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);
/*
diff --git a/src/mesa/drivers/windows/wgl.c b/src/mesa/drivers/windows/wgl.c
index 0db57641fe1..62a4c1704ce 100644
--- a/src/mesa/drivers/windows/wgl.c
+++ b/src/mesa/drivers/windows/wgl.c
@@ -1,4 +1,4 @@
-/* $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
@@ -100,6 +100,7 @@ int qt_ext = sizeof(ext) / sizeof(ext[0]);
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,
@@ -107,6 +108,7 @@ struct __pixelformat__ pix[] =
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,
@@ -114,6 +116,22 @@ struct __pixelformat__ pix[] =
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]);
@@ -158,7 +176,8 @@ WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
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;
@@ -559,6 +578,8 @@ WGLAPI int GLAPIENTRY wglChoosePixelFormat(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;
diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c
index 4f057bfad73..73037b7d05c 100644
--- a/src/mesa/drivers/windows/wmesa.c
+++ b/src/mesa/drivers/windows/wmesa.c
@@ -1,4 +1,4 @@
-/* $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
@@ -396,6 +396,13 @@ static clear(GLcontext* ctx, GLbitfield mask,
/* 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)
@@ -1240,7 +1247,8 @@ static void GetPalette(HPALETTE Pal,RGBQUAD *aRGB)
WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
GLboolean rgb_flag,
- GLboolean db_flag )
+ GLboolean db_flag,
+ GLboolean alpha_flag )
{
RECT CR;
WMesaContext c;
@@ -1318,7 +1326,8 @@ WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
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 */
@@ -1355,7 +1364,7 @@ WMesaContext WMesaCreateContext( HWND hWnd, HPALETTE* Pal,
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 );