diff --git a/src/main.c b/src/main.c index adaac43..c63e04e 100644 --- a/src/main.c +++ b/src/main.c @@ -61,6 +61,10 @@ int InitialiseWindowsSystem() exit(EXIT_FAILURE); } + SDL_WM_SetCaption("Aliens vs Predator", "Aliens vs Predator"); + +// SDL_ShowCursor(0); + glViewport(0, 0, MyWidth, MyHeight); glMatrixMode(GL_PROJECTION); @@ -447,8 +451,6 @@ int main(int argc, char *argv[]) // 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); /* starting predator level */ diff --git a/src/opengl.c b/src/opengl.c index 75f3a7e..5f99402 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -120,10 +120,11 @@ GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf) GLuint h; glGenTextures(1, &h); - + +/* TODO: d3d code doesn't explicitly enable repeating but some levels (namely predator beginning level waterfall) have clamped textures */ glBindTexture(GL_TEXTURE_2D, h); - 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_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -192,7 +193,8 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER CheckBoundTextureIsCorrect(TextureHandle->id); - glBegin(GL_POLYGON); + // glBegin(GL_POLYGON); + SelectPolygonBeginType(RenderPolygon.NumberOfVertices); for (i = 0; i < RenderPolygon.NumberOfVertices; i++) { RENDERVERTEX *vertices = &renderVerticesPtr[i]; GLfloat x, y, z; @@ -203,6 +205,9 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER s = ((float)vertices->U) * RecipW + (1.0f/256.0f); t = ((float)vertices->V) * RecipH + (1.0f/256.0f); +// if (s < 0.0 || t < 0.0 || s >= 1.0 || t >= 1.0) +// fprintf(stderr, "HEY! s = %f, t = %f (%d, %d)\n", s, t, vertices->U, vertices->V); + 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; @@ -368,8 +373,7 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr) } //glBegin(GL_POLYGON); - SelectPolygonBeginType(RenderPolygon.NumberOfVertices); - + SelectPolygonBeginType(RenderPolygon.NumberOfVertices); for (i = 0; i < RenderPolygon.NumberOfVertices; i++) { RENDERVERTEX *vertices = &renderVerticesPtr[i]; @@ -423,3 +427,79 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr) } glEnd(); } + +void D3D_PredatorThermalVisionPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr) +{ + float ZNear; + int i; + ZNear = (float) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale); + + CheckBoundTextureIsCorrect(0); /* disable texturing */ + CheckTranslucencyModeIsCorrect(TRANSLUCENCY_OFF); + + SelectPolygonBeginType(RenderPolygon.NumberOfVertices); + for (i = 0; i < RenderPolygon.NumberOfVertices; i++) { + RENDERVERTEX *vertices = &renderVerticesPtr[i]; + + int x1, y1; + GLfloat x, y, z; + float rhw, zvalue; + + 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 0 + 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; + } +#endif + + x = x1; + y = y1; + + x = (x - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX; + y = -(y - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY; + + zvalue = vertices->Z+HeadUpDisplayZOffset; + z = 1.0 - 2*ZNear/zvalue; + +// zvalue = vertices->Z+HeadUpDisplayZOffset; +// zvalue = ((zvalue-ZNear)/zvalue); + + rhw = 1.0/(float)vertices->Z; + + glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A); + glVertex4f(x/rhw, y/rhw, z/rhw, 1/rhw); + } + glEnd(); +} + +void D3D_PredatorScreenInversionOverlay() +{ + CheckTranslucencyModeIsCorrect(TRANSLUCENCY_DARKENINGCOLOUR); + CheckBoundTextureIsCorrect(0); + glDepthFunc(GL_ALWAYS); + + SelectPolygonBeginType(3); /* triangles */ + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + glVertex3f(-1.0f, -1.0f, 1.0f); + glVertex3f( 1.0f, -1.0f, 1.0f); + glVertex3f(-1.0f, 1.0f, 1.0f); + + glVertex3f( 1.0f, -1.0f, 0.0f); + glVertex3f( 1.0f, 1.0f, 0.0f); + glVertex3f(-1.0f, 1.0f, 0.0f); + + glEnd(); + + glDepthFunc(GL_LEQUAL); +} diff --git a/src/stubs.c b/src/stubs.c index df4d37e..3b2e9db 100644 --- a/src/stubs.c +++ b/src/stubs.c @@ -517,16 +517,6 @@ void D3D_ScreenInversionOverlay() fprintf(stderr, "D3D_ScreenInversionOverlay()\n"); } -void D3D_PredatorThermalVisionPolygon_Output(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVerticesPtr) -{ - fprintf(stderr, "D3D_PredatorThermalVisionPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr); -} - -void D3D_PredatorScreenInversionOverlay() -{ - fprintf(stderr, "D3D_PredatorScreenInversionOverlay()\n"); -} - void D3D_PlayerOnFireOverlay() { fprintf(stderr, "D3D_PlayerOnFireOverlay()\n");