Convert fog code to PIELIGHT

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2888 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-11-25 23:06:24 +00:00
parent 7361191aa5
commit af40ffa1cb
13 changed files with 57 additions and 76 deletions

View File

@ -27,11 +27,15 @@ void pie_SetTranslucencyMode(TRANSLUCENCY_MODE transMode);
void pie_SetDefaultStates(void)//Sets all states void pie_SetDefaultStates(void)//Sets all states
{ {
PIELIGHT black;
//fog off //fog off
rendStates.fogEnabled = FALSE;// enable fog before renderer rendStates.fogEnabled = FALSE;// enable fog before renderer
rendStates.fog = FALSE;//to force reset to false rendStates.fog = FALSE;//to force reset to false
pie_SetFogStatus(FALSE); pie_SetFogStatus(FALSE);
pie_SetFogColour(0x00000000);//nicks colour black.argb = 0;
black.byte.a = 255;
pie_SetFogColour(black);//nicks colour
//depth Buffer on //depth Buffer on
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
@ -87,13 +91,22 @@ void pie_EnableFog(BOOL val)
rendStates.fogEnabled = val; rendStates.fogEnabled = val;
if (val == TRUE) if (val == TRUE)
{ {
pie_SetFogColour(0x00B08f5f);//nicks colour PIELIGHT nickscolour;
nickscolour.byte.r = 0xB0;
nickscolour.byte.g = 0x08;
nickscolour.byte.b = 0x5f;
nickscolour.byte.a = 0xff;
pie_SetFogColour(nickscolour); // nicks colour
} }
else else
{ {
pie_SetFogColour(0x00000000);//clear background to black PIELIGHT black;
}
black.argb = 0;
black.byte.a = 255;
pie_SetFogColour(black); // clear background to black
}
} }
} }
@ -115,24 +128,21 @@ BOOL pie_GetFogStatus(void)
return rendStates.fog; return rendStates.fog;
} }
void pie_SetFogColour(UDWORD colour) void pie_SetFogColour(PIELIGHT colour)
{ {
UDWORD grey; PIELIGHT grey;
if (rendStates.fogCap == FOG_CAP_GREY) if (rendStates.fogCap == FOG_CAP_GREY)
{ {
grey = colour & 0xff; grey.byte.r = (colour.byte.r + colour.byte.b + colour.byte.g) / 3;
colour >>= 8; grey.byte.g = grey.byte.r;
grey += (colour & 0xff); grey.byte.b = grey.byte.r;
colour >>= 8; grey.byte.a = 255;
grey += (colour & 0xff);
grey /= 3;
grey &= 0xff;//check only
colour = grey + (grey<<8) + (grey<<16);
rendStates.fogColour = colour; rendStates.fogColour = colour;
} }
else if (rendStates.fogCap == FOG_CAP_NO) else if (rendStates.fogCap == FOG_CAP_NO)
{ {
rendStates.fogColour = 0; rendStates.fogColour.argb = 0;
} }
else else
{ {
@ -140,7 +150,7 @@ void pie_SetFogColour(UDWORD colour)
} }
} }
UDWORD pie_GetFogColour(void) PIELIGHT pie_GetFogColour(void)
{ {
return rendStates.fogColour; return rendStates.fogColour;
} }

View File

@ -97,7 +97,7 @@ typedef struct RENDER_STATE
FOG_CAP fogCap; FOG_CAP fogCap;
BOOL fogEnabled; BOOL fogEnabled;
BOOL fog; BOOL fog;
UDWORD fogColour; PIELIGHT fogColour;
SDWORD texPage; SDWORD texPage;
REND_MODE rendMode; REND_MODE rendMode;
BOOL keyingOn; BOOL keyingOn;
@ -134,8 +134,8 @@ extern BOOL pie_GetFogEnabled(void);
//fog currently on //fog currently on
extern void pie_SetFogStatus(BOOL val); extern void pie_SetFogStatus(BOOL val);
extern BOOL pie_GetFogStatus(void); extern BOOL pie_GetFogStatus(void);
extern void pie_SetFogColour(UDWORD colour); extern void pie_SetFogColour(PIELIGHT colour);
extern UDWORD pie_GetFogColour(void) WZ_DECL_PURE; extern PIELIGHT pie_GetFogColour(void) WZ_DECL_PURE;
extern void pie_UpdateFogDistance(float begin, float end); extern void pie_UpdateFogDistance(float begin, float end);
//render states //render states
extern void pie_SetTexturePage(SDWORD num); extern void pie_SetTexturePage(SDWORD num);

