initial CGraphics class

This commit is contained in:
Jack Andersen 2016-02-11 16:36:34 -10:00
parent 93f8ae8905
commit 43a818d1a3
6 changed files with 122 additions and 3 deletions

36
Runtime/CGraphics.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "CGraphics.hpp"
#include <Math.hpp>
namespace Retro
{
u32 CGraphics::g_NumLightsActive = 0;
ERglLight CGraphics::g_LightActive = ERglLight::None;
ERglLight CGraphics::g_LightsWereOn = ERglLight::None;
void CGraphics::DisableAllLights()
{
g_NumLightsActive = 0;
g_LightActive = ERglLight::None;
// TODO: turn lights off for real
}
void CGraphics::EnableLight(ERglLight light)
{
if ((light & g_LightActive) == ERglLight::None)
{
g_LightActive |= light;
++g_NumLightsActive;
// TODO: turn light on for real
}
g_LightsWereOn = g_LightActive;
}
void CGraphics::SetLightState(ERglLight lightState)
{
// TODO: set state for real
g_LightActive = lightState;
g_NumLightsActive = Zeus::Math::PopCount(lightState);
}
}

36
Runtime/CGraphics.hpp Normal file
View File

@ -0,0 +1,36 @@
#ifndef __RETRO_CGRAPHICS_HPP__
#define __RETRO_CGRAPHICS_HPP__
#include "RetroTypes.hpp"
namespace Retro
{
enum class ERglLight : u8
{
None = 0,
Zero = 1,
One = 1 << 1,
Two = 1 << 2,
Three = 1 << 3,
Four = 1 << 4,
Five = 1 << 5,
Six = 1 << 6,
Seven = 1 << 7
};
ENABLE_BITWISE_ENUM(ERglLight)
class CGraphics
{
public:
static u32 g_NumLightsActive;
static ERglLight g_LightActive;
static ERglLight g_LightsWereOn;
static void DisableAllLights();
static void EnableLight(ERglLight light);
static void SetLightState(ERglLight lightState);
};
}
#endif // __RETRO_CGRAPHICS_HPP__

View File

@ -67,6 +67,7 @@ add_library(RuntimeCommon
CPlayMovieBase.hpp
CMoviePlayer.hpp CMoviePlayer.cpp
CGameDebug.hpp CGameDebug.cpp
CGraphics.hpp CGraphics.cpp
rstl.hpp rstl.cpp
GameGlobalObjects.hpp
RetroTypes.hpp

View File

@ -1,6 +1,5 @@
#include "CElementGen.hpp"
#include "CGenDescription.hpp"
#include "CLight.hpp"
#include "CParticleGlobals.hpp"
#include "CParticleSwoosh.hpp"
#include "CParticleElectric.hpp"
@ -925,6 +924,48 @@ u32 CElementGen::GetSystemCount()
}
void CElementGen::Render()
{
CGenDescription* desc = x1c_genDesc.CastObj<CGenDescription>();
x22c_backupLightActive = CGraphics::g_LightActive;
CGraphics::DisableAllLights();
for (std::unique_ptr<CElementGen>& child : x234_activePartChildren)
child->Render();
if (x214_PSLT <= x50_curFrame)
for (std::unique_ptr<CElementGen>& child : x248_finishPartChildren)
child->Render();
for (std::unique_ptr<CParticleSwoosh>& child : x260_swhcChildren)
child->Render();
for (std::unique_ptr<CParticleElectric>& child : x280_elscChildren)
child->Render();
if (x2c_particleLists.size())
{
SParticleModel& pmdl = desc->x5c_PMDL;
if (pmdl.m_found || desc->x45_24_PMUS)
RenderModels();
if (x225_26_LINE)
RenderLines();
else
RenderParticles();
}
}
void CElementGen::RenderModels()
{
}
void CElementGen::RenderLines()
{
}
void CElementGen::RenderParticles()
{
}

View File

@ -8,6 +8,7 @@
#include "CAABox.hpp"
#include "CToken.hpp"
#include "CLight.hpp"
#include "CGraphics.hpp"
#include "CRandom16.hpp"
namespace Retro
@ -110,7 +111,7 @@ protected:
bool x225_29 = false;
bool x226;
int x228_MBSP;
bool x22c = false;
ERglLight x22c_backupLightActive = ERglLight::None;
CRandom16 x230_randState;
std::vector<std::unique_ptr<CElementGen>> x234_activePartChildren;
int x244_CSSD = 0;
@ -183,6 +184,10 @@ public:
u32 GetParticleCountAllInternal() const;
u32 GetParticleCountAll() const {return x20c_recursiveParticleCount;}
void RenderModels();
void RenderLines();
void RenderParticles();
virtual void Update(double);
bool InternalUpdate(double);
virtual void Render();

@ -1 +1 @@
Subproject commit 831be46890a3c97b7dde4fa777ddba7a0826c98b
Subproject commit d6f77c2afe63259dfd23ff80574ebacfc13cca4d