Fixed pixel color component problem and clear code for 24-bit Windows
devices. (Jeff Lewis)
This commit is contained in:
parent
807aea838b
commit
f2e5c19a2f
|
@ -24,6 +24,10 @@
|
|||
|
||||
/*
|
||||
* $Log: colors.h,v $
|
||||
* Revision 1.3 2002/01/15 18:14:34 kschultz
|
||||
* Fixed pixel color component problem and clear code for 24-bit Windows
|
||||
* devices. (Jeff Lewis)
|
||||
*
|
||||
* Revision 1.2 2002/01/15 18:11:36 kschultz
|
||||
* Remove trailing CR's. No logical changes.
|
||||
*
|
||||
|
@ -42,6 +46,10 @@
|
|||
|
||||
/*
|
||||
* $Log: colors.h,v $
|
||||
* Revision 1.3 2002/01/15 18:14:34 kschultz
|
||||
* Fixed pixel color component problem and clear code for 24-bit Windows
|
||||
* devices. (Jeff Lewis)
|
||||
*
|
||||
* Revision 1.2 2002/01/15 18:11:36 kschultz
|
||||
* Remove trailing CR's. No logical changes.
|
||||
*
|
||||
|
@ -60,6 +68,10 @@
|
|||
|
||||
/*
|
||||
* $Log: colors.h,v $
|
||||
* Revision 1.3 2002/01/15 18:14:34 kschultz
|
||||
* Fixed pixel color component problem and clear code for 24-bit Windows
|
||||
* devices. (Jeff Lewis)
|
||||
*
|
||||
* Revision 1.2 2002/01/15 18:11:36 kschultz
|
||||
* Remove trailing CR's. No logical changes.
|
||||
*
|
||||
|
@ -126,7 +138,8 @@ char ColorMap16[] = {
|
|||
#else
|
||||
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
|
||||
#endif
|
||||
#define BGR24(r,g,b) (unsigned long)(((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))) << 8)
|
||||
#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
|
||||
|
||||
#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: wmesa.c,v 1.23 2001/11/01 22:44:47 kschultz Exp $ */
|
||||
/* $Id: wmesa.c,v 1.24 2002/01/15 18:14:34 kschultz Exp $ */
|
||||
|
||||
/*
|
||||
* Windows (Win32) device driver for Mesa 3.4
|
||||
|
@ -370,7 +370,6 @@ static void clear_color( GLcontext* ctx, const GLchan color[4] )
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Clear the specified region of the color buffer using the clear color
|
||||
* or index as specified by one of the two functions above.
|
||||
|
@ -419,6 +418,7 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
DeleteObject(Brush);
|
||||
Current->lpDDSOffScreen->lpVtbl->ReleaseDC(Current->lpDDSOffScreen,DC);
|
||||
while (Current->lpDDSOffScreen->lpVtbl->Lock(Current->lpDDSOffScreen,NULL, &(Current->ddsd), 0, NULL) == DDERR_WASSTILLDRAWING);
|
||||
|
||||
mask &= ~DD_BACK_LEFT_BIT;
|
||||
#else
|
||||
/* single-buffer */
|
||||
|
@ -428,6 +428,7 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
HPEN Old_Pen=SelectObject(DC,Pen);
|
||||
HBRUSH Old_Brush=SelectObject(DC,Brush);
|
||||
Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
|
||||
|
||||
SelectObject(DC,Old_Pen);
|
||||
SelectObject(DC,Old_Brush);
|
||||
DeleteObject(Pen);
|
||||
|
@ -447,6 +448,8 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
UINT nBypp = Current->cColorBits / 8;
|
||||
int i = 0;
|
||||
int iSize = 0;
|
||||
int mult = 4;
|
||||
|
||||
|
||||
assert(Current->db_flag==GL_TRUE); /* we'd better be double buffer */
|
||||
if(nBypp ==1 ){
|
||||
|
@ -457,13 +460,28 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
wColor = MAKEWORD(bColor,bColor);
|
||||
dwColor = MAKELONG(wColor, wColor);
|
||||
}
|
||||
if(nBypp == 2){
|
||||
else if(nBypp == 2){
|
||||
iSize = Current->width / 2;
|
||||
wColor = BGR16(GetRValue(Current->clearpixel),
|
||||
GetGValue(Current->clearpixel),
|
||||
GetBValue(Current->clearpixel));
|
||||
dwColor = MAKELONG(wColor, wColor);
|
||||
}
|
||||
else if(nBypp == 3){
|
||||
BYTE r, g, b;
|
||||
r = GetRValue(Current->clearpixel);
|
||||
g = GetGValue(Current->clearpixel);
|
||||
b = GetBValue(Current->clearpixel);
|
||||
iSize = Current->width;
|
||||
while (i < iSize) {
|
||||
*lpb++ = r;
|
||||
*lpb++ = g;
|
||||
*lpb++ = b;
|
||||
i++;
|
||||
}
|
||||
lpb = Current->pbPixels + Current->ScanWidth;
|
||||
mult = 3;
|
||||
}
|
||||
else if(nBypp == 4){
|
||||
iSize = Current->width;
|
||||
dwColor = BGR32(GetRValue(Current->clearpixel),
|
||||
|
@ -471,25 +489,14 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
GetBValue(Current->clearpixel));
|
||||
}
|
||||
|
||||
if (nBypp != 3)
|
||||
{
|
||||
/* clear a line */
|
||||
while(i < iSize){
|
||||
*lpdw = dwColor;
|
||||
lpdw++;
|
||||
i++;
|
||||
}
|
||||
|
||||
/* This is the 24bit case */
|
||||
if (nBypp == 3) {
|
||||
iSize = Current->width *3/4;
|
||||
dwColor = BGR24(GetRValue(Current->clearpixel),
|
||||
GetGValue(Current->clearpixel),
|
||||
GetBValue(Current->clearpixel));
|
||||
while(i < iSize){
|
||||
*lpdw = dwColor;
|
||||
lpb += nBypp;
|
||||
lpdw = (LPDWORD)lpb;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
@ -499,7 +506,7 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
lines = height;
|
||||
/* copy cleared line to other lines in buffer */
|
||||
do {
|
||||
memcpy(lpb, Current->pbPixels, iSize*4);
|
||||
memcpy(lpb, Current->pbPixels, iSize*mult);
|
||||
lpb += Current->ScanWidth;
|
||||
i++;
|
||||
}
|
||||
|
@ -516,6 +523,7 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
HPEN Old_Pen=SelectObject(DC,Pen);
|
||||
HBRUSH Old_Brush=SelectObject(DC,Brush);
|
||||
Rectangle(DC,x+Current->rectSurface.left,Current->rectSurface.top+y,x+width+Current->rectSurface.left,y+height+Current->rectSurface.top);
|
||||
|
||||
SelectObject(DC,Old_Pen);
|
||||
SelectObject(DC,Old_Brush);
|
||||
DeleteObject(Pen);
|
||||
|
@ -531,7 +539,6 @@ static clear(GLcontext* ctx, GLbitfield mask,
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void enable( GLcontext* ctx, GLenum pname, GLboolean enable )
|
||||
{
|
||||
if (!Current)
|
||||
|
|
Loading…
Reference in New Issue