View File

@ -183,9 +183,8 @@ void pie_DrawSkybox(float scale, int u, int v, int w, int h)
/// Draws a fog colored box which is wider at the top /// Draws a fog colored box which is wider at the top
void pie_DrawFogBox(float left, float right, float front, float back, float height, float wider) void pie_DrawFogBox(float left, float right, float front, float back, float height, float wider)
{ {
PIELIGHT fog_colour; PIELIGHT fog_colour = pie_GetFogColour();
fog_colour.argb = pie_GetFogColour();
glColor4ub(fog_colour.byte.r,fog_colour.byte.g,fog_colour.byte.b,0xFF); glColor4ub(fog_colour.byte.r,fog_colour.byte.g,fog_colour.byte.b,0xFF);
pie_SetRendMode(REND_FLAT); pie_SetRendMode(REND_FLAT);

View File

@ -105,7 +105,6 @@ void pie_UpdateFogDistance(float begin, float end)
void pie_SetFogStatus(BOOL val) void pie_SetFogStatus(BOOL val)
{ {
PIELIGHT fog;
float fog_colour[4]; float fog_colour[4];
if (rendStates.fogEnabled) if (rendStates.fogEnabled)
@ -115,7 +114,8 @@ void pie_SetFogStatus(BOOL val)
{ {
rendStates.fog = val; rendStates.fog = val;
if (rendStates.fog) { if (rendStates.fog) {
fog.argb = pie_GetFogColour(); PIELIGHT fog = pie_GetFogColour();
fog_colour[0] = fog.byte.r/255.0f; fog_colour[0] = fog.byte.r/255.0f;
fog_colour[1] = fog.byte.g/255.0f; fog_colour[1] = fog.byte.g/255.0f;
fog_colour[2] = fog.byte.b/255.0f; fog_colour[2] = fog.byte.b/255.0f;

View File

@ -624,7 +624,7 @@ static void drawTiles(iView *camera, iView *player)
if (pie_GetFogEnabled()) if (pie_GetFogEnabled())
{ {
tileScreenInfo[i][j].light.argb = 0xff030303; tileScreenInfo[i][j].light.argb = 0xff030303;
tileScreenInfo[i][j].specular.argb = pie_GetFogColour(); tileScreenInfo[i][j].specular = pie_GetFogColour();
} }
else else
{ {

View File

@ -2477,7 +2477,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
fogStatus = saveGameData.fogState; fogStatus = saveGameData.fogState;
fogStatus &= FOG_FLAGS; fogStatus &= FOG_FLAGS;
} }
pie_SetFogColour(saveGameData.fogColour); pie_SetFogColour((PIELIGHT)saveGameData.fogColour);
} }
if (saveGameVersion >= VERSION_19)//V21 if (saveGameVersion >= VERSION_19)//V21
{ {
@ -4681,7 +4681,7 @@ bool gameLoadV(PHYSFS_file* fileHandle, unsigned int version)
fogStatus = saveGameData.fogState; fogStatus = saveGameData.fogState;
fogStatus &= FOG_FLAGS; fogStatus &= FOG_FLAGS;
} }
pie_SetFogColour(saveGameData.fogColour); pie_SetFogColour((PIELIGHT)saveGameData.fogColour);
} }
if (version >= VERSION_17) if (version >= VERSION_17)
@ -5004,7 +5004,7 @@ static bool writeGameFile(const char* fileName, SDWORD saveType)
saveGame.offWorldKeepLists = offWorldKeepLists; saveGame.offWorldKeepLists = offWorldKeepLists;
saveGame.RubbleTile = getRubbleTileNum(); saveGame.RubbleTile = getRubbleTileNum();
saveGame.WaterTile = getWaterTileNum(); saveGame.WaterTile = getWaterTileNum();
saveGame.fogColour = pie_GetFogColour(); saveGame.fogColour = pie_GetFogColour().argb;
saveGame.fogState = fogStatus; saveGame.fogState = fogStatus;
if(pie_GetFogEnabled()) if(pie_GetFogEnabled())
{ {

View File

@ -515,38 +515,8 @@ extern void kf_ToggleDistanceFog( void )
} }
void kf_ToggleFogColour( void )
{
fogCol++;
if (fogCol>4)
fogCol = 0;
switch(fogCol)
{
case 1:
pie_SetFogColour(0x00c9920f);//nicks colour Urban
break;
case 2:
pie_SetFogColour(0x00b6e1ec);//nicks colour Rockies 182,225,236
break;
case 3:
pie_SetFogColour(0x00101040);//haze
break;
case 4:
pie_SetFogColour(0x00000000);//black
break;
case 0:
default:
pie_SetFogColour(0x00B08f5f);//nicks colour Arizona
//pie_SetFogColour(0x0078684f);//(nicks colour + 404040)/2
break;
}
}
void kf_ToggleFog( void ) void kf_ToggleFog( void )
{ {
static BOOL fogEnabled = FALSE; static BOOL fogEnabled = FALSE;
if (fogEnabled) if (fogEnabled)
@ -554,15 +524,14 @@ void kf_ToggleFog( void )
fogEnabled = FALSE; fogEnabled = FALSE;
pie_SetFogStatus(FALSE); pie_SetFogStatus(FALSE);
pie_EnableFog(fogEnabled); pie_EnableFog(fogEnabled);
// addConsoleMessage("Fog Off",DEFAULT_JUSTIFY); addConsoleMessage("Fog Off", DEFAULT_JUSTIFY);
} }
else else
{ {
fogEnabled = TRUE; fogEnabled = TRUE;
pie_EnableFog(fogEnabled); pie_EnableFog(fogEnabled);
// addConsoleMessage("Fog On",DEFAULT_JUSTIFY); addConsoleMessage("Fog On", DEFAULT_JUSTIFY);
} }
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@ -39,7 +39,6 @@ extern void kf_ToggleWidgets( void );
extern void kf_ToggleBackgroundFog( void ); extern void kf_ToggleBackgroundFog( void );
extern void kf_ToggleDistanceFog( void ); extern void kf_ToggleDistanceFog( void );
extern void kf_ToggleMistFog( void ); extern void kf_ToggleMistFog( void );
extern void kf_ToggleFogColour( void );
extern void kf_ToggleFog( void ); extern void kf_ToggleFog( void );
extern void kf_ToggleShadows( void ); extern void kf_ToggleShadows( void );
extern void kf_ToggleCamera( void ); extern void kf_ToggleCamera( void );

View File

@ -228,7 +228,7 @@ _keymapsave keyMapSaveTable[] =
kf_SelectGrouping_0, kf_SelectGrouping_0,
kf_SelectCommander_0, kf_SelectCommander_0,
kf_NOOP, // unused kf_NOOP, // unused
kf_ToggleFogColour, kf_NOOP, // unused
kf_AddMissionOffWorld, kf_AddMissionOffWorld,
kf_KillSelected, kf_KillSelected,
kf_ShowMappings, kf_ShowMappings,
@ -430,7 +430,7 @@ void keyInitMappings( BOOL bForceDefaults )
keyAddMapping(KEYMAP_ASSIGNABLE,KEY_IGNORE,(KEY_CODE)KEY_MAXSCAN,KEYMAP_PRESSED,kf_ToggleReopenBuildMenu,_("Toggle reopening the build menu")); keyAddMapping(KEYMAP_ASSIGNABLE,KEY_IGNORE,(KEY_CODE)KEY_MAXSCAN,KEYMAP_PRESSED,kf_ToggleReopenBuildMenu,_("Toggle reopening the build menu"));
// NOTE THIS!!!!!!! // NOTE THIS!!!!!!!
// available: ctrl+e, ctrl+m, ctrl+k // available: ctrl+e, ctrl+m, ctrl+k, ctrl+l
keyAddMapping(KEYMAP___HIDE,KEY_LSHIFT,KEY_BACKSPACE,KEYMAP_PRESSED,kf_ToggleDebugMappings, "TOGGLE Debug Mappings"); keyAddMapping(KEYMAP___HIDE,KEY_LSHIFT,KEY_BACKSPACE,KEYMAP_PRESSED,kf_ToggleDebugMappings, "TOGGLE Debug Mappings");
keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_M,KEYMAP_PRESSED,kf_ShowMappings, "Show all keyboard mappings - use pause!"); keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_M,KEYMAP_PRESSED,kf_ShowMappings, "Show all keyboard mappings - use pause!");
keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_V,KEYMAP_PRESSED,kf_ToggleVisibility, "Toggle visibility"); keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_V,KEYMAP_PRESSED,kf_ToggleVisibility, "Toggle visibility");
@ -439,7 +439,6 @@ void keyInitMappings( BOOL bForceDefaults )
keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_Y,KEYMAP_PRESSED,kf_ToggleDemoMode, "Toggles on/off DEMO Mode"); keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_Y,KEYMAP_PRESSED,kf_ToggleDemoMode, "Toggles on/off DEMO Mode");
keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_B,KEYMAP_PRESSED,kf_EndMissionOffWorld, "End Mission"); keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_B,KEYMAP_PRESSED,kf_EndMissionOffWorld, "End Mission");
keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_J,KEYMAP_PRESSED,kf_ToggleFog, "Toggles All fog"); keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_J,KEYMAP_PRESSED,kf_ToggleFog, "Toggles All fog");
keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_L,KEYMAP_PRESSED,kf_ToggleFogColour, "Toggle Fog Colour Fog");
keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_Q,KEYMAP_PRESSED,kf_ToggleWeather, "Trigger some weather"); keyAddMapping(KEYMAP__DEBUG,KEY_LCTRL,KEY_Q,KEYMAP_PRESSED,kf_ToggleWeather, "Trigger some weather");
keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_K,KEYMAP_PRESSED,kf_TriFlip, "Flip terrain triangle"); keyAddMapping(KEYMAP__DEBUG,KEY_IGNORE,KEY_K,KEYMAP_PRESSED,kf_TriFlip, "Flip terrain triangle");

