summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/avp/lighting.c35
-rw-r--r--src/avp/win95/gammacontrol.cpp49
-rw-r--r--src/main.c42
-rw-r--r--src/opengl.c58
-rw-r--r--src/stubs.c4
5 files changed, 84 insertions, 104 deletions
diff --git a/src/avp/lighting.c b/src/avp/lighting.c
index a98ec75..294d88b 100644
--- a/src/avp/lighting.c
+++ b/src/avp/lighting.c
@@ -47,11 +47,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->RedScale=255*256;
lightPtr->GreenScale=120*256;
lightPtr->BlueScale=0;
- #if PSX
- lightPtr->LightColour.r=255;
- lightPtr->LightColour.g=120;
- lightPtr->LightColour.b=0;
- #endif
break;
}
@@ -69,11 +64,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->RedScale=255*256;
lightPtr->GreenScale=120*256;
lightPtr->BlueScale=0;
- #if PSX
- lightPtr->LightColour.r=255;
- lightPtr->LightColour.g=120;
- lightPtr->LightColour.b=0;
- #endif
break;
}
@@ -99,11 +89,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->GreenScale=230*256;
lightPtr->BlueScale=200*256;
#endif
- #if PSX
- lightPtr->LightColour.r=255;
- lightPtr->LightColour.g=192;
- lightPtr->LightColour.b=128;
- #endif
break;
}
@@ -121,11 +106,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->RedScale=255*256;
lightPtr->GreenScale=32*256;
lightPtr->BlueScale=0;
- #if PSX
- lightPtr->LightColour.r=255;
- lightPtr->LightColour.g=32;
- lightPtr->LightColour.b=0;
- #endif
break;
}
case LFX_ROCKETJET:
@@ -142,11 +122,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->RedScale=255*256;
lightPtr->GreenScale=255*256;
lightPtr->BlueScale=128*256;
- #if PSX
- lightPtr->LightColour.r=255;
- lightPtr->LightColour.g=255;
- lightPtr->LightColour.b=128;
- #endif
break;
}
@@ -164,11 +139,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->RedScale=255*256;
lightPtr->GreenScale=200*256;
lightPtr->BlueScale=255*256;
- #if PSX
- lightPtr->LightColour.r=255;
- lightPtr->LightColour.g=64;
- lightPtr->LightColour.b=255;
- #endif
break;
}
@@ -186,11 +156,6 @@ void AddLightingEffectToObject(DISPLAYBLOCK *objectPtr, enum LIGHTING_EFFECTS_ID
lightPtr->RedScale=255*256;
lightPtr->GreenScale=64*256;
lightPtr->BlueScale=255*256;
- #if PSX
- lightPtr->LightColour.r=64;
- lightPtr->LightColour.g=64;
- lightPtr->LightColour.b=255;
- #endif
break;
}
diff --git a/src/avp/win95/gammacontrol.cpp b/src/avp/win95/gammacontrol.cpp
index dad5a99..1a1b1df 100644
--- a/src/avp/win95/gammacontrol.cpp
+++ b/src/avp/win95/gammacontrol.cpp
@@ -4,10 +4,8 @@ extern "C"
#include "3dc.h"
#include "module.h"
#include "inline.h"
-#include "d3dmacs.h"
-#include "GammaControl.h"
+#include "gammacontrol.h"
-extern LPDIRECTDRAWSURFACE lpDDSPrimary;
static int ActualGammaSetting;
int RequestedGammaSetting;
@@ -19,50 +17,9 @@ void InitialiseGammaSettings(int gamma)
RequestedGammaSetting = gamma;
UpdateGammaSettings();
}
-#if 0
-void UpdateGammaSettings(void)
-{
- LPDIRECTDRAWGAMMACONTROL handle=NULL;
- DDGAMMARAMP gammaValues;
-
- if (RequestedGammaSetting==ActualGammaSetting) return;
-
- lpDDSPrimary->QueryInterface(IID_IDirectDrawGammaControl,(LPVOID*)&handle);
- if(!handle)
- {
- return;
- }
-// handle->GetGammaRamp(0,&gammaValues);
- for (int i=0; i<=255; i++)
- {
- int u = ((i*65536)/255);
- int m = MUL_FIXED(u,u);
- int l = MUL_FIXED(2*u,ONE_FIXED-u);
- int a;
-
- a = m/256+MUL_FIXED(RequestedGammaSetting,l);
- if (a<0) a=0;
- if (a>255) a=255;
-
- gammaValues.red[i]=a*256;
- gammaValues.green[i]=a*256;
- gammaValues.blue[i]=a*256;
- }
-
- HRESULT result = handle->SetGammaRamp(0,&gammaValues);
-
- RELEASE(handle);
-
- ActualGammaSetting=RequestedGammaSetting;
-
-}
-#else
void UpdateGammaSettings(void)
{
- LPDIRECTDRAWGAMMACONTROL handle=NULL;
- DDGAMMARAMP gammaValues;
-
if (RequestedGammaSetting==ActualGammaSetting) return;
for (int i=0; i<=255; i++)
@@ -76,7 +33,6 @@ void UpdateGammaSettings(void)
a = m+MUL_FIXED(RequestedGammaSetting*256,l);
-
m = MUL_FIXED(a,a);
l = MUL_FIXED(2*a,ONE_FIXED-a);
@@ -91,6 +47,5 @@ void UpdateGammaSettings(void)
ActualGammaSetting=RequestedGammaSetting;
}
-#endif
-}; \ No newline at end of file
+};
diff --git a/src/main.c b/src/main.c
index 1bf390b..d99a495 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,6 +20,10 @@
#include "avp_userprofile.h"
#include "pldnet.h"
#include "cdtrackselection.h"
+#include "gammacontrol.h"
+
+#define MyWidth 1024
+#define MyHeight 768
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
@@ -51,13 +55,13 @@ int InitialiseWindowsSystem()
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) {
+ if (SDL_SetVideoMode(MyWidth, MyHeight, 0, SDL_OPENGL) == NULL) {
fprintf(stderr, "SDL SetVideoMode failed: %s\n", SDL_GetError());
SDL_Quit();
exit(EXIT_FAILURE);
}
- glViewport(0, 0, 640, 480);
+ glViewport(0, 0, MyWidth, MyHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -348,8 +352,9 @@ void InGameFlipBuffers()
void ThisFramesRenderingHasBegun()
{
- fprintf(stderr, "ThisFramesRenderingHasBegun()\n");
+/* fprintf(stderr, "ThisFramesRenderingHasBegun()\n"); */
+/* TODO: this should be in D3D_DrawBackdrop */
#if 1
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#endif
@@ -357,7 +362,11 @@ void ThisFramesRenderingHasBegun()
void ThisFramesRenderingHasFinished()
{
- fprintf(stderr, "ThisFramesRenderingHasFinished()\n");
+/* fprintf(stderr, "ThisFramesRenderingHasFinished()\n"); */
+
+/* This is where the queued drawing commands' execution takes place */
+
+ LightBlockDeallocation();
}
int ExitWindowsSystem()
@@ -397,6 +406,8 @@ int main(int argc, char *argv[])
InitialiseSystem();
InitialiseRenderer();
+ RequestedGammaSetting = 128;
+
/* InitOptionsMenu(); NOT YET */
// LoadDefaultPrimaryConfigs(); /* load the configs! yes! */
@@ -422,8 +433,11 @@ int main(int argc, char *argv[])
LoadSounds("PLAYER");
AvP.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */
+
+ AvP.PlayerType = I_Alien;
// 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);
// while(AvP_MainMenus()) {
@@ -431,19 +445,21 @@ int main(int argc, char *argv[])
d3d_overlay_ctrl.ctrl = OCCM_NORMAL;
/* this was in windows SetGameVideoMode: */
- ScreenDescriptorBlock.SDB_Width = 640;
- ScreenDescriptorBlock.SDB_Height = 480;
- ScreenDescriptorBlock.SDB_CentreX = 640/2;
- ScreenDescriptorBlock.SDB_CentreY = 480/2;
- ScreenDescriptorBlock.SDB_ProjX = 640/2;
- ScreenDescriptorBlock.SDB_ProjY = 480/2;
+ ScreenDescriptorBlock.SDB_Width = MyWidth;
+ ScreenDescriptorBlock.SDB_Height = MyHeight;
+ ScreenDescriptorBlock.SDB_CentreX = MyWidth/2;
+ ScreenDescriptorBlock.SDB_CentreY = MyHeight/2;
+ ScreenDescriptorBlock.SDB_ProjX = MyWidth/2;
+ ScreenDescriptorBlock.SDB_ProjY = MyHeight/2;
ScreenDescriptorBlock.SDB_ClipLeft = 0;
- ScreenDescriptorBlock.SDB_ClipRight = 640;
+ ScreenDescriptorBlock.SDB_ClipRight = MyWidth;
ScreenDescriptorBlock.SDB_ClipUp = 0;
- ScreenDescriptorBlock.SDB_ClipDown = 480;
+ ScreenDescriptorBlock.SDB_ClipDown = MyHeight;
// GetCorrectDirectDrawObject();
+ InitialiseGammaSettings(RequestedGammaSetting);
+
start_of_loaded_shapes = load_precompiled_shapes();
InitCharacter();
diff --git a/src/opengl.c b/src/opengl.c
index ea3855d..f670027 100644
--- a/src/opengl.c
+++ b/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
}
diff --git a/src/stubs.c b/src/stubs.c
index 756f2a9..ce16084 100644
--- a/src/stubs.c
+++ b/src/stubs.c
@@ -40,10 +40,6 @@ void Draw_Item_2dTexturePolygon(int *itemptr)
}
}
-
-/* gammacontrol.cpp */
-int RequestedGammaSetting;
-
/* indexfnt.cpp */
void INDEXFNT_PFLoadHook(FontIndex I_Font_New, PFFONT *pffont_New)