Skip to content

Commit

Permalink
Some small changes and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Zang3th committed Apr 20, 2024
1 parent d0bf6c9 commit 927d2cd
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 66 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [push, pull_request]

env:
BUILD_TYPE: Debug
Expand Down Expand Up @@ -37,4 +33,8 @@ jobs:

- name: Run CellSim
working-directory: ${{github.workspace}}/build
run: xvfb-run -a ./CellSim & sleep 20 ; kill $!
run: xvfb-run -a ./CellSim & sleep 20 ; kill $!

- name: Run Liquefied
working-directory: ${{github.workspace}}/build
run: xvfb-run -a ./Liquefied & sleep 20 ; kill $!
6 changes: 1 addition & 5 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Static analysis

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [push, pull_request]

jobs:
static_analysis:
Expand Down
4 changes: 2 additions & 2 deletions Apps/CellSim/CellSimApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ namespace CS
{
if(InitModules() != EXIT_SUCCESS)
{
appStartSuccess = false;
_initSuccess = false;
}
else
{
appStartSuccess = true;
_initSuccess = true;
AddObjects();
AddCellWorld();
}
Expand Down
8 changes: 4 additions & 4 deletions Apps/CellSim/CellSimApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ namespace CS
Engine::Scope<Engine::CellManager> _cellManager;
Engine::Scope<CellSimInterface> _interface;

void LoadResources() final;
Engine::uint32 InitModules() final;
void LoadResources() override;
Engine::uint32 InitModules() override;
void AddObjects();
void AddCellWorld();
void HandleCellSpawn();
void HandleCellKill();

public:
CellSimApp();
~CellSimApp() final;
void Update() final;
~CellSimApp() override;
void Update() override;
};
}
4 changes: 3 additions & 1 deletion Apps/CellSim/CellSimEntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ int main()
CS::CellSimApp cellSimApp;

//Check for success
if(cellSimApp.appStartSuccess)
if(cellSimApp.GetInitSuccess())
{
//Start app
while(cellSimApp.IsRunning())
{
cellSimApp.Update();
}
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Apps/GreenWorld/GreenWorldApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ namespace GW
{
if(InitModules() != EXIT_SUCCESS)
{
appStartSuccess = false;
_initSuccess = false;
}
else
{
appStartSuccess = true;
_initSuccess = true;
AddObjects();
AddSprites();
}
Expand Down
8 changes: 4 additions & 4 deletions Apps/GreenWorld/GreenWorldApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace GW
Engine::Scope<GreenWorldInterface> _interface;
Engine::Scope<Engine::Audio> _audio;

void LoadResources() final;
Engine::uint32 InitModules() final;
void LoadResources() override;
Engine::uint32 InitModules() override;
void AddObjects();
void AddSprites();

public:
GreenWorldApp();
~GreenWorldApp() final;
void Update() final;
~GreenWorldApp() override;
void Update() override;
};
}
4 changes: 3 additions & 1 deletion Apps/GreenWorld/GreenWorldEntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ int main()
GW::GreenWorldApp greenWorldApp;

//Check for success
if(greenWorldApp.appStartSuccess)
if(greenWorldApp.GetInitSuccess())
{
//Start app
while(greenWorldApp.IsRunning())
{
greenWorldApp.Update();
}
}
else
{
Expand Down
22 changes: 8 additions & 14 deletions Apps/Liquefied/LiquefiedApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Liq
//Load shaders and textures
LoadResources();

//Create PixelRenderer
//Create pixel renderer
_pixelRenderer = Engine::RenderManager::AddPixelRenderer("BG_Texture", "SpriteShader");

//Create UI
Expand All @@ -41,11 +41,11 @@ namespace Liq
{
if(InitModules() != EXIT_SUCCESS)
{
appStartSuccess = false;
_initSuccess = false;
}
else
{
appStartSuccess = true;
_initSuccess = true;
}
}

Expand Down Expand Up @@ -79,26 +79,20 @@ namespace Liq
Engine::RenderManager::RenderPixels();

//Test of the pixel renderer
if(Engine::Window::GetFrameCounter() == 75)
if(Engine::Window::GetFrameCounter() == 0)
{
_pixelRenderer->Set(0, 0, COLOR_WHITE);
_pixelRenderer->Set(1919, 0, COLOR_RED);
_pixelRenderer->Set(0, 1079, COLOR_BLUE);
_pixelRenderer->Set(1919, 1079, COLOR_GREEN);
_pixelRenderer->SetScreen(COLOR_WHITE);
}
else if(Engine::Window::GetFrameCounter() == 0)
else if(Engine::Window::GetFrameCounter() == 80)
{
_pixelRenderer->Reset(0, 0);
_pixelRenderer->Reset(1919, 0);
_pixelRenderer->Reset(0, 1079);
_pixelRenderer->Reset(1919, 1079);
_pixelRenderer->ClearScreen();
}
}

{
Engine::PROFILE_SCOPE("Render UI");

//_interface->AddElements();
_interface->AddElements();
_interface->Render();
}

Expand Down
8 changes: 4 additions & 4 deletions Apps/Liquefied/LiquefiedApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Liq
Engine::PixelRenderer* _pixelRenderer = nullptr;
Engine::Scope<LiquefiedInterface> _interface;

void LoadResources() final;
Engine::uint32 InitModules() final;
void LoadResources() override;
Engine::uint32 InitModules() override;

public:
LiquefiedApp();
~LiquefiedApp() final;
void Update() final;
~LiquefiedApp() override;
void Update() override;
};
}
4 changes: 3 additions & 1 deletion Apps/Liquefied/LiquefiedEntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ int main()
Liq::LiquefiedApp liquefiedApp;