View File

@ -704,7 +704,7 @@ UDWORD lightDoFogAndIllumination(UBYTE brightness, SDWORD dx, SDWORD dz, UDWORD*
{ {
if (pSpecular != NULL) if (pSpecular != NULL)
{ {
fogColour.argb = pie_GetFogColour(); fogColour = pie_GetFogColour();
specular.byte.a = (UBYTE)fog; specular.byte.a = (UBYTE)fog;
specular.byte.r = pie_ByteScale((UBYTE)fog, fogColour.byte.r); specular.byte.r = pie_ByteScale((UBYTE)fog, fogColour.byte.r);
specular.byte.g = pie_ByteScale((UBYTE)fog, fogColour.byte.g); specular.byte.g = pie_ByteScale((UBYTE)fog, fogColour.byte.g);

View File

@ -155,9 +155,13 @@ GAMECODE gameLoop(void)
clearMode = CLEAR_FOG; clearMode = CLEAR_FOG;
if (!war_GetFog()) if (!war_GetFog())
{ {
PIELIGHT black;
// set the fog color to black (RGB) // set the fog color to black (RGB)
// the fogbox will get this color // the fogbox will get this color
pie_SetFogColour(0x000000); black.argb = 0;
black.byte.a = 255;
pie_SetFogColour(black);
} }
if(getDrawShadows()) if(getDrawShadows())
{ {

View File

@ -3927,22 +3927,19 @@ BOOL scrSetDepthFog(void)
BOOL scrSetFogColour(void) BOOL scrSetFogColour(void)
{ {
SDWORD red,green,blue; SDWORD red,green,blue;
SDWORD scrFogColour; PIELIGHT scrFogColour;
if (!stackPopParams(3, VAL_INT, &red, VAL_INT, &green, VAL_INT, &blue)) if (!stackPopParams(3, VAL_INT, &red, VAL_INT, &green, VAL_INT, &blue))
{ {
return FALSE; return FALSE;
} }
scrFogColour.byte.r = red;
scrFogColour.byte.g = green;
scrFogColour.byte.b = blue;
scrFogColour.byte.a = 255;
// if (pie_GetRenderEngine() == ENGINE_GLIDE) pie_SetFogColour(scrFogColour);
// {
red &= 0xff;
green &= 0xff;
blue &= 0xff;
scrFogColour = ((red << 16) + (green << 8) + blue);
pie_SetFogColour(scrFogColour);
// }
return TRUE; return TRUE;
} }

View File

@ -133,8 +133,12 @@ void war_SetFog(BOOL val)
} }
else else
{ {
PIELIGHT black;
setRevealStatus(TRUE); setRevealStatus(TRUE);
pie_SetFogColour(0); black.argb = 0;
black.byte.a = 255;
pie_SetFogColour(black);
} }
} }