Skip to content

Commit

Permalink
constness refactor in renderpath, gui and others
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Mar 9, 2019
1 parent 41cbb43 commit 39eb173
Show file tree
Hide file tree
Showing 31 changed files with 117 additions and 163 deletions.
8 changes: 4 additions & 4 deletions Editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ void EditorLoadingScreen::Load()

__super::Load();
}
void EditorLoadingScreen::Compose()
void EditorLoadingScreen::Update(float dt)
{
font.params.posX = (int)(wiRenderer::GetDevice()->GetScreenWidth()*0.5f);
font.params.posY = (int)(wiRenderer::GetDevice()->GetScreenHeight()*0.5f);
sprite.params.pos = XMFLOAT3(wiRenderer::GetDevice()->GetScreenWidth()*0.5f, wiRenderer::GetDevice()->GetScreenHeight()*0.5f - font.textHeight(), 0);

__super::Compose();
__super::Update(dt);
}
void EditorLoadingScreen::Unload()
{
Expand Down Expand Up @@ -1355,7 +1355,7 @@ void EditorComponent::Update(float dt)

renderPath->Update(dt);
}
void EditorComponent::Render()
void EditorComponent::Render() const
{
Scene& scene = wiRenderer::GetScene();

Expand Down Expand Up @@ -1471,7 +1471,7 @@ void EditorComponent::Render()
__super::Render();

}
void EditorComponent::Compose()
void EditorComponent::Compose() const
{
renderPath->Compose();

Expand Down
6 changes: 3 additions & 3 deletions Editor/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EditorLoadingScreen : public LoadingScreen
wiFont font;
public:
void Load() override;
void Compose() override;
void Update(float dt) override;
void Unload() override;
};

Expand Down Expand Up @@ -71,8 +71,8 @@ class EditorComponent : public RenderPath2D
void Start() override;
void FixedUpdate() override;
void Update(float dt) override;
void Render() override;
void Compose() override;
void Render() const override;
void Compose() const override;
void Unload() override;


Expand Down
2 changes: 1 addition & 1 deletion Editor/Translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void Translator::Update()

prevPointer = pointer;
}
void Translator::Draw(const CameraComponent& camera, GRAPHICSTHREAD threadID)
void Translator::Draw(const CameraComponent& camera, GRAPHICSTHREAD threadID) const
{
Scene& scene = wiRenderer::GetScene();

Expand Down
2 changes: 1 addition & 1 deletion Editor/Translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Translator
~Translator();

void Update();
void Draw(const wiSceneSystem::CameraComponent& camera, GRAPHICSTHREAD threadID);
void Draw(const wiSceneSystem::CameraComponent& camera, GRAPHICSTHREAD threadID) const;

wiECS::Entity entityID = wiECS::INVALID_ENTITY;

Expand Down
4 changes: 2 additions & 2 deletions WickedEngine/RenderPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class RenderPath
virtual void Update(float dt);
// Render to layers, rendertargets, etc
// This will be rendered offscreen
virtual void Render() {}
virtual void Render() const {}
// Compose the rendered layers (for example blend the layers together as Images)
// This will be rendered to the backbuffer
virtual void Compose() {}
virtual void Compose() const {}

inline uint32_t getLayerMask() const { return layerMask; }
inline void setlayerMask(uint32_t value) { layerMask = value; }
Expand Down
4 changes: 2 additions & 2 deletions WickedEngine/RenderPath2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void RenderPath2D::FixedUpdate()

RenderPath::FixedUpdate();
}
void RenderPath2D::Render()
void RenderPath2D::Render() const
{
GraphicsDevice* device = wiRenderer::GetDevice();

Expand Down Expand Up @@ -136,7 +136,7 @@ void RenderPath2D::Render()

RenderPath::Render();
}
void RenderPath2D::Compose()
void RenderPath2D::Compose() const
{
wiImageParams fx((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight());
fx.enableFullScreen();
Expand Down
5 changes: 3 additions & 2 deletions WickedEngine/RenderPath2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class RenderPath2D :
void Start() override;
void Update(float dt) override;
void FixedUpdate() override;
void Render() override;
void Compose() override;
void Render() const override;
void Compose() const override;

const wiGraphics::Texture2D& GetRenderResult() { return rtFinal; }

Expand All @@ -73,6 +73,7 @@ class RenderPath2D :
void SortLayers();
void CleanLayers();

const wiGUI& GetGUI() const { return GUI; }
wiGUI& GetGUI() { return GUI; }
};

22 changes: 1 addition & 21 deletions WickedEngine/RenderPath3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,34 +196,14 @@ void RenderPath3D::ResizeBuffers()
}
}

