Fixed particle blending.

This commit is contained in:
Steven Fuller 2001-08-12 01:26:18 +00:00 committed by Patryk Obara
parent 56982d4e9b
commit ae2906ca83
4 changed files with 39 additions and 45 deletions

View file

@ -41,7 +41,8 @@ extern "C" {
/* #define _mbclen strlen */
size_t _mbclen(const unsigned char *s);
#define RGBA_MAKE(r,g,b,a) (((r) << 24) | ((g) << 16) | ((b) << 8) | (a))
//#define RGBA_MAKE(r,g,b,a) (((r) << 24) | ((g) << 16) | ((b) << 8) | (a))
#define RGBA_MAKE(r,g,b,a) ((((unsigned char)a) << 24) | (((unsigned char)b) << 16) | (((unsigned char)g) << 8) | ((unsigned char)r))
#define MAX_PATH PATH_MAX

View file

@ -33,7 +33,7 @@ static D3DTexture *CurrTextureHandle;
#define TRANSLUCENCY_ONEONE 33
static int CurrentTranslucencyMode = TRANSLUCENCY_OFF; /* opengl state variable */
static enum TRANSLUCENCY_TYPE CurrentTranslucencyMode = TRANSLUCENCY_OFF; /* opengl state variable */
static GLuint CurrentlyBoundTexture = 0; /* opengl state variable */
static void CheckBoundTextureIsCorrect(GLuint tex)
@ -46,14 +46,20 @@ static void CheckBoundTextureIsCorrect(GLuint tex)
CurrentlyBoundTexture = tex;
}
static void CheckTranslucencyModeIsCorrect(int mode) /* TODO: use correct enum */
static void CheckTranslucencyModeIsCorrect(enum TRANSLUCENCY_TYPE mode)
{
if (CurrentTranslucencyMode == mode)
return;
switch(RenderPolygon.TranslucencyMode) {
switch(mode) {
case TRANSLUCENCY_OFF:
glBlendFunc(GL_ONE, GL_ZERO);
if (TRIPTASTIC_CHEATMODE||MOTIONBLUR_CHEATMODE) {
// glBlendMode(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
/* TODO: this may not be properly set... */
} else {
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
}
break;
case TRANSLUCENCY_NORMAL:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -81,6 +87,9 @@ static void CheckTranslucencyModeIsCorrect(int mode) /* TODO: use correct enum *
return;
}
if (mode != TRANSLUCENCY_OFF && CurrentTranslucencyMode == TRANSLUCENCY_OFF)
glEnable(GL_BLEND);
CurrentTranslucencyMode = mode;
}
@ -119,7 +128,7 @@ GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -324,15 +333,15 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
{
int r, g, b, a;
r = (particlePtr->Colour >> 24) & 0xFF;
g = (particlePtr->Colour >> 16) & 0xFF;
b = (particlePtr->Colour >> 8) & 0xFF;
a = (particlePtr->Colour >> 0) & 0xFF;
r = (particlePtr->Colour >> 0) & 0xFF;
g = (particlePtr->Colour >> 8) & 0xFF;
b = (particlePtr->Colour >> 16) & 0xFF;
a = (particlePtr->Colour >> 24) & 0xFF;
glColor4ub(
MUL_FIXED(intensity,r),
MUL_FIXED(intensity,g),
MUL_FIXED(intensity,g),
MUL_FIXED(intensity,b),
a
);
} else {
@ -346,10 +355,10 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
} else {
int r, g, b, a;
r = (particlePtr->Colour >> 24) & 0xFF;
g = (particlePtr->Colour >> 16) & 0xFF;
b = (particlePtr->Colour >> 8) & 0xFF;
a = (particlePtr->Colour >> 0) & 0xFF;
r = (particlePtr->Colour >> 0) & 0xFF;
g = (particlePtr->Colour >> 8) & 0xFF;
b = (particlePtr->Colour >> 16) & 0xFF;
a = (particlePtr->Colour >> 24) & 0xFF;
glColor4ub(r, g, b, a);
}

View file

@ -100,15 +100,7 @@ class AwIffConvTransp
: (1<<pixelFormat.blueRightShift )*3/2 - (pPalette[*pCol].b & (1<<pixelFormat.blueRightShift )-1));
// Pick lowest value and do the business
Colour colAdj = pPalette[*pCol];
#if defined(_MSC_VER) && _MSC_VER >= 1100
// VC5.0 gives inane warnings when += type operators
// are used on types smaller than int (even with
// explicit casting!)
#pragma warning(disable:4244)
#endif
if
(
nBlueDiffUp <= nBlueDiffDown
@ -155,12 +147,6 @@ class AwIffConvTransp
{
colAdj.g -= static_cast<unsigned char>(1<<pixelFormat.greenRightShift);
}
#if defined(_MSC_VER) && _MSC_VER == 1100
// VC5.0 gives inane warnings when += type operators
// are used on types smaller than int (even with
// explicit casting!)
#pragma warning(default:4244)
#endif
return Colour::ConvNonTransp::DoConv(&colAdj);
}

View file

@ -432,10 +432,8 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
// transparency?
m_bTranspMask = HasTransparentMask(fMyFlags & AW_TLF_TRANSP ? true : false);
if (_parmsR.loadTextureB || fMyFlags & AW_TLF_TEXTURE)
{
fprintf(stderr, "AwBackupTexture::ChoosePixelFormat(...)\n");
#if 0
// use a texture format
unsigned nColours = GetNumColours();
@ -445,7 +443,7 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
for (LIF<AdditionalPixelFormat> itFormat(&listTextureFormats); !itFormat.done(); itFormat.next())
{
AdditionalPixelFormat const * pThisFormat = &itFormat();
AdditionalPixelFormat * pThisFormat = &itFormat();
// is this format suitable?
// ignoring alpha for now
if
@ -495,12 +493,12 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
{
// use display surface format
pixelFormat = pfSurfaceFormat;
#endif
}
/* Just convert the texture to 32bpp */
#endif
/* Just convert the texture to 32bpp */
pixelFormat.palettizedB = 0;
pixelFormat.alphaB = 0;
pixelFormat.alphaB = 1;
pixelFormat.validB = 1;
pixelFormat.bitsPerPixel = 32;
pixelFormat.redLeftShift = 0;
@ -509,8 +507,8 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
pixelFormat.redRightShift = 0;
pixelFormat.greenRightShift = 0;
pixelFormat.blueRightShift = 0;
pixelFormat.dwRGBAlphaBitMask = 0x00000000;
pixelFormat.dwRGBAlphaBitMask = 0xFF000000;
}
}
extern "C" {