Skip to content

Commit

Permalink
Merge pull request #1 from migon25/Structure_Remake
Browse files Browse the repository at this point in the history
Structure remake
  • Loading branch information
migon25 authored Dec 12, 2024
2 parents c97b835 + 2d01a86 commit dbb5450
Show file tree
Hide file tree
Showing 228 changed files with 6,179,917 additions and 281 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@ FodyWeavers.xsd

# vcpkg_installed
vcpkg_installed/
vcpkg/
vcpkg/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
9 changes: 9 additions & 0 deletions Directory.build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<VcpkgRoot>$(MSBuildThisFileDirectory)vcpkg</VcpkgRoot>
<VcpkgEnableManifest>true</VcpkgEnableManifest>
<VcpkgManifestInstall>true</VcpkgManifestInstall>
<VcpkgManifestRoot>$(MSBuildThisFileDirectory)</VcpkgManifestRoot>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)vcpkg\scripts\buildsystems\msbuild\vcpkg.props" />
</Project>
13 changes: 13 additions & 0 deletions Directory.build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>

<Target Name="VcPkgBootstrap" BeforeTargets="ClCompile" Condition="!Exists('$(MSBuildThisFileDirectory)vcpkg\vcpkg.exe')">
<Exec Command="$(MSBuildThisFileDirectory)vcpkg\bootstrap-vcpkg.bat" />
</Target>

<Target Name="VcPkgClean" AfterTargets="Clean" Condition="Exists('$(MSBuildThisFileDirectory)vcpkg\vcpkg.exe')">
<Delete Files="$(MSBuildThisFileDirectory)vcpkg\vcpkg.exe" />
</Target>

<Import Project="$(MSBuildThisFileDirectory)vcpkg\scripts\buildsystems\msbuild\vcpkg.targets" />

</Project>
109 changes: 109 additions & 0 deletions EclipseEngine/EclipseEditor/App.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include "EclipseEngine/Logger.h"
#include "App.h"

Core* core = NULL;

App::App(int argc, char* args[])
{
core = new Core();
panelHandler = new PanelHandler(this);
editorCamera = new Camera(core->window->GetWidth(), core->window->GetHeight(), glm::vec3(38.0f, 20.0f, -37.0f));
editorRenderer = new EditorRenderer();

AddModule(editorRenderer, true);
AddModule(panelHandler, true);
}

App::~App()
{
}

bool App::Initialize()
{
if(!core->Initialize()) return false;
for (std::list<Module*>::iterator it = modules.begin(); it != modules.end(); it++)
{
if (!(*it)->Initialize()) return false;
}
m_fpsPanel = std::dynamic_pointer_cast<FPSPanel>(panelHandler->GetPanel("FPS Panel"));
return true;
}

bool App::Start()
{
Initialize();
return true;
}

bool App::Update()
{
float currentFrame = glfwGetTime();
dt = currentFrame - lastFrame;
lastFrame = currentFrame;
float fps = 1.0f / dt; // Assuming dt is the delta time (time since last frame in seconds)
float ms = dt * 1000.0f; // Convert delta time to milliseconds

if (m_fpsPanel) {
if (auto fpsPanel = dynamic_cast<FPSPanel*>(m_fpsPanel.get())) {
fpsPanel->Update(fps, ms);
}
}

// Pass these values to the FPS panel
if (!PreUpdate()) return false;
if (!DoUpdate()) return false;
if (!PostUpdate()) return false;
return true;
}

bool App::CleanUp()
{
for (std::list<Module*>::iterator it = modules.begin(); it != modules.end(); it++)
{
(*it)->CleanUp();
}
core->CleanUp();
return true;
}

void App::AddModule(Module* module, bool activate)
{
if (activate) module->Enable();
modules.push_back(module);
}

bool App::PreUpdate()
{
editorCamera->UpdateMatrix(0.1f, 200.0f);
for (std::list<Module*>::iterator it = modules.begin(); it != modules.end(); it++)
{
if ((*it)->active == false) continue;
if (!(*it)->PreUpdate()) return false;
}
editorRenderer->Render(core->scene, editorCamera, panelHandler->hierarchyPanel->GetSelectedObject());
if (!core->PreUpdate()) return false;
return true;
}

bool App::DoUpdate()
{
if (!core->Update(dt)) return false;
for (std::list<Module*>::iterator it = modules.begin(); it != modules.end(); it++)
{
if ((*it)->active == false) continue;
if (!(*it)->Update(dt)) return false;
}
return true;
}

bool App::PostUpdate()
{
if (!core->PostUpdate()) return false;
for (std::list<Module*>::iterator it = modules.begin(); it != modules.end(); it++)
{
if ((*it)->active == false) continue;
if (!(*it)->PostUpdate()) return false;
}

return true;
}
58 changes: 58 additions & 0 deletions EclipseEngine/EclipseEditor/App.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef APP_H
#define APP_H

#include <memory>
#include <vector>
#include <string>
#include <list>

#include "EclipseEngine/Core.h"
#include "EclipseEngine/Logger.h"
#include "EclipseEngine/Camera.h"

#include "Module.h"
#include "Panel.h"
#include "PanelHandler.h"
#include "FPSpanel.h"
#include "EditorRenderer.h"

class PanelHandler;

class App
{
public:
App(int argc, char* args[]);
virtual ~App();

bool Initialize();
bool Start(); // Called before the first frame
bool Update(); // Called each loop iteration
bool CleanUp(); // Called before quitting

// used for adding new modules we are going to have
void AddModule(Module* module, bool activate);

public:
PanelHandler* panelHandler = nullptr;
Camera* editorCamera = nullptr;
EditorRenderer* editorRenderer = nullptr;

private:
// these functions are called in each llop iteration
bool PreUpdate();
bool DoUpdate();
bool PostUpdate();

private:
std::string name;

// List of modules
std::list<Module*> modules;
std::shared_ptr<FPSPanel> m_fpsPanel;

double dt = 0.0f;
double lastFrame = 0.0f;

};

#endif // APP_H
Loading

0 comments on commit dbb5450

Please sign in to comment.