Skip to content

Commit

Permalink
Work on scripts and some small scale refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Zang3th committed Jul 3, 2024
1 parent 8c51f3c commit c6687ae
Show file tree
Hide file tree
Showing 24 changed files with 128 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SpaceAfterCStyleCast: false
DerivePointerAlignment: false
PointerAlignment: Left
SpaceAfterTemplateKeyword: true
SortIncludes: true
SortIncludes: false
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true

Expand Down
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Checks: "*,
-hicpp-use-auto,
-modernize-use-auto,
-cert-err58-cpp,
-hicpp-vararg,
-modernize-loop-convert,
"
WarningsAsErrors: ''
HeaderFilterRegex: ''
Expand Down
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/Build_Debug
/Build_Release
/Debug_Build
/Release_Build
/.idea
StaticAnalysis.sh
DebugBuildScript.sh
ReleaseBuildScript.sh
/.PVS-Studio
.i
.cfg
Expand Down
26 changes: 9 additions & 17 deletions Apps/CellSim/CellSimApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace CS
Engine::ResourceManager::LoadShader("CellShader", "../Res/Shader/CellSim/Cell_VS.glsl", "../Res/Shader/CellSim/Cell_FS.glsl");
}

Engine::uint32 CellSimApp::InitModules()
bool CellSimApp::Init()
{
//Configure some global application parameters
Engine::RenderParams::farPlane = 1024.0f;
Expand All @@ -28,7 +28,7 @@ namespace CS
Engine::Logger::Init();
if(Engine::Window::Init("CellSim") != EXIT_SUCCESS)
{
return EXIT_FAILURE;
return false;
}
Engine::Camera3D::Init();
Engine::CameraController3D::Init();
Expand All @@ -47,11 +47,15 @@ namespace CS

//Create UI
_interface = Engine::MakeScope<CellSimInterface>();
_interface->Init();

//Create timer
_physicsTimer = Engine::MakeScope<Engine::Timer>(10); //10ms

return EXIT_SUCCESS;
AddObjects();
AddCellWorld();

return true;
}

void CellSimApp::AddObjects()
Expand Down Expand Up @@ -119,19 +123,7 @@ namespace CS

// ----- Public -----

CellSimApp::CellSimApp()
{
if(InitModules() != EXIT_SUCCESS)
{
_initSuccess = false;
}
else
{
_initSuccess = true;
AddObjects();
AddCellWorld();
}
}
CellSimApp::CellSimApp() = default;

CellSimApp::~CellSimApp()
{
Expand Down Expand Up @@ -269,4 +261,4 @@ namespace CS
Engine::Window::SwapBuffers();
}
}
}
}
15 changes: 8 additions & 7 deletions Apps/CellSim/CellSimApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ namespace CS
Engine::Scope<Engine::CellManager> _cellManager;
Engine::Scope<CellSimInterface> _interface;

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

public:
CellSimApp();
Expand All @@ -29,5 +28,7 @@ namespace CS

//Not needed in this app because we only use a general 3D camera controller to handle input.
void ProcessInput() override {}

[[nodiscard]] bool Init() override;
};
}
}
14 changes: 6 additions & 8 deletions Apps/CellSim/CellSimEntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ int main()
//Create app
CS::CellSimApp cellSimApp;

//Check for success
if(cellSimApp.GetInitSuccess())
//Init and check for success
if(cellSimApp.Init())
{
//Start app
while(cellSimApp.IsRunning())
{
cellSimApp.Update();
}
}
else
{
return EXIT_FAILURE;

return 0;
}

return EXIT_SUCCESS;
}
return -1;
}
9 changes: 3 additions & 6 deletions Apps/CellSim/CellSimInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,9 @@ namespace CS

// ----- Public -----

CellSimInterface::CellSimInterface()
{
InitUI();
}
CellSimInterface::CellSimInterface() = default;

void CellSimInterface::InitUI()
void CellSimInterface::Init()
{
LoadCustomFont("../Res/Assets/Fonts/JetBrainsMono-Medium.ttf", 19);
SetDarkThemeColors();
Expand Down Expand Up @@ -263,4 +260,4 @@ namespace CS
ImGui::PopStyleVar();
ImGui::PopStyleVar();
}
}
}
4 changes: 2 additions & 2 deletions Apps/CellSim/CellSimInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace CS

public:
CellSimInterface();
void InitUI() override;
void Init() override;
void AddElements() override;
};
}
}
26 changes: 9 additions & 17 deletions Apps/GreenWorld/GreenWorldApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace GW
Engine::ResourceManager::LoadHeightmap("TerrainHeightmap", "../Res/Assets/Textures/GreenWorld/Heightmap128.bmp");
}

Engine::uint32 GreenWorldApp::InitModules()
bool GreenWorldApp::Init()
{
Engine::CameraParams::startPitch = -24.0f;
Engine::CameraParams::startPos = glm::vec3(-75.0f, 74.0f, 70.0f);
Expand All @@ -38,7 +38,7 @@ namespace GW
Engine::Logger::Init();
if(Engine::Window::Init("GreenWorld") != EXIT_SUCCESS)
{
return EXIT_FAILURE;
return false;
}
Engine::Camera3D::Init();
Engine::CameraController3D::Init();
Expand Down Expand Up @@ -70,6 +70,7 @@ namespace GW

//Create UI
_interface = Engine::MakeScope<GreenWorldInterface>();
_interface->Init();

//Init audio system
_audio = Engine::MakeScope<Engine::Audio>();
Expand All @@ -79,7 +80,10 @@ namespace GW
_audio->PlaySound3D("../Res/Assets/Audio/GreenWorld/Sounds/River.wav", true, 4.0f, glm::vec3(39.0f, 14.0f, 56.0f), 0.5f);
}