void RenderPath3D::Initialize()
{
RenderPath2D::Initialize();
}

void RenderPath3D::Load()
{
RenderPath2D::Load();
}

void RenderPath3D::Start()
{
RenderPath2D::Start();
}

void RenderPath3D::FixedUpdate()
{
RenderPath2D::FixedUpdate();
}

void RenderPath3D::Update(float dt)
{
RenderPath2D::Update(dt);

wiRenderer::UpdatePerFrameData(dt);
}

void RenderPath3D::Compose()
void RenderPath3D::Compose() const
{
GraphicsDevice* device = wiRenderer::GetDevice();

Expand Down
7 changes: 2 additions & 5 deletions WickedEngine/RenderPath3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,8 @@ class RenderPath3D :

virtual void setMSAASampleCount(UINT value) { if (msaaSampleCount != value) { msaaSampleCount = value; ResizeBuffers(); } }

void Initialize() override;
void Load() override;
void Start() override;
void FixedUpdate() override;
void Update(float dt) override;
void Compose() override;
void Render() const override = 0;
void Compose() const override;
};

4 changes: 2 additions & 2 deletions WickedEngine/RenderPath3D_Deferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void RenderPath3D_Deferred::ResizeBuffers()
}
}

void RenderPath3D_Deferred::Render()
void RenderPath3D_Deferred::Render() const
{
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
Expand Down Expand Up @@ -127,7 +127,7 @@ void RenderPath3D_Deferred::Render()

// Deferred lights:
{
Texture2D* rts[] = {
const Texture2D* rts[] = {
&lightbuffer_diffuse,
&lightbuffer_specular,
};
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_Deferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class RenderPath3D_Deferred :
public:
void setMSAASampleCount(UINT value) override { /*disable MSAA for deferred*/ }

void Render() override;
void Render() const override;
};

2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_Forward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void RenderPath3D_Forward::ResizeBuffers()
}
}

void RenderPath3D_Forward::Render()
void RenderPath3D_Forward::Render() const
{
GraphicsDevice* device = wiRenderer::GetDevice();
const Texture2D* scene_read[] = { &rtMain[0], &rtMain[1] };
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_Forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class RenderPath3D_Forward :
void ResizeBuffers() override;

public:
void Render() override;
void Render() const override;
};

4 changes: 2 additions & 2 deletions WickedEngine/RenderPath3D_PathTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void RenderPath3D_PathTracing::Update(float dt)
RenderPath3D::Update(dt);
}

