diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 87cb918..46c2152 100755 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -42,9 +42,6 @@ #include "Game/CBrick.h" #include "Game/CPad.h" -#include "GUI/Frame.h" -#include "GUI/GameFrame.h" - #include "Physics/PhysicsSystem.h" #include "Physics/CPhysics.h" #include "Physics/CBoxShape.h" diff --git a/include/Core/RenderQueue.h b/include/Core/RenderQueue.h index 64c587e..4a88a91 100755 --- a/include/Core/RenderQueue.h +++ b/include/Core/RenderQueue.h @@ -88,10 +88,6 @@ 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; diff --git a/include/Core/Renderer.h b/include/Core/Renderer.h index f1e1510..d95de69 100755 --- a/include/Core/Renderer.h +++ b/include/Core/Renderer.h @@ -51,32 +51,6 @@ public: } } - - - //Niklas is trying to implement Frames. - std::shared_ptr GetCamera() const { return m_FrameCamera; } - void SetCamera(const std::shared_ptr 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); @@ -90,14 +64,6 @@ private: const dd::Camera* m_Camera = nullptr; - //Niklas is trying to implement Frames. - std::shared_ptr 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; diff --git a/include/Core/ResourceManager.h b/include/Core/ResourceManager.h index 6ea29db..020653f 100644 --- a/include/Core/ResourceManager.h +++ b/include/Core/ResourceManager.h @@ -108,11 +108,6 @@ public: @param resourceName Fully qualified name of the resource to fetch. */ - //Niklas is trying to get frames to work. - template - T* Load(std::string resourceType, std::string resourceName); - //Niklas is trying to get frames to work./end - template static T* Fetch(std::string resourceName); @@ -168,25 +163,6 @@ T* ResourceManager::Load(std::string resourceName, Resource* parent /* = nullptr return CreateResource(resourceName, parent); } -//Niklas is trying to get frames to work. -template -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(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(CreateResource(resourceType, resourceName)); -} - - - //Niklas is trying to get frames to work./end - template T* ResourceManager::Fetch(std::string resourceName) { diff --git a/include/GUI/Frame.h b/include/GUI/Frame.h deleted file mode 100644 index f90801f..0000000 --- a/include/GUI/Frame.h +++ /dev/null @@ -1,261 +0,0 @@ -// -// Created by Administrator on 2015-09-16. -// - -#ifndef DAYDREAM_FRAME_H -#define DAYDREAM_FRAME_H - -namespace dd -{ - -#include -#include - -#include "Core/Util/Rectangle.h" -#include "Core/EventBroker.h" -#include "Core/EKeyDown.h" -#include "Core/EKeyUp.h" -#include "Input/EInputCommand.h" -#include "Core/ResourceManager.h" -#include "Core/Renderer.h" -#include "Core/RenderQueue.h" -#include "Core/Texture.h" - -class Frame : public Rectangle -{ -public: - enum class Anchor - { - Left, - Right, - Top, - Bottom - }; - - static const int BaseWidth = 1280; - static const int BaseHeight = 720; - - // Set up a base frame with an event broker - Frame(std::shared_ptr eventBroker, std::shared_ptr resourceManager) - : EventBroker(eventBroker) - , ResourceManager(resourceManager) - , Rectangle() - , m_Parent(nullptr) - , m_Name("UIParent") - , m_Layer(0) - , m_Hidden(false) - { Initialize(); } - - // Create a frame as a child - Frame(Frame* parent, std::string name) - : m_Name(name) - , m_Layer(0) - , m_Hidden(false) - { SetParent(parent); Initialize(); } - - ~Frame() - { - /*for (auto layer : m_Children) - { - for (auto child : layer.second) - { - delete child.second; - } - } - if (m_Parent) - { - m_Parent->RemoveChild(this); - }*/ - } - - dd::RenderQueuePair RenderQueue; - - Frame* Parent() const { return m_Parent; } - void SetParent(Frame* parent) - { - if (parent == nullptr) - { - LOG_ERROR("Failed to create frame \"%s\": Invalid parent", m_Name.c_str()); - return; - } - - Width = parent->Width; - Height = parent->Height; - m_Layer = parent->Layer() + 1; - parent->AddChild(this); - m_Parent = parent; - EventBroker = parent->EventBroker; - ResourceManager = parent->ResourceManager; - } - - void AddChild(Frame* child) - { - m_Children[child->m_Layer].insert(std::make_pair(child->Name(), child)); - if (m_Parent) - { - m_Parent->AddChild(child); - } - } - - void RemoveChild(Frame* child) - { - auto it = m_Children.find(child->m_Layer); - if (it != m_Children.end()) - { - m_Children.erase(it); - } - - if (m_Parent) - { - m_Parent->RemoveChild(child); - } - } - - std::string Name() const { return m_Name; } - void SetName(std::string val) { m_Name = val; } - int Layer() const { return m_Layer; } - bool Hidden() const - { - if (m_Parent) - return m_Parent->Hidden() || m_Hidden; - else - return m_Hidden; - } - - bool Visible() const - { - return !Hidden(); - } - - virtual void Hide() { m_Hidden = true; } - virtual void Show() { m_Hidden = false; } - - int Left() const override - { - if (m_Parent) - return m_Parent->Left() + X; - else - return X; - } - int Right() const override - { - if (m_Parent) - return std::min(m_Parent->Right(), Left() + Width); - else - return Left() + Width; - } - int Top() const override - { - if (m_Parent) - return m_Parent->Top() + Y; - else - return Y; - } - int Bottom() const override - { - if (m_Parent) - return std::min(m_Parent->Bottom(), Top() + Height); - else - return Top() + Height; - } - - glm::vec2 Scale() - { - if (m_Parent) - return m_Parent->Scale(); - else - return glm::vec2(Width, Height) / glm::vec2(BaseWidth, BaseHeight); - } - - Rectangle AbsoluteRectangle() - { - int left = Left(); - if (m_Parent) - left = std::max(left, m_Parent->Left()); - int top = Top(); - if (m_Parent) - top = std::max(top, m_Parent->Top()); - int width = Right() - left; - int height = Bottom() - top; - return Rectangle(left, top, width, height); - } - - void UpdateLayered(double dt) - { - // Update ourselves - this->Update(dt); - - // Update children - for (auto &pairLayer : m_Children) - { - auto children = pairLayer.second; - for (auto &pairChild : children) - { - auto child = pairChild.second; - child->Update(dt); - } - } - } - virtual void Update(double dt) { } - - void DrawLayered(std::shared_ptr renderer) - { - if (this->Hidden()) - return; - - // Draw ourselves - renderer->SetScissor(AbsoluteRectangle()); - this->Draw(renderer); - - // Draw children - for (auto &pairLayer : m_Children) - { - auto children = pairLayer.second; - for (auto &pairChild : children) - { - auto child = pairChild.second; - if (child->Hidden()) - continue; - Rectangle rect = child->AbsoluteRectangle(); - renderer->SetScissor(rect); - child->Draw(renderer); - } - } - } - - virtual void Draw(std::shared_ptr renderer) { } - -protected: - std::shared_ptr EventBroker; - std::shared_ptr ResourceManager; - - std::string m_Name; - int m_Layer; - bool m_Hidden; - - Frame* m_Parent; - typedef std::multimap Children_t; // name -> frame - std::map m_Children; // layer -> Children_t - - virtual bool OnKeyDown(const dd::Events::KeyDown &event) { return false; } - virtual bool OnKeyUp(const dd::Events::KeyUp &event) { return false; } - //virtual bool OnMouseDown(const Events::KeyDown &event) { } - //virtual bool OnMouseUp(const Events::KeyDown &event) { } - virtual bool OnCommand(const dd::Events::InputCommand &event) { return false; } - -private: - EventRelay m_EKeyDown; - EventRelay m_EKeyUp; - EventRelay m_EInputCommand; - - void Initialize() - { - EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Frame::OnKeyDown); - EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Frame::OnKeyUp); - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Frame::OnCommand); - } -}; - -} - -#endif //DAYDREAM_FRAME_H diff --git a/include/GUI/GameFrame.h b/include/GUI/GameFrame.h deleted file mode 100644 index 1556fe3..0000000 --- a/include/GUI/GameFrame.h +++ /dev/null @@ -1,97 +0,0 @@ -// -// Created by Administrator on 2015-09-16. -// - -#ifndef DAYDREAM_GAMEFRAME_H -#define DAYDREAM_GAMEFRAME_H - -#include "GUI/Frame.h" -#include "GUI/MainMenuFrame.h" -//#include "GUI/WorldFrame.h" -#include "GUI/Viewport.h" -#include "GUI/TextureFrame.h" -//#include "GUI/PlayerHUD.h" - -//#include "GameWorld.h" -#include "Game/EGameStart.h" -#include "Game/EGameOver.h" -//#include "Events/Dead.h" - -namespace dd -{ - - class GameFrame : public Frame - { - public: - GameFrame(Frame* parent, std::string name) - : Frame(parent, name) - , m_GameOver(false) - { - EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &dd::GameFrame::OnGameStart); - EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &dd::GameFrame::OnGameOver); - - //m_World = std::make_shared(EventBroker, ResourceManager); - /*m_WorldFrame = new WorldFrame(this, "GameWorldFrame", m_World); - { - vp1 = new Viewport(m_WorldFrame, "Viewport1", m_World); - vp1->X = 0; - vp1->Width = this->Width / 2.f; - new PlayerHUD(vp1, "PlayerHUD", m_World, 1); - - vp2 = new Viewport(m_WorldFrame, "Viewport2", m_World); - vp2->X = vp1->Right(); - vp2->Width = this->Width / 2.f; - new PlayerHUD(vp2, "PlayerHUD", m_World, 2); - - m_FreeCamViewport = new Viewport(m_WorldFrame, "ViewportFreeCam", m_World); - m_FreeCamViewport->Hide(); - }*/ - //m_WorldFrame->Hide(); - //m_World->Initialize(); - - m_MainMenuFrame = new MainMenuFrame(this, "MainMenu"); - } - - private: - EventRelay m_EGameStart; - bool OnGameStart(const dd::Events::GameStart &event) - { - //m_WorldFrame->Show(); - - return true; - } - EventRelay m_EGameOver; - bool OnGameOver(const Events::GameOver &event) - { - m_GameOver = true; - - return true; - } - - //std::shared_ptr m_World; - - MainMenuFrame* m_MainMenuFrame; - //WorldFrame* m_WorldFrame; - //Viewport* vp1; - //Viewport* vp2; - //Viewport* m_FreeCamViewport; - - bool m_GameOver; - - bool OnKeyUp(const dd::Events::KeyUp &event) override - { - if (event.KeyCode == GLFW_KEY_1) - { - /*if (m_FreeCamViewport->Hidden()) - m_FreeCamViewport->Show(); - else - m_FreeCamViewport->Hide();*/ - } - - return true; - } - }; - -} - -#endif //DAYDREAM_GAMEFRAME_H diff --git a/include/GUI/MainMenuFrame.h b/include/GUI/MainMenuFrame.h deleted file mode 100644 index 335e753..0000000 --- a/include/GUI/MainMenuFrame.h +++ /dev/null @@ -1,113 +0,0 @@ -// -// Created by Administrator on 2015-09-16. -// - -#ifndef DAYDREAM_MAINMENUFRAME_H -#define DAYDREAM_MAINMENUFRAME_H - -#include "GUI/Frame.h" -#include "GUI/TextureFrame.h" -//#include "GUI/HealthOverlay.h" - -#include "Game/EGameStart.h" -//#include "Events/PlayBGM.h" - -namespace dd -{ - -class MainMenuFrame : public Frame -{ -public: - MainMenuFrame(Frame* parent, std::string name) - : Frame(parent, name) - { - m_CurrentSelection = 0; - - //Hide(); - m_Background = new TextureFrame(this, "Background"); - m_Background->SetTexture("Textures/GUI/MainMenu/BackGround.png"); - - m_Buttons = new TextureFrame(this, "Message"); - m_Buttons->SetTexture("Textures/GUI/MainMenu/Buttons.png"); - m_CurrentCoordinate = -m_SelectionCoordinates[0] * Scale(); - m_TargetCoordinate = m_CurrentCoordinate; - m_Buttons->X = m_CurrentCoordinate.x; - m_Buttons->Y = m_CurrentCoordinate.y; - - /*Events::PlayBGM e; - e.Resource = "Sounds/BGM/DiesIrae.mp3"; - EventBroker->Publish(e);*/ - } - - void Update(double dt) override - { - if (Hidden()) - return; - - glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate; - m_CurrentCoordinate += posDiff * 4.f * (float)dt; - - m_Buttons->X = m_CurrentCoordinate.x; - m_Buttons->Y = m_CurrentCoordinate.y; - } - -protected: - bool m_Victory; - TextureFrame* m_Background; - TextureFrame* m_Buttons; - - int m_CurrentSelection; - static glm::vec2 m_SelectionCoordinates[2]; - glm::vec2 m_CurrentCoordinate; - glm::vec2 m_TargetCoordinate; - - bool OnCommand(const Events::InputCommand &event) override - { - if (Hidden()) - return false; - - const float deadzone = 0.5f; - - if (event.Command == "interface_horizontal") - { - if (event.Value > deadzone) - m_CurrentSelection++; - else if (event.Value < -deadzone) - m_CurrentSelection--; - } - m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 1) ? 1 : m_CurrentSelection); - m_TargetCoordinate = -m_SelectionCoordinates[m_CurrentSelection] * Scale(); - - if (event.Command == "interface_confirm" && event.Value > 0) - { - // Play - if (m_CurrentSelection == 0) - { - Hide(); - Events::GameStart e1; - EventBroker->Publish(e1); - /*Events::PlayBGM e2; - e2.Resource = "Sounds/BGM/FlightOfTheBumblebee.mp3"; - EventBroker->Publish(e2);*/ - } - // Quit - else if (m_CurrentSelection == 1) - { - exit(EXIT_SUCCESS); - } - } - - return false; - } - - -}; - -glm::vec2 MainMenuFrame::m_SelectionCoordinates[2] = { - glm::vec2(0, 0), - glm::vec2(193, 0), -}; - -} - -#endif //DAYDREAM_MAINMENUFRAME_H diff --git a/include/GUI/TextureFrame.h b/include/GUI/TextureFrame.h deleted file mode 100644 index 98a8e71..0000000 --- a/include/GUI/TextureFrame.h +++ /dev/null @@ -1,88 +0,0 @@ -// -// Created by Administrator on 2015-09-16. -// - -#ifndef DAYDREAM_TEXTUREFRAME_H -#define DAYDREAM_TEXTUREFRAME_H - -#include "GUI/Frame.h" -#include "Core/Texture.h" - -namespace dd -{ - -class TextureFrame : public Frame { -public: - TextureFrame(Frame *parent, std::string name) - : Frame(parent, name), m_Texture(nullptr), m_FadeTexture(nullptr), - m_Color(glm::vec4(1.f, 1.f, 1.f, 1.f)), m_FadeDuration(0.f), m_CurrentFade(1.f) { } - - void Draw(std::shared_ptr renderer) override { - if (m_Texture == nullptr) - return; - - RenderQueue.Clear(); - - // Main texture - { - SpriteJob job; - job.TextureID = m_Texture->ResourceID; - job.Texture = *m_Texture; - job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade); - RenderQueue.Forward.Add(job); - } - - // Texture while fading - if (m_FadeTexture && m_CurrentFade < 1) { - SpriteJob job; - job.TextureID = m_FadeTexture->ResourceID; - job.Texture = *m_FadeTexture; - job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a); - RenderQueue.Forward.Add(job); - } - - renderer->SetCamera(nullptr); - renderer->SetViewport(Rectangle(Left(), Top(), Width, Height)); - renderer->DrawFrame(RenderQueue); - } - - Texture *Texture() const { return m_Texture; } - - void SetTexture(std::string resourceName) { - m_Texture = ResourceManager->Load("Texture", resourceName); - } - - void FadeToTexture(std::string resourceName, double duration) { - m_FadeTexture = m_Texture; - SetTexture(resourceName); - m_FadeDuration = duration; - m_CurrentFade = 0.f; - } - - void Update(double dt) override { - if (m_CurrentFade < 1) { - m_CurrentFade += dt / m_FadeDuration; - if (m_CurrentFade > 1) { - m_FadeTexture = nullptr; - m_CurrentFade = 1; - m_FadeDuration = 0; - } - } - } - - glm::vec4 Color() const { return m_Color; } - - void SetColor(glm::vec4 val) { m_Color = val; } - -protected: - dd::Texture *m_Texture; - dd::Texture *m_FadeTexture; - glm::vec4 m_Color; - float m_FadeDuration; - float m_CurrentFade; - -}; - -} - -#endif //DAYDREAM_TEXTUREFRAME_H diff --git a/include/GUI/Viewport.h b/include/GUI/Viewport.h deleted file mode 100644 index 129f0ce..0000000 --- a/include/GUI/Viewport.h +++ /dev/null @@ -1,81 +0,0 @@ -// -// Created by Administrator on 2015-09-16. -// - -#ifndef DAYDREAM_VIEWPORT_H -#define DAYDREAM_VIEWPORT_H - -#include - -#include "GUI/Frame.h" -#include "Core/World.h" -#include "Transform/TransformSystem.h" -#include "Core/CTransform.h" -#include "Rendering/CCamera.h" -#include "Core/RenderQueue.h" -#include "Core/Camera.h" - -namespace dd -{ - -class Viewport : public Frame -{ -public: - Viewport(Frame *parent, std::string name, std::shared_ptr world) - : Frame(parent, name), m_World(world) { } - - EntityID CameraEntity() const { return m_CameraEntity; } - - void SetCameraEntity(EntityID cameraEntity) { - m_CameraEntity = cameraEntity; - auto transformComponent = m_World->GetComponent(cameraEntity); - if (!transformComponent) - return; - auto cameraComponent = m_World->GetComponent(cameraEntity); - if (!cameraComponent) - return; - - m_FrameCamera = std::make_shared(cameraComponent->FOV, cameraComponent->NearClip, cameraComponent->FarClip); - } - - - void Update(double dt) override { - if (!m_TransformSystem) - m_TransformSystem = m_World->GetSystem(); - - auto transformComponent = m_World->GetComponent(m_CameraEntity); - if (!transformComponent) - return; - - auto cameraComponent = m_World->GetComponent(m_CameraEntity); - if (!cameraComponent) - return; - - dd::Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(m_CameraEntity); - - m_FrameCamera->SetFOV(cameraComponent->FOV); - m_FrameCamera->SetNearClip(cameraComponent->NearClip); - m_FrameCamera->SetFarClip(cameraComponent->FarClip); - m_FrameCamera->SetPosition(absoluteTransform.Position); - m_FrameCamera->SetOrientation(absoluteTransform.Orientation); - } - - void Draw(std::shared_ptr renderer) override { - if (!m_FrameCamera) - return; - - renderer->SetCamera(m_FrameCamera); - renderer->SetViewport(AbsoluteRectangle()); - renderer->DrawWorld(m_Parent->RenderQueue); - } - -private: - std::shared_ptr m_World; - std::shared_ptr m_TransformSystem; - std::shared_ptr m_FrameCamera; - EntityID m_CameraEntity; -}; - -} - -#endif //DAYDREAM_VIEWPORT_H diff --git a/src/game/Core/Renderer.cpp b/src/game/Core/Renderer.cpp index e0efbe3..50cb489 100755 --- a/src/game/Core/Renderer.cpp +++ b/src/game/Core/Renderer.cpp @@ -464,103 +464,3 @@ void dd::Renderer::DebugKeys() } } -//Niklas is trying to get frames to work. -void dd::Renderer::DrawFrame(RenderQueuePair &rq) -{ - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); - glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height); - - //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - //glClearColor(0.0f, 0.5f, 0.0f, 1.0f); - - glEnable(GL_SCISSOR_TEST); - glDisable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix((float)m_Width / m_Height) * m_Camera->ViewMatrix(); - //glm::mat4 MVP; - - m_ForwardRendering.Bind(); - - //for (auto tuple : ModelsToRender) //// Todo: Add so it's TransparentModelsToRender - //{ - // Model* model; - // glm::mat4 modelMatrix; - // bool visible; - // std::tie(model, modelMatrix, visible, std::ignore) = tuple; - // if (!visible) - // continue; - - // MVP = cameraMatrix * modelMatrix; - // glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); - // glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix)); - // glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix())); - // glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(m_Camera->ProjectionMatrix((float)m_Width / m_Height))); - - // glBindVertexArray(model->VAO); - // for (auto texGroup : model->TextureGroups) - // { - // glActiveTexture(GL_TEXTURE0); - // glBindTexture(GL_TEXTURE_2D, *texGroup.Texture); - // glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1); - // } - //} - - for (auto &job : rq.Forward) - { - //auto modelJob = std::dynamic_pointer_cast(job); - //if (modelJob) - //{ - // glm::mat4 modelMatrix = modelJob->ModelMatrix; - - // MVP = cameraMatrix * modelMatrix; - // depthMVP = depthCameraMatrix * modelMatrix; - // glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); - // glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP)); - // glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix)); - // glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix())); - // glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection)); - // //glUniform3fv(glGetUniformLocation(m_SecondPassProgram.GetHandle(), "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview)); - - // glBindVertexArray(modelJob->VAO); - // glActiveTexture(GL_TEXTURE0); - // glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture); - // if (modelJob->NormalTexture != 0) - // { - // glActiveTexture(GL_TEXTURE2); - // glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture); - // } - // if (modelJob->SpecularTexture) - // { - // glActiveTexture(GL_TEXTURE3); - // glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture); - // } - // glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1); - - // continue; - //} - - auto spriteJob = std::dynamic_pointer_cast(job); - if (spriteJob) - { - glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4())); - glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4())); - glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4())); - glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(glm::mat4())); - glUniform4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "Color"), 1, glm::value_ptr(spriteJob->Color)); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, spriteJob->Texture); - glBindVertexArray(m_ScreenQuad); - glDrawArrays(GL_TRIANGLES, 0, 6); - - continue; - } - } -} -//Niklas is trying to get frames to work./end - diff --git a/src/game/Core/ResourceManager.cpp b/src/game/Core/ResourceManager.cpp index a77074d..5fec3b0 100644 --- a/src/game/Core/ResourceManager.cpp +++ b/src/game/Core/ResourceManager.cpp @@ -83,25 +83,3 @@ void dd::ResourceManager::Update() { m_FileWatcher.Check(); } - -//Niklas is trying to get frames to work. -dd::Resource* dd::ResourceManager::CreateResource(std::string resourceType, std::string resourceName) -{ - auto facIt = m_FactoryFunctions.find(resourceType); - if (facIt == m_FactoryFunctions.end()) - { - LOG_ERROR("Failed to load resource \"%s\" of type \"%s\": Type not registered", resourceName.c_str(), resourceType.c_str()); - return nullptr; - } - - // Call the factory function - Resource* resource = facIt->second(resourceName); - // Store IDs - resource->TypeID = GetTypeID(resourceType); - resource->ResourceID = GetNewResourceID(resource->TypeID); - // Cache - m_ResourceCache[std::make_pair(resourceType, resourceName)] = resource; - - return resource; -} -//Niklas is trying to get frames to work./end