//Check for success
if(liquefiedApp.appStartSuccess)
if(liquefiedApp.GetInitSuccess())
{
//Start app
while(liquefiedApp.IsRunning())
{
liquefiedApp.Update();
}
}
else
{
Expand Down
7 changes: 6 additions & 1 deletion Engine/Application/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ namespace Engine

App::~App() = default;

bool App::IsRunning()
bool App::GetInitSuccess() const
{
return _initSuccess;
}

bool App::IsRunning() const
{
return Engine::Window::IsRunning();
}
Expand Down
9 changes: 6 additions & 3 deletions Engine/Application/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ namespace Engine
class App
{
protected:
bool _initSuccess = false;

virtual void LoadResources() = 0;
virtual uint32 InitModules() = 0;

public:
bool appStartSuccess;
virtual ~App() = 0;
virtual ~App() = 0;
virtual void Update() = 0;
static bool IsRunning();

[[nodiscard]] bool GetInitSuccess() const;
[[nodiscard]] bool IsRunning() const;
};
}
4 changes: 2 additions & 2 deletions Engine/Rendering/Renderer/CellRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ namespace Engine
std::array<glm::vec3, CellSimParams::MAX_CELL_AMOUNT> _colorStorage;

CellRenderer(Shader* shader, const glm::vec3& worldSpawnPos);
~CellRenderer() final = default;
~CellRenderer() override = default;

void InitGpuStorage();
void UploadGPUStorage();

public:
void Flush(Renderer* renderer) final;
void Flush(Renderer* renderer) override;
void UpdateGPUStorage(uint32 index, const glm::u32vec3& cellPos, const glm::vec3& cellColor);
};
}
4 changes: 2 additions & 2 deletions Engine/Rendering/Renderer/ParticleRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ namespace Engine
uint32 count, float size, float speed, float gravityCompliance, float lifeLength,
float respawnThreshold, Texture* textureAtlas, Shader* shader, const glm::vec3& position
);
~ParticleRenderer() final;
~ParticleRenderer() override;

void InitGpuStorage();
void UpdateGpuStorage();
void GenerateParticles();
glm::mat4 GetModelViewMatrix(Particle* particle);

public:
void Flush(Renderer* sceneRenderer) final;
void Flush(Renderer* sceneRenderer) override;
};
}
31 changes: 29 additions & 2 deletions Engine/Rendering/Renderer/PixelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ namespace Engine
// ----- Private -----

PixelRenderer::PixelRenderer(const std::string& bgTexture, const std::string& shader)
: _canvasSprite(ResourceManager::GetTexture(bgTexture),
: _width(ResourceManager::GetTexture(bgTexture)->GetWidth()),
_height(ResourceManager::GetTexture(bgTexture)->GetHeight()),
_canvasSprite(ResourceManager::GetTexture(bgTexture),
ResourceManager::GetShader(shader),
COLOR_WHITE,
glm::vec2((float)WindowParams::WIDTH, (float)WindowParams::HEIGHT))
glm::vec2(_width, _height))
{
Logger::Info("Created", "Renderer", __func__);
}
Expand All @@ -21,6 +23,9 @@ namespace Engine
{
GLRenderSettings::DisableCulling();

//Commit texture changes
_canvasSprite.GetTexture()->CommitModifications();

//Render sprite
RenderStatistics::drawnVertices += _canvasSprite.Draw();
RenderStatistics::drawCalls++;
Expand All @@ -41,4 +46,26 @@ namespace Engine
{
_canvasSprite.GetTexture()->ResetTextureModification(x, y);
}

void PixelRenderer::SetScreen(const glm::vec3& color) const
{
for(uint32 x = 0; x < _width; x++)
{
for(uint32 y = 0; y < _height; y++)
{
Set(x, y, color);
}
}
}

void PixelRenderer::ClearScreen() const
{
for(uint32 x = 0; x < _width; x++)
{
for(uint32 y = 0; y < _height; y++)
{
Reset(x, y);
}
}
}
}
5 changes: 4 additions & 1 deletion Engine/Rendering/Renderer/PixelRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ namespace Engine
friend class RenderManager;

private:
uint32 _width, _height;
Sprite _canvasSprite;

PixelRenderer(const std::string& bgTexture, const std::string& shader);

public:
void Flush(Renderer* renderer) final;
void Flush(Renderer* renderer) override;
void Set(uint32 x, uint32 y, const glm::vec3& color) const;
void Reset(uint32 x, uint32 y) const;
void SetScreen(const glm::vec3& color) const;
void ClearScreen() const;
};
}
4 changes: 2 additions & 2 deletions Engine/Rendering/Renderer/SceneRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ namespace Engine
Shader *_terrainShader, *_modelShader, *_waterShader;

SceneRenderer();
~SceneRenderer() final;
~SceneRenderer() override;

void FlushModel(Model* model, Shader* shader);
void FlushWater();
void UpdateMoveFactor();

public:
void Flush(Renderer* renderer) final;
void Flush(Renderer* renderer) override;
void FlushModels(Shader* shader);
void FlushCubemap();
void FlushTerrain();
Expand Down
2 changes: 1 addition & 1 deletion Engine/Rendering/Renderer/ShadowRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Engine
void EndFrame();

public:
void Flush(Renderer* sceneRenderer) final;
void Flush(Renderer* sceneRenderer) override;
[[nodiscard]] Texture* GetDepthTexture() const;
[[nodiscard]] glm::mat4 GetLightProjection() const;
};
Expand Down
Loading

0 comments on commit 927d2cd

Please sign in to comment.