void RenderPath3D_PathTracing::Render()
void RenderPath3D_PathTracing::Render() const
{
// Setup:
{
Expand Down Expand Up @@ -137,7 +137,7 @@ void RenderPath3D_PathTracing::Render()
RenderPath2D::Render();
}

void RenderPath3D_PathTracing::Compose()
void RenderPath3D_PathTracing::Compose() const
{
GraphicsDevice* device = wiRenderer::GetDevice();

Expand Down
4 changes: 2 additions & 2 deletions WickedEngine/RenderPath3D_PathTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class RenderPath3D_PathTracing :
const wiGraphics::Texture2D* GetDepthBuffer() override { return nullptr; };

void Update(float dt) override;
void Render() override;
void Compose() override;
void Render() const override;
void Compose() const override;
};
2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_TiledDeferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using namespace wiGraphics;

void RenderPath3D_TiledDeferred::Render()
void RenderPath3D_TiledDeferred::Render() const
{
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_TiledDeferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class RenderPath3D_TiledDeferred :
public RenderPath3D_Deferred
{
public:
void Render() override;
void Render() const override;
};

2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_TiledForward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace wiGraphics;

void RenderPath3D_TiledForward::Render()
void RenderPath3D_TiledForward::Render() const
{
GraphicsDevice* device = wiRenderer::GetDevice();
const Texture2D* scene_read[] = { &rtMain[0], &rtMain[1] };
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/RenderPath3D_TiledForward.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class RenderPath3D_TiledForward :
public RenderPath3D_Forward
{
private:
void Render() override;
void Render() const override;
};

12 changes: 6 additions & 6 deletions WickedEngine/wiFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ void wiFont::BindPersistentState(GRAPHICSTHREAD threadID)
// Bind the whole font atlas once for the whole frame:
device->BindResource(PS, &texture, TEXSLOT_FONTATLAS, threadID);
}
Texture2D* wiFont::GetAtlas()
const Texture2D* wiFont::GetAtlas()
{
return &texture;
}
Expand All @@ -467,7 +467,7 @@ int wiFont::AddFontStyle(const string& fontName)
}


void wiFont::Draw(GRAPHICSTHREAD threadID)
void wiFont::Draw(GRAPHICSTHREAD threadID) const
{
if (!initialized.load() || text.length() <= 0)
{
Expand Down Expand Up @@ -545,7 +545,7 @@ void wiFont::Draw(GRAPHICSTHREAD threadID)
}


int wiFont::textWidth()
int wiFont::textWidth() const
{
if (style >= fontStyles.size())
{
Expand Down Expand Up @@ -586,7 +586,7 @@ int wiFont::textWidth()

return maxWidth;
}
int wiFont::textHeight()
int wiFont::textHeight() const
{
if (style >= fontStyles.size())
{
Expand Down Expand Up @@ -622,11 +622,11 @@ void wiFont::SetText(const wstring& text)
{
this->text = text;
}
wstring wiFont::GetText()
wstring wiFont::GetText() const
{
return text;
}
string wiFont::GetTextA()
string wiFont::GetTextA() const
{
return string(text.begin(),text.end());
}
12 changes: 6 additions & 6 deletions WickedEngine/wiFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class wiFont

static void LoadShaders();
static void BindPersistentState(GRAPHICSTHREAD threadID);
static wiGraphics::Texture2D* GetAtlas();
static const wiGraphics::Texture2D* GetAtlas();

// Returns the font path that can be modified
static std::string& GetFontPath();
Expand All @@ -55,14 +55,14 @@ class wiFont
wiFont(const std::string& text = "", wiFontParams params = wiFontParams(), int style = 0);
wiFont(const std::wstring& text, wiFontParams params = wiFontParams(), int style = 0);

void Draw(GRAPHICSTHREAD threadID);
void Draw(GRAPHICSTHREAD threadID) const;

int textWidth();
int textHeight();
int textWidth() const;
int textHeight() const;

void SetText(const std::string& text);
void SetText(const std::wstring& text);
std::wstring GetText();
std::string GetTextA();
std::wstring GetText() const;
std::string GetTextA() const;

};
12 changes: 2 additions & 10 deletions WickedEngine/wiGPUBVH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ static ComputePSO CPSO[CSTYPE_BVH_COUNT];

static GPUBuffer constantBuffer;

wiGPUBVH::wiGPUBVH()
{

}
wiGPUBVH::~wiGPUBVH()
{
}

//#define BVH_VALIDATE // slow but great for debug!
void wiGPUBVH::Build(const Scene& scene, GRAPHICSTHREAD threadID)
{
Expand Down Expand Up @@ -475,11 +467,11 @@ void wiGPUBVH::Build(const Scene& scene, GRAPHICSTHREAD threadID)

wiProfiler::EndRange(threadID); // BVH rebuild
}
void wiGPUBVH::Bind(SHADERSTAGE stage, GRAPHICSTHREAD threadID)
void wiGPUBVH::Bind(SHADERSTAGE stage, GRAPHICSTHREAD threadID) const
{
GraphicsDevice* device = wiRenderer::GetDevice();

GPUResource* res[] = {
const GPUResource* res[] = {
&triangleBuffer,
&clusterCounterBuffer,
&clusterIndexBuffer,
Expand Down
5 changes: 1 addition & 4 deletions WickedEngine/wiGPUBVH.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ class wiGPUBVH
uint32_t maxClusterCount = 0;

public:
wiGPUBVH();
~wiGPUBVH();

void Build(const wiSceneSystem::Scene& scene, GRAPHICSTHREAD threadID);
void Bind(wiGraphics::SHADERSTAGE stage, GRAPHICSTHREAD threadID);
void Bind(wiGraphics::SHADERSTAGE stage, GRAPHICSTHREAD threadID) const;

static void LoadShaders();

Expand Down
Loading

0 comments on commit 39eb173

Please sign in to comment.