Didn't work. Let's try again.
This commit is contained in:
+11
-7
@@ -43,6 +43,7 @@
|
||||
#include "Game/CPad.h"
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/GameFrame.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
@@ -103,7 +104,7 @@ public:
|
||||
m_FrameStack->Width = 1920;
|
||||
m_FrameStack->Height = 1080;
|
||||
|
||||
|
||||
new dd::GameFrame(m_FrameStack, "GameFrame");
|
||||
|
||||
|
||||
//TODO: Remove tobias light-test code.
|
||||
@@ -159,14 +160,15 @@ public:
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}
|
||||
|
||||
// Top Wall
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(18.f, 0.5f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
|
||||
@@ -175,14 +177,15 @@ public:
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
// Left Wall
|
||||
{
|
||||
auto leftWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(leftWall);
|
||||
transform->Position = glm::vec3(-9.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 10.f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
|
||||
|
||||
@@ -191,14 +194,15 @@ public:
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
// Right Wall.
|
||||
{
|
||||
auto rightWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(rightWall);
|
||||
transform->Position = glm::vec3(9.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 10.f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
|
||||
|
||||
|
||||
@@ -88,6 +88,10 @@ struct SpriteJob : RenderJob
|
||||
unsigned int ShaderID;
|
||||
unsigned int TextureID;
|
||||
|
||||
//Niklas is trying to get Frames to work.
|
||||
GLuint Texture;
|
||||
//Niklas is trying to get Frames to work./end
|
||||
|
||||
glm::mat4 ModelMatrix;
|
||||
GLuint DiffuseTexture;
|
||||
GLuint NormalTexture;
|
||||
@@ -167,6 +171,23 @@ struct RenderQueueCollection
|
||||
}
|
||||
};
|
||||
|
||||
struct RenderQueuePair
|
||||
|
||||
{
|
||||
RenderQueue Deferred;
|
||||
RenderQueue Forward;
|
||||
|
||||
void Clear() {
|
||||
Deferred.Clear();
|
||||
Forward.Clear();
|
||||
}
|
||||
|
||||
void Sort() {
|
||||
Deferred.Sort();
|
||||
Forward.Sort();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RenderQueue_h__
|
||||
@@ -51,6 +51,32 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Niklas is trying to implement Frames.
|
||||
std::shared_ptr<dd::Camera> GetCamera() const { return m_FrameCamera; }
|
||||
void SetCamera(const std::shared_ptr<dd::Camera> camera)
|
||||
{
|
||||
m_FrameCamera = camera;
|
||||
}
|
||||
|
||||
void DrawFrame(RenderQueuePair &rq);
|
||||
void DrawWorld(RenderQueuePair &rq);
|
||||
|
||||
void SetViewport(const Rectangle &viewport)
|
||||
{
|
||||
m_Viewport = viewport;
|
||||
}
|
||||
|
||||
void SetScissor(const Rectangle &scissor)
|
||||
{
|
||||
m_Scissor = scissor;
|
||||
}
|
||||
|
||||
int Width() const { return m_Width; }
|
||||
int Height() const { return m_Height; }
|
||||
//Niklas is trying to implement Frames.
|
||||
|
||||
void Initialize();
|
||||
void Draw(RenderQueueCollection& rq);
|
||||
|
||||
@@ -61,8 +87,17 @@ private:
|
||||
//Rectangle m_Viewport;
|
||||
//Rectangle m_Scissor;
|
||||
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
|
||||
|
||||
const dd::Camera* m_Camera = nullptr;
|
||||
|
||||
//Niklas is trying to implement Frames.
|
||||
std::shared_ptr<dd::Camera> m_FrameCamera;
|
||||
Rectangle m_Viewport;
|
||||
Rectangle m_Scissor;
|
||||
ShaderProgram m_ForwardRendering;
|
||||
int m_Width = 1980, m_Height = 1080;
|
||||
//Niklas is trying to implement Frames./end
|
||||
|
||||
int m_GLVersion[2];
|
||||
std::string m_GLVendor;
|
||||
GLFWwindow* m_Window = nullptr;
|
||||
|
||||
@@ -107,6 +107,12 @@ public:
|
||||
@tparam T Resource type.
|
||||
@param resourceName Fully qualified name of the resource to fetch.
|
||||
*/
|
||||
|
||||
//Niklas is trying to get frames to work.
|
||||
template <typename T>
|
||||
T* Load(std::string resourceType, std::string resourceName);
|
||||
//Niklas is trying to get frames to work./end
|
||||
|
||||
template <typename T>
|
||||
static T* Fetch(std::string resourceName);
|
||||
|
||||
@@ -142,6 +148,7 @@ private:
|
||||
// Internal: Create a resource and cache it
|
||||
template <typename T>
|
||||
static T* CreateResource(std::string resourceName, Resource* parent);
|
||||
Resource* CreateResource(std::string resourceType, std::string resourceName);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -161,6 +168,25 @@ T* ResourceManager::Load(std::string resourceName, Resource* parent /* = nullptr
|
||||
return CreateResource<T>(resourceName, parent);
|
||||
}
|
||||
|
||||
//Niklas is trying to get frames to work.
|
||||
template <typename T>
|
||||
T* ResourceManager::Load(std::string resourceType, std::string resourceName)
|
||||
{
|
||||
auto it = m_ResourceCache.find(std::make_pair(resourceType, resourceName));
|
||||
if (it != m_ResourceCache.end())
|
||||
return static_cast<T *>(it->second);
|
||||
if (m_Preloading) {
|
||||
LOG_INFO("Preloading resource \"%s\"", resourceName.c_str());
|
||||
}
|
||||
else {
|
||||
LOG_WARNING("Hot-loading resource \"%s\"", resourceName.c_str());
|
||||
}
|
||||
return static_cast<T *>(CreateResource(resourceType, resourceName));
|
||||
}
|
||||
|
||||
|
||||
//Niklas is trying to get frames to work./end
|
||||
|
||||
template <typename T>
|
||||
T* ResourceManager::Fetch(std::string resourceName)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user