Fixed particle blending.
This commit is contained in:
parent
56982d4e9b
commit
ae2906ca83
4 changed files with 39 additions and 45 deletions
|
@ -41,7 +41,8 @@ extern "C" {
|
||||||
/* #define _mbclen strlen */
|
/* #define _mbclen strlen */
|
||||||
size_t _mbclen(const unsigned char *s);
|
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
|
#define MAX_PATH PATH_MAX
|
||||||
|
|
||||||
|
|
35
src/opengl.c
35
src/opengl.c
|
@ -33,7 +33,7 @@ static D3DTexture *CurrTextureHandle;
|
||||||
|
|
||||||
#define TRANSLUCENCY_ONEONE 33
|
#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 GLuint CurrentlyBoundTexture = 0; /* opengl state variable */
|
||||||
|
|
||||||
static void CheckBoundTextureIsCorrect(GLuint tex)
|
static void CheckBoundTextureIsCorrect(GLuint tex)
|
||||||
|
@ -46,14 +46,20 @@ static void CheckBoundTextureIsCorrect(GLuint tex)
|
||||||
CurrentlyBoundTexture = tex;
|
CurrentlyBoundTexture = tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CheckTranslucencyModeIsCorrect(int mode) /* TODO: use correct enum */
|
static void CheckTranslucencyModeIsCorrect(enum TRANSLUCENCY_TYPE mode)
|
||||||
{
|
{
|
||||||
if (CurrentTranslucencyMode == mode)
|
if (CurrentTranslucencyMode == mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(RenderPolygon.TranslucencyMode) {
|
switch(mode) {
|
||||||
case TRANSLUCENCY_OFF:
|
case TRANSLUCENCY_OFF:
|
||||||
|
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);
|
glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TRANSLUCENCY_NORMAL:
|
case TRANSLUCENCY_NORMAL:
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
@ -81,6 +87,9 @@ static void CheckTranslucencyModeIsCorrect(int mode) /* TODO: use correct enum *
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode != TRANSLUCENCY_OFF && CurrentTranslucencyMode == TRANSLUCENCY_OFF)
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
CurrentTranslucencyMode = mode;
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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);
|
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;
|
int r, g, b, a;
|
||||||
|
|
||||||
r = (particlePtr->Colour >> 24) & 0xFF;
|
r = (particlePtr->Colour >> 0) & 0xFF;
|
||||||
g = (particlePtr->Colour >> 16) & 0xFF;
|
g = (particlePtr->Colour >> 8) & 0xFF;
|
||||||
b = (particlePtr->Colour >> 8) & 0xFF;
|
b = (particlePtr->Colour >> 16) & 0xFF;
|
||||||
a = (particlePtr->Colour >> 0) & 0xFF;
|
a = (particlePtr->Colour >> 24) & 0xFF;
|
||||||
|
|
||||||
glColor4ub(
|
glColor4ub(
|
||||||
MUL_FIXED(intensity,r),
|
MUL_FIXED(intensity,r),
|
||||||
MUL_FIXED(intensity,g),
|
MUL_FIXED(intensity,g),
|
||||||
MUL_FIXED(intensity,g),
|
MUL_FIXED(intensity,b),
|
||||||
a
|
a
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -346,10 +355,10 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
|
||||||
} else {
|
} else {
|
||||||
int r, g, b, a;
|
int r, g, b, a;
|
||||||
|
|
||||||
r = (particlePtr->Colour >> 24) & 0xFF;
|
r = (particlePtr->Colour >> 0) & 0xFF;
|
||||||
g = (particlePtr->Colour >> 16) & 0xFF;
|
g = (particlePtr->Colour >> 8) & 0xFF;
|
||||||
b = (particlePtr->Colour >> 8) & 0xFF;
|
b = (particlePtr->Colour >> 16) & 0xFF;
|
||||||
a = (particlePtr->Colour >> 0) & 0xFF;
|
a = (particlePtr->Colour >> 24) & 0xFF;
|
||||||
|
|
||||||
glColor4ub(r, g, b, a);
|
glColor4ub(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,15 +100,7 @@ class AwIffConvTransp
|
||||||
: (1<<pixelFormat.blueRightShift )*3/2 - (pPalette[*pCol].b & (1<<pixelFormat.blueRightShift )-1));
|
: (1<<pixelFormat.blueRightShift )*3/2 - (pPalette[*pCol].b & (1<<pixelFormat.blueRightShift )-1));
|
||||||
|
|
||||||
// Pick lowest value and do the business
|
// Pick lowest value and do the business
|
||||||
|
|
||||||
Colour colAdj = pPalette[*pCol];
|
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
|
if
|
||||||
(
|
(
|
||||||
nBlueDiffUp <= nBlueDiffDown
|
nBlueDiffUp <= nBlueDiffDown
|
||||||
|
@ -155,12 +147,6 @@ class AwIffConvTransp
|
||||||
{
|
{
|
||||||
colAdj.g -= static_cast<unsigned char>(1<<pixelFormat.greenRightShift);
|
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);
|
return Colour::ConvNonTransp::DoConv(&colAdj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,10 +432,8 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
|
||||||
// transparency?
|
// transparency?
|
||||||
m_bTranspMask = HasTransparentMask(fMyFlags & AW_TLF_TRANSP ? true : false);
|
m_bTranspMask = HasTransparentMask(fMyFlags & AW_TLF_TRANSP ? true : false);
|
||||||
|
|
||||||
|
|
||||||
if (_parmsR.loadTextureB || fMyFlags & AW_TLF_TEXTURE)
|
if (_parmsR.loadTextureB || fMyFlags & AW_TLF_TEXTURE)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "AwBackupTexture::ChoosePixelFormat(...)\n");
|
|
||||||
#if 0
|
#if 0
|
||||||
// use a texture format
|
// use a texture format
|
||||||
unsigned nColours = GetNumColours();
|
unsigned nColours = GetNumColours();
|
||||||
|
@ -445,7 +443,7 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
|
||||||
|
|
||||||
for (LIF<AdditionalPixelFormat> itFormat(&listTextureFormats); !itFormat.done(); itFormat.next())
|
for (LIF<AdditionalPixelFormat> itFormat(&listTextureFormats); !itFormat.done(); itFormat.next())
|
||||||
{
|
{
|
||||||
AdditionalPixelFormat const * pThisFormat = &itFormat();
|
AdditionalPixelFormat * pThisFormat = &itFormat();
|
||||||
// is this format suitable?
|
// is this format suitable?
|
||||||
// ignoring alpha for now
|
// ignoring alpha for now
|
||||||
if
|
if
|
||||||
|
@ -495,12 +493,12 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
|
||||||
{
|
{
|
||||||
// use display surface format
|
// use display surface format
|
||||||
pixelFormat = pfSurfaceFormat;
|
pixelFormat = pfSurfaceFormat;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#endif
|
||||||
/* Just convert the texture to 32bpp */
|
/* Just convert the texture to 32bpp */
|
||||||
pixelFormat.palettizedB = 0;
|
pixelFormat.palettizedB = 0;
|
||||||
pixelFormat.alphaB = 0;
|
|
||||||
|
pixelFormat.alphaB = 1;
|
||||||
pixelFormat.validB = 1;
|
pixelFormat.validB = 1;
|
||||||
pixelFormat.bitsPerPixel = 32;
|
pixelFormat.bitsPerPixel = 32;
|
||||||
pixelFormat.redLeftShift = 0;
|
pixelFormat.redLeftShift = 0;
|
||||||
|
@ -509,8 +507,8 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
|
||||||
pixelFormat.redRightShift = 0;
|
pixelFormat.redRightShift = 0;
|
||||||
pixelFormat.greenRightShift = 0;
|
pixelFormat.greenRightShift = 0;
|
||||||
pixelFormat.blueRightShift = 0;
|
pixelFormat.blueRightShift = 0;
|
||||||
pixelFormat.dwRGBAlphaBitMask = 0x00000000;
|
pixelFormat.dwRGBAlphaBitMask = 0xFF000000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue