-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c806675
commit 6d7e6f0
Showing
17 changed files
with
369 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
#include <Engine/Configuration/ConfigCreator.h> | ||
#include <Engine/RenderContext/RenderContext.h> | ||
|
||
#include <Engine/Resource/Helpers/ResourceHelper.h> | ||
#include <Engine/Resource/Factory/ResourceFactory.h> | ||
|
||
using namespace MAGE; | ||
|
||
int main(int argC, char** argV) | ||
{ | ||
Config::InitializeConfig(argC, argV); | ||
|
||
RenderContext::Get().GenerateContext(); | ||
|
||
while (!Context::GetMainWindow()->IsClosed()) | ||
{ | ||
RenderContext::Get().PrepareFrame(); | ||
RenderContext::Get().SubmitFrame(); | ||
} | ||
|
||
Context::GetMainDevice()->WaitForIdle(); | ||
Guid guid = Guid::GenerateID(); | ||
Resource* test = ResourceFactory::Get().GetResourceObject(guid); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
#include "Resource.h" | ||
|
||
#include "Engine/Resource/Helpers/ResourceHelper.h" | ||
#include <nlohmann/json.hpp> | ||
#include <magic_enum.hpp> | ||
|
||
namespace MAGE | ||
{ | ||
Resource::Resource(const ResourceProps& desc) : m_resProps(desc) | ||
{ | ||
} | ||
|
||
void Serialize(const path& absPath) | ||
Resource::Resource(const json& desc) : m_props(desc) | ||
{ | ||
/*nlohmann::json json = {}; | ||
json["ResourceProperties"]["Guid"] = m_resProps.guid.ToString().c_str(); | ||
json["ResourceProperties"]["SizeInBytes"] = m_resProps.sizeInBytes; | ||
json["ResourceProperties"]["MetaPath"] = m_resProps.relativePath; | ||
json["ResourceProperties"]["ResourceName"] = m_resProps.resourceName; | ||
json["ResourceProperties"]["ResourceType"] = m_resProps.type; | ||
json["ResourceProperties"]["LastModified"] = m_resProps.lastModified.ToString().c_str();*/ | ||
|
||
// Write data from m_props.data into the binary file | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright (c) 2024 Metehan Tuncbilek | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Engine/Core/Core.h" | ||
#include "Engine/Objects/Singleton.h" | ||
#include "Engine/Data/Guid.h" | ||
#include "Engine/Resource/Core/Resource.h" | ||
|
||
namespace MAGE | ||
{ | ||
class ResourceFactory final : public Singleton<ResourceFactory> | ||
{ | ||
friend class ResourceHandler; | ||
|
||
public: | ||
ResourceFactory() = default; | ||
~ResourceFactory() = default; | ||
|
||
template<typename T = Resource, typename Key = Guid, typename = std::enable_if<std::is_base_of_v<Resource, T> && (std::is_same_v<Guid, Key> || std::is_same_v<string, Key>)>> | ||
auto GetResourceObject(const Key& key) -> typename std::conditional<std::is_void<T>::value, Resource*, T*>::type | ||
{ | ||
if constexpr (std::is_same_v<string, Key>) | ||
{ | ||
auto it = m_auxillary.find(key); | ||
if (it != m_auxillary.end()) | ||
return dynamic_cast<T*>(&*m_resources[it->second]); | ||
} | ||
else | ||
return dynamic_cast<T*>(&*m_resources[key]); | ||
|
||
return nullptr; | ||
} | ||
|
||
protected: | ||
void RegisterResource(const Shared<Resource>& obj) | ||
{ | ||
m_resources[obj->GetGuid()] = obj; | ||
m_auxillary.emplace(obj->GetPath() + obj->GetResourceName() + "." + obj->GetType(), obj->GetGuid()); | ||
} | ||
|
||
private: | ||
hashmap<Guid, Shared<Resource>, GuidHash> m_resources; | ||
map<string, Guid> m_auxillary; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "Mesh.h" | ||
|
||
namespace MAGE | ||
{ | ||
Mesh::Mesh(const json& desc) : Resource(desc) | ||
{ | ||
} | ||
|
||
Mesh::~Mesh() | ||
{ | ||
} | ||
|
||
void Mesh::Serialize() | ||
{ | ||
} | ||
|
||
void Mesh::Deserialize() | ||
{ | ||
} | ||
|
||
void Mesh::Destroy() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright (c) 2024 Metehan Tuncbilek | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Engine/Core/Core.h" | ||
#include "Engine/Resource/Core/Resource.h" | ||
|
||
#include "Engine/Vulkan/Buffer/VBuffer.h" | ||
|
||
namespace MAGE | ||
{ | ||
class Mesh : public Resource | ||
{ | ||
public: | ||
Mesh(const json& desc); | ||
virtual ~Mesh() override; | ||
|
||
void Serialize() override final; | ||
void Deserialize() override final; | ||
void Destroy() override final; | ||
|
||
protected: | ||
Owned<VBuffer> m_geoBuffer; | ||
}; | ||
} |
Oops, something went wrong.