Added the windows gamma code.
Fixed lighting problem with weapons.
This commit is contained in:
parent
d19a2069c6
commit
62bc91ebba
6 changed files with 86 additions and 106 deletions
58
src/opengl.c
58
src/opengl.c
|
@ -21,6 +21,8 @@
|
|||
|
||||
extern IMAGEHEADER ImageHeaderArray[];
|
||||
extern VIEWDESCRIPTORBLOCK *Global_VDB_Ptr;
|
||||
extern unsigned char GammaValues[256];
|
||||
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
|
||||
|
||||
static void *CurrTextureHandle;
|
||||
|
||||
|
@ -72,32 +74,78 @@ switch(RenderPolygon.TranslucencyMode)
|
|||
fprintf(stderr, "RenderPolygon.TranslucencyMode: invalid %d\n", RenderPolygon.TranslucencyMode);
|
||||
}
|
||||
|
||||
/*
|
||||
if (SecondaryColorExt)
|
||||
glEnable(GL_COLOR_SUM_EXT);
|
||||
*/
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
for (i = 0; i < RenderPolygon.NumberOfVertices; i++) {
|
||||
RENDERVERTEX *vertices = &renderVerticesPtr[i];
|
||||
GLfloat x, y, z;
|
||||
int x1, y1;
|
||||
RENDERVERTEX *vertices = &renderVerticesPtr[i];
|
||||
|
||||
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;
|
||||
// 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;
|
||||
|
||||
zvalue = vertices->Z+HeadUpDisplayZOffset;
|
||||
zvalue = 1.0 - ZNear/zvalue*2;
|
||||
zvalue = 1.0 - 2*ZNear/zvalue; /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */
|
||||
z = zvalue;
|
||||
|
||||
glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A);
|
||||
glColor4ub(GammaValues[vertices->R], GammaValues[vertices->G], GammaValues[vertices->B], vertices->A);
|
||||
/*
|
||||
if (SecondaryColorExt)
|
||||
glSecondaryColor3ub(GammaValues[vertices->SpecularR], GammaValues[vertices->SpecularG], GammaValues[vertices->SpecularB]);
|
||||
*/
|
||||
glVertex3f(x, y, z);
|
||||
|
||||
// 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);
|
||||
// fprintf(stderr, "GREP: z = %d, znear = %f, zvalue = %f, z = %f\n", vertices->Z, ZNear, zvalue, z);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
CurrTextureHandle = TextureHandle;
|
||||
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue