Added Particle drawing.
This commit is contained in:
parent
62bc91ebba
commit
da46de9018
2 changed files with 129 additions and 30 deletions
|
@ -434,10 +434,11 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
AvP.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */
|
AvP.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */
|
||||||
|
|
||||||
AvP.PlayerType = I_Alien;
|
// AvP.PlayerType = I_Alien;
|
||||||
|
AvP.PlayerType = I_Marine;
|
||||||
// SetLevelToLoad(AVP_ENVIRONMENT_INVASION); /* because the menus aren't implemented */
|
// SetLevelToLoad(AVP_ENVIRONMENT_INVASION); /* because the menus aren't implemented */
|
||||||
// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
|
SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
|
||||||
SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP);
|
// SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP);
|
||||||
|
|
||||||
// while(AvP_MainMenus()) {
|
// while(AvP_MainMenus()) {
|
||||||
|
|
||||||
|
|
144
src/opengl.c
144
src/opengl.c
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "3dc.h"
|
#include "3dc.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "inline.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "stratdef.h"
|
#include "stratdef.h"
|
||||||
#include "projfont.h"
|
#include "projfont.h"
|
||||||
|
@ -17,38 +18,21 @@
|
||||||
#include "kshape.h"
|
#include "kshape.h"
|
||||||
#include "prototyp.h"
|
#include "prototyp.h"
|
||||||
#include "d3d_hud.h"
|
#include "d3d_hud.h"
|
||||||
|
#include "avp_userprofile.h"
|
||||||
|
|
||||||
|
|
||||||
extern IMAGEHEADER ImageHeaderArray[];
|
extern IMAGEHEADER ImageHeaderArray[];
|
||||||
extern VIEWDESCRIPTORBLOCK *Global_VDB_Ptr;
|
extern VIEWDESCRIPTORBLOCK *Global_VDB_Ptr;
|
||||||
extern unsigned char GammaValues[256];
|
extern unsigned char GammaValues[256];
|
||||||
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
|
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
|
||||||
|
extern int SpecialFXImageNumber;
|
||||||
|
|
||||||
static void *CurrTextureHandle;
|
static void *CurrTextureHandle;
|
||||||
|
|
||||||
void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
|
#define TRANSLUCENCY_ONEONE 33
|
||||||
{
|
void CheckTranslucencyModeIsCorrect(int mode) /* TODO: use correct enum */
|
||||||
#if 1
|
|
||||||
int texoffset;
|
|
||||||
void *TextureHandle;
|
|
||||||
int i;
|
|
||||||
GLfloat ZNear, zvalue;
|
|
||||||
|
|
||||||
ZNear = (GLfloat) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
|
|
||||||
|
|
||||||
texoffset = inputPolyPtr->PolyColour & ClrTxDefn;
|
|
||||||
if (texoffset) {
|
|
||||||
TextureHandle = (void *)ImageHeaderArray[texoffset].D3DHandle;
|
|
||||||
} else {
|
|
||||||
TextureHandle = CurrTextureHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);
|
|
||||||
// fprintf(stderr, "\tRenderPolygon.NumberOfVertices = %d\n", RenderPolygon.NumberOfVertices);
|
|
||||||
// fprintf(stderr, "\ttexoffset = %d (ptr = %p)\n", texoffset, texoffset ? (void *)ImageHeaderArray[texoffset].D3DHandle : CurrTextureHandle);
|
|
||||||
|
|
||||||
switch(RenderPolygon.TranslucencyMode)
|
|
||||||
{
|
{
|
||||||
|
switch(RenderPolygon.TranslucencyMode) {
|
||||||
case TRANSLUCENCY_OFF:
|
case TRANSLUCENCY_OFF:
|
||||||
glBlendFunc(GL_ONE, GL_ZERO);
|
glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
break;
|
break;
|
||||||
|
@ -70,10 +54,39 @@ switch(RenderPolygon.TranslucencyMode)
|
||||||
case TRANSLUCENCY_JUSTSETZ:
|
case TRANSLUCENCY_JUSTSETZ:
|
||||||
glBlendFunc(GL_ZERO, GL_ONE);
|
glBlendFunc(GL_ZERO, GL_ONE);
|
||||||
break;
|
break;
|
||||||
|
case TRANSLUCENCY_ONEONE:
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "RenderPolygon.TranslucencyMode: invalid %d\n", RenderPolygon.TranslucencyMode);
|
fprintf(stderr, "RenderPolygon.TranslucencyMode: invalid %d\n", RenderPolygon.TranslucencyMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
int texoffset;
|
||||||
|
void *TextureHandle;
|
||||||
|
int i;
|
||||||
|
GLfloat ZNear, zvalue;
|
||||||
|
// GLflaot ZFar;
|
||||||
|
|
||||||
|
ZNear = (GLfloat) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
|
||||||
|
// ZFar = 18000.0f; /* TODO: is this good enough? */
|
||||||
|
|
||||||
|
texoffset = inputPolyPtr->PolyColour & ClrTxDefn;
|
||||||
|
if (texoffset) {
|
||||||
|
TextureHandle = (void *)ImageHeaderArray[texoffset].D3DHandle;
|
||||||
|
} else {
|
||||||
|
TextureHandle = CurrTextureHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);
|
||||||
|
// fprintf(stderr, "\tRenderPolygon.NumberOfVertices = %d\n", RenderPolygon.NumberOfVertices);
|
||||||
|
// fprintf(stderr, "\ttexoffset = %d (ptr = %p)\n", texoffset, texoffset ? (void *)ImageHeaderArray[texoffset].D3DHandle : CurrTextureHandle);
|
||||||
|
|
||||||
|
CheckTranslucencyModeIsCorrect(RenderPolygon.TranslucencyMode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (SecondaryColorExt)
|
if (SecondaryColorExt)
|
||||||
glEnable(GL_COLOR_SUM_EXT);
|
glEnable(GL_COLOR_SUM_EXT);
|
||||||
|
@ -97,6 +110,7 @@ switch(RenderPolygon.TranslucencyMode)
|
||||||
|
|
||||||
zvalue = vertices->Z+HeadUpDisplayZOffset;
|
zvalue = vertices->Z+HeadUpDisplayZOffset;
|
||||||
zvalue = 1.0 - 2*ZNear/zvalue; /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */
|
zvalue = 1.0 - 2*ZNear/zvalue; /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */
|
||||||
|
// zvalue = 2.0 * (zvalue - ZNear) / (ZFar - ZNear) - 1.0;
|
||||||
z = zvalue;
|
z = zvalue;
|
||||||
|
|
||||||
glColor4ub(GammaValues[vertices->R], GammaValues[vertices->G], GammaValues[vertices->B], vertices->A);
|
glColor4ub(GammaValues[vertices->R], GammaValues[vertices->G], GammaValues[vertices->B], vertices->A);
|
||||||
|
@ -116,7 +130,7 @@ switch(RenderPolygon.TranslucencyMode)
|
||||||
return;
|
return;
|
||||||
/* This *tries* to emulate SecondaryColorExt */
|
/* This *tries* to emulate SecondaryColorExt */
|
||||||
/* if (!SecondaryColorExt || WantSecondaryColorHack) */ {
|
/* if (!SecondaryColorExt || WantSecondaryColorHack) */ {
|
||||||
glBlendFunc(GL_ONE, GL_ONE);
|
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_ONEONE);
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
|
@ -151,4 +165,88 @@ return;
|
||||||
|
|
||||||
void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
|
void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
|
||||||
{
|
{
|
||||||
|
PARTICLE_DESC *particleDescPtr = &ParticleDescription[particlePtr->ParticleID];
|
||||||
|
int texoffset = SpecialFXImageNumber;
|
||||||
|
GLfloat ZNear;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (particleDescPtr->IsLit && !(particlePtr->ParticleID==PARTICLE_ALIEN_BLOOD && CurrentVisionMode==VISION_MODE_PRED_SEEALIENS) )
|
||||||
|
{
|
||||||
|
int intensity = LightIntensityAtPoint(&particlePtr->Position);
|
||||||
|
|
||||||
|
if (particlePtr->ParticleID==PARTICLE_SMOKECLOUD || particlePtr->ParticleID==PARTICLE_ANDROID_BLOOD)
|
||||||
|
{
|
||||||
|
int r, g, b, a;
|
||||||
|
|
||||||
|
r = (particlePtr->Colour >> 24) & 0xFF000000;
|
||||||
|
g = (particlePtr->Colour >> 16) & 0x00FF0000;
|
||||||
|
b = (particlePtr->Colour >> 8) & 0x0000FF00;
|
||||||
|
a = (particlePtr->Colour >> 0) & 0x000000FF;
|
||||||
|
|
||||||
|
glColor4ub(
|
||||||
|
MUL_FIXED(intensity,r),
|
||||||
|
MUL_FIXED(intensity,g),
|
||||||
|
MUL_FIXED(intensity,g),
|
||||||
|
a
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
glColor4ub(
|
||||||
|
MUL_FIXED(intensity,particleDescPtr->RedScale[CurrentVisionMode]),
|
||||||
|
MUL_FIXED(intensity,particleDescPtr->GreenScale[CurrentVisionMode]),
|
||||||
|
MUL_FIXED(intensity,particleDescPtr->BlueScale[CurrentVisionMode]),
|
||||||
|
particleDescPtr->Alpha
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int r, g, b, a;
|
||||||
|
|
||||||
|
r = (particlePtr->Colour >> 24) & 0xFF000000;
|
||||||
|
g = (particlePtr->Colour >> 16) & 0x00FF0000;
|
||||||
|
b = (particlePtr->Colour >> 8) & 0x0000FF00;
|
||||||
|
a = (particlePtr->Colour >> 0) & 0x000000FF;
|
||||||
|
|
||||||
|
glColor4ub(r, g, b, a);
|
||||||
|
}
|
||||||
|
if (RAINBOWBLOOD_CHEATMODE) {
|
||||||
|
glColor4ub(FastRandom()&255, FastRandom()&255, FastRandom()&255, particleDescPtr->Alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZNear = (GLfloat) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
|
||||||
|
|
||||||
|
CheckTranslucencyModeIsCorrect(particleDescPtr->TranslucencyType);
|
||||||
|
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
for (i = 0; i < RenderPolygon.NumberOfVertices; i++) {
|
||||||
|
RENDERVERTEX *vertices = &renderVerticesPtr[i];
|
||||||
|
|
||||||
|
int x1, y1;
|
||||||
|
GLfloat x, y, z, zvalue;
|
||||||
|
|
||||||
|
x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX;
|
||||||
|
if (x1<Global_VDB_Ptr->VDB_ClipLeft) {
|
||||||
|
x1=Global_VDB_Ptr->VDB_ClipLeft;
|
||||||
|
} else if (x1>Global_VDB_Ptr->VDB_ClipRight) {
|
||||||
|
x1=Global_VDB_Ptr->VDB_ClipRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
y1 = (vertices->Y*(Global_VDB_Ptr->VDB_ProjY+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreY;
|
||||||
|
if (y1<Global_VDB_Ptr->VDB_ClipUp) {
|
||||||
|
y1=Global_VDB_Ptr->VDB_ClipUp;
|
||||||
|
} else if (y1>Global_VDB_Ptr->VDB_ClipDown) {
|
||||||
|
y1=Global_VDB_Ptr->VDB_ClipDown;
|
||||||
|
}
|
||||||
|
x = x1;
|
||||||
|
y = y1;
|
||||||
|
|
||||||
|
x = (x - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX;
|
||||||
|
y = -(y - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY;
|
||||||
|
|
||||||
|
zvalue = vertices->Z+HeadUpDisplayZOffset;
|
||||||
|
zvalue = 1.0 - 2*ZNear/zvalue; /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */
|
||||||
|
// zvalue = 2.0 * (zvalue - ZNear) / (ZFar - ZNear) - 1.0;
|
||||||
|
z = zvalue;
|
||||||
|
|
||||||
|
glVertex3f(x, y, z);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue