diff --git a/src/main.c b/src/main.c index a8c1aa7..f82aa9e 100644 --- a/src/main.c +++ b/src/main.c @@ -69,8 +69,13 @@ int InitialiseWindowsSystem() glLoadIdentity(); glEnable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glEnable(GL_TEXTURE_2D); + + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); #endif return 0; } @@ -437,16 +442,18 @@ int main(int argc, char *argv[]) // AvP.PlayerType = I_Alien; -// AvP.PlayerType = I_Marine; -// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */ + AvP.PlayerType = I_Marine; + SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */ // SetLevelToLoad(AVP_ENVIRONMENT_INVASION); /* because the menus aren't implemented */ - AvP.PlayerType = I_Predator; - SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); +// AvP.PlayerType = I_Predator; +// SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); /* starting predator level */ -// SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer - +// SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer */ + +// SetLevelToLoad(AVP_ENVIRONMENT_E3DEMOSP); /* demo level */ + // while(AvP_MainMenus()) { d3d_light_ctrl.ctrl = LCCM_NORMAL; diff --git a/src/opengl.c b/src/opengl.c index 0ed405e..b058d9b 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -40,6 +40,16 @@ void SecondFlushD3DZBuffer() glClear(GL_DEPTH_BUFFER_BIT); } +void D3D_DecalSystem_Setup() +{ + glDepthMask(GL_FALSE); +} + +void D3D_DecalSystem_End() +{ + glDepthMask(GL_TRUE); +} + GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf) { GLuint h; @@ -47,8 +57,11 @@ GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf) glGenTextures(1, &h); glBindTexture(GL_TEXTURE_2D, h); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); +// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -141,11 +154,25 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER /* this currently doesn't work quite right */ s = ((float)vertices->U) * RecipW + (1.0f/256.0f); t = ((float)vertices->V) * RecipH + (1.0f/256.0f); - z = (65536.0f)/(vertices->Z); - glTexCoord4f(s, t, 0, 1.00); + + z = 1.0 - 600.0/(vertices->Z); + glTexCoord2f(s, t); 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; + + if (x1VDB_ClipLeft) { + x1=Global_VDB_Ptr->VDB_ClipLeft; + } else if (x1>Global_VDB_Ptr->VDB_ClipRight) { + x1=Global_VDB_Ptr->VDB_ClipRight; + } + + if (y1VDB_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; @@ -173,6 +200,7 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER CurrTextureHandle = TextureHandle; +/* note: this doesn't seem to be used in the original? */ return; /* This *tries* to emulate SecondaryColorExt */ /* if (!SecondaryColorExt || WantSecondaryColorHack) */ { @@ -219,6 +247,34 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr) int texoffset = SpecialFXImageNumber; GLfloat ZNear; int i; + float RecipW, RecipH; + + D3DTexture *TextureHandle; + + TextureHandle = ImageHeaderArray[texoffset].D3DTexture; + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, TextureHandle->id); + +// if(ImageHeaderArray[texoffset].ImageWidth==256) { + if (TextureHandle->w == 256) { + RecipW = 1.0 / 256.0; + } else { +// float width = (float) ImageHeaderArray[texoffset].ImageWidth; + float width = (float) TextureHandle->w; + + RecipW = (1.0 / width); + } + +// if(ImageHeaderArray[texoffset].ImageHeight==256) { + if (TextureHandle->h == 256) { + RecipH = 1.0 / 256.0; + } else { +// float height = (float) ImageHeaderArray[texoffset].ImageHeight; + float height = (float) TextureHandle->h; + + RecipH = (1.0 / height); + } if (particleDescPtr->IsLit && !(particlePtr->ParticleID==PARTICLE_ALIEN_BLOOD && CurrentVisionMode==VISION_MODE_PRED_SEEALIENS) ) { @@ -271,6 +327,11 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr) int x1, y1; GLfloat x, y, z, zvalue; + GLfloat s, t; + + s = ((float)(vertices->U>>16)+.5) * RecipW; + t = ((float)(vertices->V>>16)+.5) * RecipH; + glTexCoord2f(s, t); x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX; if (x1VDB_ClipLeft) { @@ -291,9 +352,14 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr) 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; + zvalue = 0; + if (particleDescPtr->IsDrawnInFront) { + zvalue = -1.0f; + } else if (particleDescPtr->IsDrawnAtBack) { + zvalue = 1.0f; + } else { + zvalue = 1.0 - 2*ZNear/((float)vertices->Z); /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */ + } z = zvalue; glVertex3f(x, y, z); diff --git a/src/stubs.c b/src/stubs.c index b895b0c..df4d37e 100644 --- a/src/stubs.c +++ b/src/stubs.c @@ -577,16 +577,6 @@ void D3D_Decal_Output(DECAL *decalPtr,RENDERVERTEX *renderVerticesPtr) fprintf(stderr, "D3D_Decal_Output(%p, %p)\n", decalPtr, renderVerticesPtr); } -void D3D_DecalSystem_Setup() -{ - fprintf(stderr, "D3D_DecalSystem_Setup()\n"); -} - -void D3D_DecalSystem_End() -{ - fprintf(stderr, "D3D_DecalSystem_End()\n"); -} - void D3D_BackdropPolygon_Output(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVerticesPtr) { fprintf(stderr, "D3D_BackdropPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);