2001-08-08 06:14:20 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
|
|
|
|
|
|
|
#include "fixer.h"
|
|
|
|
|
|
|
|
#include "3dc.h"
|
|
|
|
#include "platform.h"
|
|
|
|
#include "module.h"
|
|
|
|
#include "stratdef.h"
|
|
|
|
#include "projfont.h"
|
|
|
|
#include "krender.h"
|
|
|
|
#include "kshape.h"
|
|
|
|
#include "prototyp.h"
|
|
|
|
#include "d3d_hud.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern IMAGEHEADER ImageHeaderArray[];
|
|
|
|
extern VIEWDESCRIPTORBLOCK *Global_VDB_Ptr;
|
2001-08-10 02:37:25 +00:00
|
|
|
extern unsigned char GammaValues[256];
|
|
|
|
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
|
2001-08-08 06:14:20 +00:00
|
|
|
|
|
|
|
static void *CurrTextureHandle;
|
|
|
|
|
|
|
|
void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
|
|
|
|
{
|
2001-08-09 06:23:42 +00:00
|
|
|
#if 1
|
2001-08-08 06:14:20 +00:00
|
|
|
int texoffset;
|
|
|
|
void *TextureHandle;
|
|
|
|
int i;
|
2001-08-08 15:49:59 +00:00
|
|
|
GLfloat ZNear, zvalue;
|
|
|
|
|
|
|
|
ZNear = (GLfloat) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
|
2001-08-08 06:14:20 +00:00
|
|
|
|
|
|
|
texoffset = inputPolyPtr->PolyColour & ClrTxDefn;
|
|
|
|
if (texoffset) {
|
|
|
|
TextureHandle = (void *)ImageHeaderArray[texoffset].D3DHandle;
|
|
|
|
} else {
|
|
|
|
TextureHandle = CurrTextureHandle;
|
|
|
|
}
|
|
|
|
|
2001-08-09 06:23:42 +00:00
|
|
|
// 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);
|
2001-08-08 15:49:59 +00:00
|
|
|
|
|
|
|
switch(RenderPolygon.TranslucencyMode)
|
|
|
|
{
|
|
|
|
case TRANSLUCENCY_OFF:
|
|
|
|
glBlendFunc(GL_ONE, GL_ZERO);
|
|
|
|
break;
|
|
|
|
case TRANSLUCENCY_NORMAL:
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
break;
|
|
|
|
case TRANSLUCENCY_COLOUR:
|
|
|
|
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
|
|
|
break;
|
|
|
|
case TRANSLUCENCY_INVCOLOUR:
|
|
|
|
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
|
|
|
break;
|
|
|
|
case TRANSLUCENCY_GLOWING:
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
|
|
break;
|
|
|
|
case TRANSLUCENCY_DARKENINGCOLOUR:
|
|
|
|
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
|
|
|
break;
|
|
|
|
case TRANSLUCENCY_JUSTSETZ:
|
|
|
|
glBlendFunc(GL_ZERO, GL_ONE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "RenderPolygon.TranslucencyMode: invalid %d\n", RenderPolygon.TranslucencyMode);
|
|
|
|
}
|
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
/*
|
|
|
|
if (SecondaryColorExt)
|
|
|
|
glEnable(GL_COLOR_SUM_EXT);
|
|
|
|
*/
|
|
|
|
|
2001-08-08 06:14:20 +00:00
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
for (i = 0; i < RenderPolygon.NumberOfVertices; i++) {
|
2001-08-10 02:37:25 +00:00
|
|
|
RENDERVERTEX *vertices = &renderVerticesPtr[i];
|
2001-08-08 06:14:20 +00:00
|
|
|
GLfloat x, y, z;
|
|
|
|
int x1, y1;
|
|
|
|
|
2001-08-08 15:49:59 +00:00
|
|
|
x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX;
|
|
|
|
y1 = (vertices->Y*(Global_VDB_Ptr->VDB_ProjY+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreY;
|
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
// x = (x - 319.0)/319.0;
|
|
|
|
// y = -(y - 239.0)/239.0;
|
|
|
|
x = (x - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX;
|
|
|
|
y = -(y - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY;
|
2001-08-08 15:49:59 +00:00
|
|
|
|
2001-08-09 07:03:00 +00:00
|
|
|
zvalue = vertices->Z+HeadUpDisplayZOffset;
|
2001-08-10 02:37:25 +00:00
|
|
|
zvalue = 1.0 - 2*ZNear/zvalue; /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */
|
2001-08-09 07:03:00 +00:00
|
|
|
z = zvalue;
|
2001-08-08 15:49:59 +00:00
|
|
|
|
2001-08-10 02:37:25 +00:00
|
|
|
glColor4ub(GammaValues[vertices->R], GammaValues[vertices->G], GammaValues[vertices->B], vertices->A);
|
|
|
|
/*
|
|
|
|
if (SecondaryColorExt)
|
|
|
|
glSecondaryColor3ub(GammaValues[vertices->SpecularR], GammaValues[vertices->SpecularG], GammaValues[vertices->SpecularB]);
|
|
|
|
*/
|
2001-08-08 06:14:20 +00:00
|
|
|
glVertex3f(x, y, z);
|
2001-08-10 02:37:25 +00:00
|
|
|
|
2001-08-09 06:23:42 +00:00
|
|
|
// fprintf(stderr, "Vertex %d: (%f, %f, %f)\n\t[%d, %d, %d]->[%d, %d] (%d, %d, %d, %d)\n", i, x, y, z, vertices->X, vertices->Y, vertices->Z, x1, y1, vertices->R, vertices->G, vertices->B, vertices->A);
|
2001-08-09 07:03:00 +00:00
|
|
|
// fprintf(stderr, "GREP: z = %d, znear = %f, zvalue = %f, z = %f\n", vertices->Z, ZNear, zvalue, z);
|
2001-08-08 06:14:20 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
CurrTextureHandle = TextureHandle;
|
2001-08-10 02:37:25 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
/* This *tries* to emulate SecondaryColorExt */
|
|
|
|
/* if (!SecondaryColorExt || WantSecondaryColorHack) */ {
|
|
|
|
glBlendFunc(GL_ONE, GL_ONE);
|
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
|
|
|
glDepthMask(GL_FALSE);
|
|
|
|
|
|
|
|
glBegin(GL_POLYGON);
|
|
|
|
for (i = 0; i < RenderPolygon.NumberOfVertices; i++) {
|
|
|
|
RENDERVERTEX *vertices = &renderVerticesPtr[i];
|
|
|
|
GLfloat x, y, z;
|
|
|
|
int x1, y1;
|
|
|
|
|
|
|
|
x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX;
|
|
|
|
y1 = (vertices->Y*(Global_VDB_Ptr->VDB_ProjY+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreY;
|
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
|
|
|
|
x = (x - 320.0)/320.0;
|
|
|
|
y = -(y - 240.0)/240.0;
|
|
|
|
|
|
|
|
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 */
|
|
|
|
z = zvalue;
|
|
|
|
|
|
|
|
glColor4ub(GammaValues[vertices->SpecularR], GammaValues[vertices->SpecularG], GammaValues[vertices->SpecularB], 255);
|
|
|
|
glVertex3f(x, y, z);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
glDepthMask(GL_TRUE);
|
|
|
|
}
|
2001-08-09 06:23:42 +00:00
|
|
|
#endif
|
2001-08-08 06:14:20 +00:00
|
|
|
}
|
2001-08-09 22:34:20 +00:00
|
|
|
|
|
|
|
void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
|
|
|
|
{
|
|
|
|
}
|