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
2
Makefile
2
Makefile
|
@ -14,7 +14,7 @@ ROOT = main.c mathline.c math.asm net.c render.c opengl.c winapi.c stubs.c stubs
|
|||
AVP = ai_sight.c avpview.c bh_agun.c bh_ais.c bh_alien.c bh_binsw.c bh_cable.c bh_corpse.c bh_deathvol.c bh_debri.c bh_dummy.c bh_fan.c bh_far.c bh_fhug.c bh_gener.c bh_ldoor.c bh_lift.c bh_light.c bh_lnksw.c bh_ltfx.c bh_marin.c bh_mission.c bh_near.c bh_pargen.c bh_plachier.c bh_plift.c bh_pred.c bh_queen.c bh_rubberduck.c bh_selfdest.c bh_snds.c bh_spcl.c bh_swdor.c bh_track.c bh_types.c bh_videoscreen.c bh_waypt.c bh_weap.c bh_xeno.c bonusabilities.c cconvars.cpp cdtrackselection.cpp cheatmodes.c comp_map.c comp_shp.c consolelog.cpp davehook.cpp deaths.c decal.c detaillevels.c dynamics.c dynblock.c equipmnt.c equiputl.cpp extents.c game.c game_statistics.c gamecmds.cpp gameflow.c gamevars.cpp hmodel.c hud.c inventry.c language.c lighting.c load_shp.c los.c maps.c mempool.c messagehistory.c missions.cpp movement.c paintball.c particle.c pfarlocs.c pheromon.c player.c pmove.c psnd.c psndproj.c pvisible.c savegame.c scream.cpp secstats.c sfx.c stratdef.c targeting.c track.c triggers.c weapons.c
|
||||
SHAPES = cube.c
|
||||
SUPPORT = consbind.cpp consbtch.cpp coordstr.cpp daemon.cpp r2base.cpp r2pos666.cpp reflist.cpp refobj.cpp scstring.cpp strtab.cpp strutil.c trig666.cpp wrapstr.cpp
|
||||
AVPWIN95 = avpchunk.cpp cheat.c chtcodes.cpp d3d_hud.cpp ddplat.cpp endianio.c ffread.cpp ffstdio.cpp gflwplat.c hierplace.cpp iofocus.cpp jsndsup.cpp kzsort.c langplat.c modcmds.cpp npcsetup.cpp objsetup.cpp pathchnk.cpp platsup.c pldghost.c projload.cpp scrshot.cpp strachnk.cpp system.c usr_io.c vision.c
|
||||
AVPWIN95 = avpchunk.cpp cheat.c chtcodes.cpp d3d_hud.cpp ddplat.cpp endianio.c ffread.cpp ffstdio.cpp gammacontrol.cpp gflwplat.c hierplace.cpp iofocus.cpp jsndsup.cpp kzsort.c langplat.c modcmds.cpp npcsetup.cpp objsetup.cpp pathchnk.cpp platsup.c pldghost.c projload.cpp scrshot.cpp strachnk.cpp system.c usr_io.c vision.c
|
||||
FRONTEND = avp_envinfo.c avp_intro.cpp avp_menudata.c
|
||||
GADGETS = ahudgadg.cpp conscmnd.cpp conssym.cpp consvar.cpp gadget.cpp hudgadg.cpp rootgadg.cpp t_ingadg.cpp teletype.cpp textexp.cpp textin.cpp trepgadg.cpp
|
||||
WIN95 = animchnk.cpp animobs.cpp awtexld.cpp awbmpld.cpp awiffld.cpp awpnmld.cpp bmpnames.cpp chnkload.cpp chnktexi.cpp chnktype.cpp chunk.cpp chunkpal.cpp db.c debuglog.cpp dummyobjectchunk.cpp enumchnk.cpp enumsch.cpp envchunk.cpp fail.c fragchnk.cpp gsprchnk.cpp hierchnk.cpp huffman.cpp iff.cpp iff_ilbm.cpp ilbm_ext.cpp io.c list_tem.cpp ltchunk.cpp media.cpp mishchnk.cpp obchunk.cpp oechunk.cpp our_mem.c plat_shp.c plspecfn.c shpchunk.cpp sndchunk.cpp sprchunk.cpp string.cpp texio.c toolchnk.cpp txioctrl.cpp wpchunk.cpp zsp.cpp
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
};
|
||||
};
|
||||
|
|
42
src/main.c
42
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();
|
||||
|
|
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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue