genesis.h and engine.h
add
Code: Select all
GENESISAPI geBoolean geEngine_SetClearColor(geEngine *Engine, geFloat r, geFloat g, geFloat b);
in the geEngine struct add
Code: Select all
geFloat ClearR;
geFloat ClearG;
geFloat ClearB;
add
Code: Select all
//=====================================================================================
// geEngine_UpdateClearColor
//=====================================================================================
static geBoolean geEngine_UpdateClearColor(geEngine *Engine)
{
if(Engine->DriverInfo.RDriver)
{
return Engine->DriverInfo.RDriver->SetClearColor(Engine->ClearR,
Engine->ClearG,
Engine->ClearB);
}
return GE_TRUE;
}
//=====================================================================================
// geEngine_SetClearColor
//=====================================================================================
GENESISAPI geBoolean geEngine_SetClearColor(geEngine *Engine, geFloat r, geFloat g, geFloat b)
{
Engine->ClearR = r;
Engine->ClearG = g;
Engine->ClearB = b;
return geEngine_UpdateClearColor(Engine);
}
dcommon.h
add
Code: Select all
typedef geBoolean DRIVERCC DRV_SET_CLEARCOLOR(geFloat r, geFloat g, geFloat b);
Code: Select all
DRV_SET_CLEARCOLOR *SetClearColor;
DX7 driver:
D3d_main.h
in the App_Info struct add
Code: Select all
float ClearR;
float ClearG;
float ClearB;
Code: Select all
geBoolean DRIVERCC D3DMain_SetClearColor(float r, float g, float b);
D3d_main.cpp
in BOOL Main_ClearBackBuffer(BOOL Clear, BOOL ClearZ, BOOL ClearStencil) change
Code: Select all
if (AppInfo.FogEnable)
LastError = AppInfo.lpD3DDevice->Clear( 1, &Dummy, ClearFlags, ((DWORD)AppInfo.FogR<<16)|((DWORD)AppInfo.FogG<<8)|(DWORD)AppInfo.FogB, 1.0f, 0L );
else
LastError = AppInfo.lpD3DDevice->Clear( 1, &Dummy, ClearFlags, ((DWORD)AppInfo.ClearR<<16)|((DWORD)AppInfo.ClearG<<8)|(DWORD)AppInfo.ClearB, 1.0f, 0L );
change
Code: Select all
geBoolean DRIVERCC D3DMain_SetFogEnable(geBoolean Enable, float r, float g, float b, float Start, float End)
{
/* 07/16/2000 Wendell Buckner
Convert to Directx7...
D3DMATERIAL Material; */
D3DMATERIAL7 Material;
AppInfo.FogEnable = Enable;
AppInfo.FogR = r;
AppInfo.FogG = g;
AppInfo.FogB = b;
AppInfo.FogStart = Start;
AppInfo.FogEnd = End;
// Fill in the material with the data
/* 07/16/2000 Wendell Buckner
Convert to Directx7...
memset(&Material, 0, sizeof(D3DMATERIAL));
Material.dwSize = sizeof(D3DMATERIAL); */
memset(&Material, 0, sizeof(D3DMATERIAL7));
if (Enable)
{
Material.dcvDiffuse.r = Material.dcvAmbient.r = r/255.0f;
Material.dcvDiffuse.g = Material.dcvAmbient.g = g/255.0f;
Material.dcvDiffuse.b = Material.dcvAmbient.b = b/255.0f;
}
else
{
Material.dcvDiffuse.r = Material.dcvAmbient.r = AppInfo.ClearR/255.0f;
Material.dcvDiffuse.g = Material.dcvAmbient.g = AppInfo.ClearG/255.0f;
Material.dcvDiffuse.b = Material.dcvAmbient.b = AppInfo.ClearB/255.0f;
}
/* 07/16/2000 Wendell Buckner
Convert to Directx7...
Material.dwRampSize = 16L; // A default ramp size */
AppInfo.BackgroundMaterial->SetMaterial(&Material);
return GE_TRUE;
}
Code: Select all
//========================================================================================================
// D3DMain_SetClearColor
//========================================================================================================
geBoolean DRIVERCC D3DMain_SetClearColor(float r, float g, float b)
{
D3DMATERIAL7 Material;
AppInfo.ClearR = r;
AppInfo.ClearG = g;
AppInfo.ClearB = b;
// Fill in the material with the data
memset(&Material, 0, sizeof(D3DMATERIAL7));
Material.dcvDiffuse.r = Material.dcvAmbient.r = r/255.0f;
Material.dcvDiffuse.g = Material.dcvAmbient.g = g/255.0f;
Material.dcvDiffuse.b = Material.dcvAmbient.b = b/255.0f;
AppInfo.BackgroundMaterial->SetMaterial(&Material);
return GE_TRUE;
}
Scene.cpp
in BOOL DRIVERCC BeginScene(BOOL Clear, BOOL ClearZ, BOOL ClearStencil, RECT *WorldRect) change
Code: Select all
if (AppInfo.FogEnable)
{
D3DFogEnable ( AppInfo.FogEnable, ((DWORD)AppInfo.FogR<<16)|((DWORD)AppInfo.FogG<<8)|(DWORD)AppInfo.FogB );
}
else
{
D3DFogEnable ( AppInfo.FogEnable, ((DWORD)AppInfo.ClearR<<16)|((DWORD)AppInfo.ClearG<<8)|(DWORD)AppInfo.ClearB );
}
D3ddrv7x.cpp
in the DRV_Driver D3DDRV initialization after D3DMain_SetFogEnable, add
Code: Select all
D3DMain_SetClearColor,
changes in the old d3d driver are pretty much the same
OpenGL driver
OglDrv.c
to the globals add
Code: Select all
GLfloat ClearColor[3];
in the DRV_Driver OGLDRV initialization after SetFogEnable, add
Code: Select all
SetClearColor,
change
Code: Select all
else
{
glDisable(GL_FOG);
FogEnabled = GE_FALSE;
glClearColor(ClearColor[0], ClearColor[1], ClearColor[2], 1.0);
}
add
Code: Select all
geBoolean DRIVERCC SetClearColor(float r, float g, float b)
{
ClearColor[0] = (GLfloat)r/255.0f;
ClearColor[1] = (GLfloat)g/255.0f;
ClearColor[2] = (GLfloat)b/255.0f;
glClearColor(ClearColor[0], ClearColor[1], ClearColor[2], 1.0);
return GE_TRUE;
}
Code: Select all
ClearColor[0] = ClearColor[1] = ClearColor[2] = 0.f;