return EXIT_SUCCESS;
AddObjects();
AddSprites();

return true;
}

void GreenWorldApp::AddObjects()
Expand Down Expand Up @@ -199,19 +203,7 @@ namespace GW

// ----- Public -----

GreenWorldApp::GreenWorldApp()
{
if(InitModules() != EXIT_SUCCESS)
{
_initSuccess = false;
}
else
{
_initSuccess = true;
AddObjects();
AddSprites();
}
}
GreenWorldApp::GreenWorldApp() = default;

GreenWorldApp::~GreenWorldApp()
{
Expand Down Expand Up @@ -276,4 +268,4 @@ namespace GW
Engine::Window::SwapBuffers();
}
}
}
}
23 changes: 12 additions & 11 deletions Apps/GreenWorld/GreenWorldApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ namespace GW
class GreenWorldApp final : public Engine::App
{
private:
Engine::SceneRenderer* _sceneRenderer = nullptr;
Engine::ShadowRenderer* _shadowRenderer = nullptr;
Engine::WaterRenderer* _waterRenderer = nullptr;
Engine::SpriteRenderer* _spriteRenderer = nullptr;
Engine::Scope<GreenWorldInterface> _interface;
Engine::Scope<Engine::Audio> _audio;
Engine::SceneRenderer* _sceneRenderer = nullptr;
Engine::ShadowRenderer* _shadowRenderer = nullptr;
Engine::WaterRenderer* _waterRenderer = nullptr;
Engine::SpriteRenderer* _spriteRenderer = nullptr;
Engine::Scope<GreenWorldInterface> _interface;
Engine::Scope<Engine::Audio> _audio;

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

public:
GreenWorldApp();
Expand All @@ -27,5 +26,7 @@ namespace GW

//Not needed in this app because we only use a general 3D camera controller to handle input.
void ProcessInput() override {}

[[nodiscard]] bool Init() override;
};
}
}
14 changes: 6 additions & 8 deletions Apps/GreenWorld/GreenWorldEntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ int main()
//Create app
GW::GreenWorldApp greenWorldApp;

//Check for success
if(greenWorldApp.GetInitSuccess())
//Init and check for success
if(greenWorldApp.Init())
{
//Start app
while(greenWorldApp.IsRunning())
{
greenWorldApp.Update();
}
}
else
{
return EXIT_FAILURE;

return 0;
}

return EXIT_SUCCESS;
}
return -1;
}
9 changes: 3 additions & 6 deletions Apps/GreenWorld/GreenWorldInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,9 @@ namespace GW

// ----- Public -----

GreenWorldInterface::GreenWorldInterface()
{
InitUI();
}
GreenWorldInterface::GreenWorldInterface() = default;

void GreenWorldInterface::InitUI()
void GreenWorldInterface::Init()
{
_windowAlphaValue = 0.65;
LoadCustomFont("../Res/Assets/Fonts/JetBrainsMono-Medium.ttf", 19);
Expand Down Expand Up @@ -156,4 +153,4 @@ namespace GW

ImGui::PopStyleVar();
}
}
}
4 changes: 2 additions & 2 deletions Apps/GreenWorld/GreenWorldInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace GW

public:
GreenWorldInterface();
void InitUI() override;
void Init() override;
void AddElements() override;
};
}
}
19 changes: 5 additions & 14 deletions Apps/Liquefied/LiquefiedApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ namespace Liq
}
}

Engine::uint32 LiquefiedApp::InitModules()
bool LiquefiedApp::Init()
{
//Initialize engine components
Engine::Logger::Init();
if(Engine::Window::Init("Liquefied") != EXIT_SUCCESS)
{
return EXIT_FAILURE;
return false;
}
Engine::RenderManager::Init2D();

Expand All @@ -54,6 +54,7 @@ namespace Liq

//Create UI
_interface = Engine::MakeScope<LiquefiedInterface>();
_interface->Init();

//Create fluid simulator
_fluidSimulator = Engine::MakeScope<Engine::FluidSimulator>();
Expand All @@ -66,7 +67,7 @@ namespace Liq
AddBorderCells();
_gridRenderer->SetConfigAsDefault();

return EXIT_SUCCESS;
return true;
}

void LiquefiedApp::UpdateTimer() const
Expand Down Expand Up @@ -106,17 +107,7 @@ namespace Liq

// ----- Public -----

LiquefiedApp::LiquefiedApp()
{
if(InitModules() != EXIT_SUCCESS)
{
_initSuccess = false;
}
else
{
_initSuccess = true;
}
}
LiquefiedApp::LiquefiedApp() = default;

LiquefiedApp::~LiquefiedApp()
{
Expand Down
Loading

0 comments on commit c6687ae

Please sign in to comment.