diff --git a/assets/Textures/GUI/Menu/Background.png b/assets/Textures/GUI/Menu/Background.png new file mode 100644 index 0000000..8b598c3 Binary files /dev/null and b/assets/Textures/GUI/Menu/Background.png differ diff --git a/assets/Textures/GUI/Menu/Left.png b/assets/Textures/GUI/Menu/Left.png new file mode 100644 index 0000000..e7813de Binary files /dev/null and b/assets/Textures/GUI/Menu/Left.png differ diff --git a/assets/Textures/GUI/Menu/MainOptions.png b/assets/Textures/GUI/Menu/MainOptions.png new file mode 100644 index 0000000..a38c916 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainOptions.png differ diff --git a/assets/Textures/GUI/Menu/MainOptionsClick.png b/assets/Textures/GUI/Menu/MainOptionsClick.png new file mode 100644 index 0000000..5a69342 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainOptionsClick.png differ diff --git a/assets/Textures/GUI/Menu/MainOptionsHover.png b/assets/Textures/GUI/Menu/MainOptionsHover.png new file mode 100644 index 0000000..c6e9c02 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainOptionsHover.png differ diff --git a/assets/Textures/GUI/Menu/MainSquidout.png b/assets/Textures/GUI/Menu/MainSquidout.png new file mode 100644 index 0000000..85d8748 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainSquidout.png differ diff --git a/assets/Textures/GUI/Menu/MainSquidoutClick.png b/assets/Textures/GUI/Menu/MainSquidoutClick.png new file mode 100644 index 0000000..f2206a3 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainSquidoutClick.png differ diff --git a/assets/Textures/GUI/Menu/MainSquidoutHover.png b/assets/Textures/GUI/Menu/MainSquidoutHover.png new file mode 100644 index 0000000..8fe33fe Binary files /dev/null and b/assets/Textures/GUI/Menu/MainSquidoutHover.png differ diff --git a/assets/Textures/GUI/Menu/MainTimeAttack.png b/assets/Textures/GUI/Menu/MainTimeAttack.png new file mode 100644 index 0000000..42ff9f3 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainTimeAttack.png differ diff --git a/assets/Textures/GUI/Menu/MainTimeAttackClick.png b/assets/Textures/GUI/Menu/MainTimeAttackClick.png new file mode 100644 index 0000000..3f37dc8 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainTimeAttackClick.png differ diff --git a/assets/Textures/GUI/Menu/MainTimeAttackHover.png b/assets/Textures/GUI/Menu/MainTimeAttackHover.png new file mode 100644 index 0000000..33cfc2d Binary files /dev/null and b/assets/Textures/GUI/Menu/MainTimeAttackHover.png differ diff --git a/assets/Textures/GUI/Menu/MainTitle.png b/assets/Textures/GUI/Menu/MainTitle.png new file mode 100644 index 0000000..9f2d607 Binary files /dev/null and b/assets/Textures/GUI/Menu/MainTitle.png differ diff --git a/assets/Textures/GUI/Menu/OptionsBGMTitle.png b/assets/Textures/GUI/Menu/OptionsBGMTitle.png new file mode 100644 index 0000000..5e35cbb Binary files /dev/null and b/assets/Textures/GUI/Menu/OptionsBGMTitle.png differ diff --git a/assets/Textures/GUI/Menu/OptionsSFXTitle.png b/assets/Textures/GUI/Menu/OptionsSFXTitle.png new file mode 100644 index 0000000..2c7b9b9 Binary files /dev/null and b/assets/Textures/GUI/Menu/OptionsSFXTitle.png differ diff --git a/assets/Textures/GUI/Menu/OptionsTitle.png b/assets/Textures/GUI/Menu/OptionsTitle.png new file mode 100644 index 0000000..08aa3f5 Binary files /dev/null and b/assets/Textures/GUI/Menu/OptionsTitle.png differ diff --git a/assets/Textures/GUI/Menu/SliderBackground.png b/assets/Textures/GUI/Menu/SliderBackground.png new file mode 100644 index 0000000..427e2e3 Binary files /dev/null and b/assets/Textures/GUI/Menu/SliderBackground.png differ diff --git a/assets/Textures/GUI/Menu/SliderHandle.png b/assets/Textures/GUI/Menu/SliderHandle.png new file mode 100644 index 0000000..49004d4 Binary files /dev/null and b/assets/Textures/GUI/Menu/SliderHandle.png differ diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 25776c3..e47d8f5 100644 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -54,6 +54,7 @@ #include "GUI/Frame.h" #include "GUI/Button.h" +#include "Game/MainMenu.h" namespace dd { @@ -73,24 +74,7 @@ public: m_FrameStack = new GUI::Frame(m_EventBroker.get()); m_FrameStack->Width = 1920; m_FrameStack->Height = 1080; - { - auto button = new GUI::Button(m_FrameStack, "SuperButt"); - button->TextureReleased = "Textures/Test/TestBrick_Specular.png"; - button->TexturePressed = "Textures/Test/TestBrick_Normal.png"; - button->TextureHover = "Textures/Test/TestBrick_Diffuse.png"; - button->X = 50; - button->Y = 75; - button->Width = 100; - button->Height = 25; - } - { - auto button = new GUI::TextureFrame(m_FrameStack, "BALLZ"); - button->SetTexture("Textures/Ball.png"); - button->X = 50; - button->Y = 75; - button->Width = 100; - button->Height = 100; - } + auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu"); m_InputManager = std::make_shared(m_Renderer->Window(), m_EventBroker); @@ -265,7 +249,7 @@ public: // Update input m_InputManager->Update(dt); // Swap event queues to get fresh input data in the read queue - m_EventBroker->Swap(); + //m_EventBroker->Swap(); ResourceManager::Update(); @@ -273,11 +257,6 @@ public: m_EventBroker->Process(); m_FrameStack->UpdateLayered(dt); -// -// if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) { -// ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl"); -// } - if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) { ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl"); } diff --git a/include/Core/PNG.h b/include/Core/PNG.h index fc99324..994a5bc 100644 --- a/include/Core/PNG.h +++ b/include/Core/PNG.h @@ -33,9 +33,6 @@ class PNG : public Image public: PNG(std::string path); ~PNG(); - -private: - }; } diff --git a/include/Core/RenderQueue.h b/include/Core/RenderQueue.h index 4985a2a..64821ff 100755 --- a/include/Core/RenderQueue.h +++ b/include/Core/RenderQueue.h @@ -122,6 +122,7 @@ struct FrameJob : SpriteJob { Rectangle Scissor; Rectangle Viewport; + std::string Name; void CalculateHash() override { @@ -136,7 +137,7 @@ public: void Add(T &job) { job.CalculateHash(); - Jobs.push_front(std::shared_ptr(new T(job))); + Jobs.push_back(std::shared_ptr(new T(job))); } void Sort() @@ -149,17 +150,17 @@ public: Jobs.clear(); } - std::forward_list>::const_iterator begin() + std::list>::const_iterator begin() { return Jobs.begin(); } - std::forward_list>::const_iterator end() + std::list>::const_iterator end() { return Jobs.end(); } - std::forward_list> Jobs; + std::list> Jobs; }; struct RenderQueueCollection diff --git a/include/Core/Texture.h b/include/Core/Texture.h index 13bd113..f7cfd69 100644 --- a/include/Core/Texture.h +++ b/include/Core/Texture.h @@ -43,6 +43,9 @@ public: operator GLuint() const { return m_Texture; } + unsigned int Width = 0; + unsigned int Height = 0; + private: GLuint m_Texture = 0; }; diff --git a/include/Core/Util/Rectangle.h b/include/Core/Util/Rectangle.h index 27af291..c24501f 100644 --- a/include/Core/Util/Rectangle.h +++ b/include/Core/Util/Rectangle.h @@ -44,24 +44,24 @@ struct Rectangle int Height; virtual int Left() const { return X; } - void SetLeft(int left) + virtual void SetLeft(int left) { - Width += X - left; + //Width += X - left; X = left; } virtual int Right() const { return X + Width; } - void SetRight(int right) + virtual void SetRight(int right) { Width = right - X; } virtual int Top() const { return Y; } - void SetTop(int top) + virtual void SetTop(int top) { - Height += Y - top; + //Height += Y - top; Y = top; } virtual int Bottom() const { return Y + Height; } - int SetBottom(int bottom) + virtual void SetBottom(int bottom) { Height = bottom - Y; } diff --git a/include/GUI/Button.h b/include/GUI/Button.h index 27661eb..b2a665d 100644 --- a/include/GUI/Button.h +++ b/include/GUI/Button.h @@ -2,6 +2,10 @@ #define GUI_BUTTON_H__ #include "GUI/TextureFrame.h" +#include "GUI/EButtonEnter.h" +#include "GUI/EButtonLeave.h" +#include "GUI/EButtonPress.h" +#include "GUI/EButtonRelease.h" #include "Core/EMouseMove.h" #include "Core/EMousePress.h" #include "Core/EMouseRelease.h" @@ -22,19 +26,34 @@ public: EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &Button::OnMouseRelease); } - std::string TextureHover; - std::string TexturePressed; - std::string TextureReleased; + void SetTextureHover(std::string resourceName) + { + m_TextureHover = resourceName; + } + void SetTextureReleased(std::string resourceName) + { + m_TextureReleased = resourceName; + SetTexture(resourceName); + } + void SetTexturePressed(std::string resourceName) + { + m_TexturePressed = resourceName; + } void Draw(RenderQueueCollection& rq) override { - if (m_Texture == nullptr && !TextureReleased.empty()) { - SetTexture(TextureReleased); + if (m_Texture == nullptr && !m_TextureReleased.empty()) { + SetTexture(m_TextureReleased); } TextureFrame::Draw(rq); } + virtual void OnEnter() { } + virtual void OnLeave() { } + virtual void OnPress() { } + virtual void OnRelease() { } + protected: bool m_MouseIsOver = false; bool m_IsDown = false; @@ -43,15 +62,25 @@ protected: { bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1)); if (isOver && !m_MouseIsOver) { // Enter - LOG_INFO("%s mouse enter", m_Name.c_str()); if (!m_IsDown) { - SetTexture(TextureHover); + if (!m_TextureHover.empty()) { + SetTexture(m_TextureHover); + } } + OnEnter(); + Events::ButtonEnter e; + e.FrameName = m_Name; + EventBroker->Publish(e); } else if (!isOver && m_MouseIsOver) { // Leave - LOG_INFO("%s mouse left", m_Name.c_str()); if (!m_IsDown) { - SetTexture(TextureReleased); + if (!m_TextureReleased.empty()) { + SetTexture(m_TextureReleased); + } } + OnLeave(); + Events::ButtonLeave e; + e.FrameName = m_Name; + EventBroker->Publish(e); } m_MouseIsOver = isOver; @@ -63,13 +92,16 @@ protected: return false; } - if (!TexturePressed.empty()) { - SetTexture(TexturePressed); + if (!m_TexturePressed.empty()) { + SetTexture(m_TexturePressed); } - LOG_INFO("%s mouse pressed", m_Name.c_str()); - m_IsDown = true; + OnPress(); + Events::ButtonPress e; + e.FrameName = m_Name; + e.Button = this; + EventBroker->Publish(e); return true; } @@ -80,13 +112,22 @@ protected: return false; } - if (!TextureReleased.empty()) { - SetTexture(TextureReleased); + if (m_MouseIsOver) { + if (!m_TextureHover.empty()) { + SetTexture(m_TextureHover); + } + } else { + if (!m_TextureReleased.empty()) { + SetTexture(m_TextureReleased); + } } - LOG_INFO("%s mouse released", m_Name.c_str()); - m_IsDown = false; + OnRelease(); + Events::ButtonRelease e; + e.FrameName = m_Name; + e.Button = this; + EventBroker->Publish(e); return true; } @@ -95,6 +136,10 @@ private: EventRelay m_EMouseMove; EventRelay m_EMousePress; EventRelay m_EMouseRelease; + + std::string m_TextureHover; + std::string m_TexturePressed; + std::string m_TextureReleased; }; } diff --git a/include/GUI/EButtonEnter.h b/include/GUI/EButtonEnter.h new file mode 100644 index 0000000..b2fa352 --- /dev/null +++ b/include/GUI/EButtonEnter.h @@ -0,0 +1,40 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Events_ButtonEnter_h__ +#define Events_ButtonEnter_h__ + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace Events +{ + +/** Thrown on GUI button hover. */ +struct ButtonEnter : Event +{ + std::string FrameName; +}; + +} + +} + +#endif // Events_ButtonEnter_h__ \ No newline at end of file diff --git a/include/GUI/EButtonLeave.h b/include/GUI/EButtonLeave.h new file mode 100644 index 0000000..c448190 --- /dev/null +++ b/include/GUI/EButtonLeave.h @@ -0,0 +1,40 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Events_ButtonLeave_h__ +#define Events_ButtonLeave_h__ + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace Events +{ + +/** Thrown on GUI button hover. */ +struct ButtonLeave : Event +{ + std::string FrameName; +}; + +} + +} + +#endif // Events_ButtonLeave_h__ \ No newline at end of file diff --git a/include/GUI/EButtonPress.h b/include/GUI/EButtonPress.h new file mode 100644 index 0000000..9e18ece --- /dev/null +++ b/include/GUI/EButtonPress.h @@ -0,0 +1,43 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Events_ButtonPress_h__ +#define Events_ButtonPress_h__ + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace GUI { class Button; } + +namespace Events +{ + +/** Thrown on GUI button press. */ +struct ButtonPress : Event +{ + std::string FrameName; + GUI::Button* Button; +}; + +} + +} + +#endif // Events_ButtonPress_h__ \ No newline at end of file diff --git a/include/GUI/EButtonRelease.h b/include/GUI/EButtonRelease.h new file mode 100644 index 0000000..a596c61 --- /dev/null +++ b/include/GUI/EButtonRelease.h @@ -0,0 +1,43 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Events_ButtonRelease_h__ +#define Events_ButtonRelease_h__ + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace GUI { class Button; } + +namespace Events +{ + +/** Thrown on GUI button release. */ +struct ButtonRelease : Event +{ + std::string FrameName; + GUI::Button* Button; +}; + +} + +} + +#endif // Events_ButtonRelease_h__ \ No newline at end of file diff --git a/include/GUI/ESliderUpdate.h b/include/GUI/ESliderUpdate.h new file mode 100644 index 0000000..b2f3c9b --- /dev/null +++ b/include/GUI/ESliderUpdate.h @@ -0,0 +1,45 @@ +/* + This file is part of Daydream Engine. + Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung + + Daydream Engine is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Daydream Engine is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with Daydream Engine. If not, see . +*/ + +#ifndef Events_SliderUpdate_h__ +#define Events_SliderUpdate_h__ + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace GUI { class Slider; } + +namespace Events +{ + +/** Thrown when GUI slider is moved. */ +struct SliderUpdate : Event +{ + std::string FrameName; + GUI::Slider* Slider; + float Percentage; + float DeltaPercentage; +}; + +} + +} + +#endif // Events_SliderUpdate_h__ \ No newline at end of file diff --git a/include/GUI/Frame.h b/include/GUI/Frame.h index 0c0d42e..8594ead 100644 --- a/include/GUI/Frame.h +++ b/include/GUI/Frame.h @@ -73,8 +73,6 @@ public: return; } - Width = parent->Width; - Height = parent->Height; m_Layer = parent->Layer() + 1; parent->AddChild(this); m_Parent = parent; @@ -128,12 +126,25 @@ public: else return X; } + void SetLeft(int absLeft) override + { + if (m_Parent) { + X = absLeft - m_Parent->Left(); + } else { + X = absLeft; + } + } int Right() const override { - if (m_Parent) - return std::min(m_Parent->Right(), Left() + Width); - else - return Left() + Width; + return Left() + Width; + } + void SetRight(int absRight) override + { + if (m_Parent) { + X = absRight - Width - m_Parent->Left(); + } else { + X = absRight - Width; + } } int Top() const override { @@ -142,12 +153,25 @@ public: else return Y; } + void SetTop(int absTop) override + { + if (m_Parent) { + Y = absTop - m_Parent->Top(); + } else { + Y = absTop; + } + } int Bottom() const override { - if (m_Parent) - return std::min(m_Parent->Bottom(), Top() + Height); - else - return Top() + Height; + return Top() + Height; + } + void SetBottom(int absBottom) override + { + if (m_Parent) { + Y = absBottom - Height - m_Parent->Top(); + } else { + Y = absBottom - Height; + } } glm::vec2 Scale() diff --git a/include/GUI/GameFrame.h b/include/GUI/GameFrame.h deleted file mode 100644 index 491163c..0000000 --- a/include/GUI/GameFrame.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef GUI_GameFrame_h__ -#define GUI_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 "Events/GameStart.h" -#include "Events/GameOver.h" -#include "Events/Dead.h" - -namespace dd -{ -namespace GUI -{ - -class GameFrame : public Frame -{ -public: - GameFrame(Frame* parent, std::string name) - : Frame(parent, name) - , m_GameOver(false) - { - EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &GUI::GameFrame::OnGameStart); - EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &GUI::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 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 Events::KeyUp& event) override - { - if (event.KeyCode == GLFW_KEY_1) { - if (m_FreeCamViewport->Hidden()) - m_FreeCamViewport->Show(); - else - m_FreeCamViewport->Hide(); - } - - return true; - } -}; - -} -} - -#endif // GUI_GameFrame_h__ diff --git a/include/GUI/Slider.h b/include/GUI/Slider.h new file mode 100644 index 0000000..48815de --- /dev/null +++ b/include/GUI/Slider.h @@ -0,0 +1,120 @@ +#ifndef GUI_SLIDER_H__ +#define GUI_SLIDER_H__ + +#include "GUI/TextureFrame.h" +#include "GUI/Button.h" +#include "GUI/EButtonPress.h" +#include "GUI/EButtonRelease.h" +#include "GUI/ESliderUpdate.h" +#include "Core/EMouseMove.h" + +namespace dd +{ +namespace GUI +{ + +class Slider : public TextureFrame +{ +public: + Slider(Frame* parent, std::string name) + : TextureFrame(parent, name) + { + m_SliderButton = new GUI::Button(this, "SliderButton"); + m_SliderButton->DisableScissor(); + + EVENT_SUBSCRIBE_MEMBER(m_EButtonPress, &Slider::OnButtonPress); + EVENT_SUBSCRIBE_MEMBER(m_EButtonRelease, &Slider::OnButtonRelease); + EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &Slider::OnMouseMove); + } + + float Percentage() const { return m_Percentage; } + void SetPercentage(const float percentage) { m_Percentage = percentage; } + + void SetTextureHover(std::string resourceName) + { + m_SliderButton->SetTextureHover(resourceName); + } + void SetTextureReleased(std::string resourceName) + { + m_SliderButton->SetTextureReleased(resourceName); + } + void SetTexturePressed(std::string resourceName) + { + m_SliderButton->SetTexturePressed(resourceName); + } + + void CenterSlider() + { + m_SliderButton->Y = (Height / 2) - (m_SliderButton->Height / 2); + } + + ~Slider() + { + if (m_SliderButton != nullptr) { + delete m_SliderButton; + m_SliderButton = nullptr; + } + } + + virtual void Update(double dt) override + { + + } + +private: + Button* m_SliderButton = nullptr; + bool m_IsGrabbed = false; + float m_Percentage = 0.f; + + EventRelay m_EButtonPress; + EventRelay m_EButtonRelease; + EventRelay m_EMouseMove; + + virtual bool OnButtonPress(const Events::ButtonPress& event) + { + if (event.Button == m_SliderButton) { + m_IsGrabbed = true; + } + + return true; + } + + virtual bool OnButtonRelease(const Events::ButtonRelease& event) + { + if (event.Button == m_SliderButton) { + m_IsGrabbed = false; + } + + return true; + } + + virtual bool OnMouseMove(const Events::MouseMove& event) + { + if (m_IsGrabbed) { + // Set horizontal position + m_SliderButton->X += event.DeltaX; + if (m_SliderButton->Left() < Left()) { + m_SliderButton->SetLeft(Left()); + } else if (m_SliderButton->Right() > Right()) { + m_SliderButton->SetRight(Right()); + } + + // Update percentage + float newPercentage = m_SliderButton->X / (float)(Width - m_SliderButton->Width); + Events::SliderUpdate e; + e.FrameName = Name(); + e.Slider = this; + e.Percentage = newPercentage; + e.DeltaPercentage = newPercentage - m_Percentage; + EventBroker->Publish(e); + m_Percentage = newPercentage; + } + + return true; + } +}; + +} +} +#endif + diff --git a/include/GUI/TextureFrame.h b/include/GUI/TextureFrame.h index 18b2b3a..0b2bb98 100644 --- a/include/GUI/TextureFrame.h +++ b/include/GUI/TextureFrame.h @@ -15,6 +15,9 @@ public: TextureFrame(Frame* parent, std::string name) : Frame(parent, name) { } + void EnableScissor() { m_ScissorEnabled = true; } + void DisableScissor() { m_ScissorEnabled = false; } + void Draw(RenderQueueCollection& rq) override { if (m_Texture == nullptr) @@ -23,22 +26,24 @@ public: // Main texture { FrameJob job; - job.Scissor = m_Parent->AbsoluteRectangle(); + job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle(); job.Viewport = Rectangle(Left(), Top(), Width, Height); job.TextureID = m_Texture->ResourceID; job.DiffuseTexture = *m_Texture; job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade); + job.Name = Name(); rq.GUI.Add(job); } // Texture while fading if (m_FadeTexture && m_CurrentFade < 1) { FrameJob job; - job.Scissor = m_Parent->AbsoluteRectangle(); + job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle(); job.Viewport = Rectangle(Left(), Top(), Width, Height); job.TextureID = m_FadeTexture->ResourceID; job.DiffuseTexture = *m_FadeTexture; job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a); + job.Name = Name(); rq.GUI.Add(job); } } @@ -51,6 +56,15 @@ public: if (m_Texture == nullptr) { m_Texture = ResourceManager::Load("Textures/Core/ErrorTexture.png"); } + SizeToTexture(); + } + + void SizeToTexture() + { + if (m_Texture != nullptr) { + this->Width = m_Texture->Width; + this->Height = m_Texture->Height; + } } void FadeToTexture(std::string resourceName, double duration) @@ -77,6 +91,7 @@ public: void SetColor(glm::vec4 val) { m_Color = val; } protected: + bool m_ScissorEnabled = true; dd::Texture* m_Texture = nullptr; dd::Texture* m_FadeTexture = nullptr; glm::vec4 m_Color = glm::vec4(1.f, 1.f, 1.f, 1.f); diff --git a/include/GUI/Viewport.h b/include/GUI/Viewport.h deleted file mode 100644 index 40d54e5..0000000 --- a/include/GUI/Viewport.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GUI_Viewport_h__ -#define GUI_Viewport_h__ - -#include - -#include "GUI/Frame.h" -#include "World.h" -#include "Systems/TransformSystem.h" -#include "Components/Transform.h" -#include "Components/Camera.h" -#include "RenderQueue.h" -#include "Camera.h" - -namespace GUI -{ - -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_Camera = 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; - - Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(m_CameraEntity); - - m_Camera->SetFOV(cameraComponent->FOV); - m_Camera->SetNearClip(cameraComponent->NearClip); - m_Camera->SetFarClip(cameraComponent->FarClip); - m_Camera->SetPosition(absoluteTransform.Position); - m_Camera->SetOrientation(absoluteTransform.Orientation); - } - - void Draw(std::shared_ptr renderer) override - { - if (!m_Camera) - return; - - renderer->SetCamera(m_Camera); - renderer->SetViewport(AbsoluteRectangle()); - renderer->DrawWorld(m_Parent->RenderQueue); - } - -private: - std::shared_ptr m_World; - std::shared_ptr m_TransformSystem; - std::shared_ptr m_Camera; - EntityID m_CameraEntity; -}; - -} - -#endif // GUI_Viewport_h__ diff --git a/include/GUI/WorldFrame.h b/include/GUI/WorldFrame.h deleted file mode 100644 index f0bc62e..0000000 --- a/include/GUI/WorldFrame.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef GUI_WorldFrame_h__ -#define GUI_WorldFrame_h__ - -#include "GUI/Frame.h" -#include "GUI/Viewport.h" -#include "RenderQueue.h" -#include "World.h" -#include "Systems/TransformSystem.h" -#include "Events/SetViewportCamera.h" -#include "Components/Transform.h" -#include "Components/Model.h" -#include "Components/Sprite.h" -#include "Components/PointLight.h" -#include "Components/BlendMap.h" - - -namespace GUI -{ - -class WorldFrame : public Frame -{ -public: - WorldFrame(Frame* parent, std::string name, std::shared_ptr world) - : Frame(parent, name) - , m_World(world) - { - EVENT_SUBSCRIBE_MEMBER(m_ESetViewportCamera, &WorldFrame::OnSetViewportCamera); - } - - void Update(double dt) override - { - if (!m_TransformSystem) - m_TransformSystem = m_World->GetSystem(); - - m_World->Update(dt); - } - - void Draw(std::shared_ptr renderer) override - { - RenderQueue.Clear(); - renderer->ClearPointLights(); - - for (auto &pair : *m_World->GetEntities()) - { - EntityID entity = pair.first; - - auto templateComponent = m_World->GetComponent(entity); - if (templateComponent) - continue; - - auto transform = m_World->GetComponent(entity); - if (!transform) - continue; - - auto modelComponent = m_World->GetComponent(entity); - if (modelComponent) - { - Model* modelAsset = nullptr; - if (modelComponent->AverageNormals) - { - modelAsset = ResourceManager->Load("AveragedModel", modelComponent->ModelFile); - } - else - { - modelAsset = ResourceManager->Load("Model", modelComponent->ModelFile); - } - - - if (modelAsset) - { - Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity); - glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position) - * glm::toMat4(absoluteTransform.Orientation) - * glm::scale(absoluteTransform.Scale); - auto blendmapComponent = m_World->GetComponent(entity); - if (blendmapComponent) - { - BlendMapTexture RedTexture; - RedTexture.Diffuse = *ResourceManager->Load("Texture", blendmapComponent->TextureRed); - RedTexture.Normal = *ResourceManager->Load("Texture", blendmapComponent->TextureRedNormal); - RedTexture.Specular = *ResourceManager->Load("Texture", blendmapComponent->TextureRedSpecular); - - BlendMapTexture GreenTexture; - GreenTexture.Diffuse = *ResourceManager->Load("Texture", blendmapComponent->TextureGreen); - GreenTexture.Normal = *ResourceManager->Load("Texture", blendmapComponent->TextureGreenNormal); - GreenTexture.Specular = *ResourceManager->Load("Texture", blendmapComponent->TextureGreenSpecular); - - BlendMapTexture BlueTexture; - BlueTexture.Diffuse = *ResourceManager->Load("Texture", blendmapComponent->TextureBlue); - BlueTexture.Normal = *ResourceManager->Load("Texture", blendmapComponent->TextureBlueNormal); - BlueTexture.Specular = *ResourceManager->Load("Texture", blendmapComponent->TextureBlueSpecular); - - float textureRepeat = blendmapComponent->TextureRepeats; - - EnqueueBlendMapModel(modelAsset, RedTexture, GreenTexture, BlueTexture, textureRepeat, modelMatrix, modelComponent->Color); - } - else - { - EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color); - } - - } - } - - auto spriteComponent = m_World->GetComponent(entity); - if (spriteComponent) - { - auto textureAsset = ResourceManager->Load("Texture", spriteComponent->SpriteFile); - if (textureAsset) - { - Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity); - glm::quat orientation2D = glm::angleAxis(glm::eulerAngles(absoluteTransform.Orientation).z, glm::vec3(0, 0, -1)); - glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position) - * glm::toMat4(orientation2D) - * glm::scale(absoluteTransform.Scale); - EnqueueSprite(textureAsset, modelMatrix, spriteComponent->Color); - } - } - - auto pointLightComponent = m_World->GetComponent(entity); - if (pointLightComponent) - { - glm::vec3 position = m_TransformSystem->AbsolutePosition(entity); - renderer->AddPointLightToDraw( - position, - pointLightComponent->Specular, - pointLightComponent->Diffuse, - pointLightComponent->specularExponent, - pointLightComponent->ConstantAttenuation, - pointLightComponent->LinearAttenuation, - pointLightComponent->QuadraticAttenuation, - pointLightComponent->Radius - ); - } - } - - RenderQueue.Sort(); - } - -protected: - std::shared_ptr m_World; - -private: - struct BlendMapTexture - { - GLuint Diffuse; - GLuint Normal; - GLuint Specular; - }; - - EventRelay m_ESetViewportCamera; - bool OnSetViewportCamera(const Events::SetViewportCamera &event) - { - // Search next layer for viewports and update cameras - auto itpair = m_Children[m_Layer + 1].equal_range(event.ViewportFrame); - for (auto it = itpair.first; it != itpair.second; ++it) - { - auto viewportFrame = dynamic_cast(it->second); - if (!viewportFrame) - continue; - - viewportFrame->SetCameraEntity(event.CameraEntity); - } - - return true; - } - - std::shared_ptr m_TransformSystem; - - void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color) - { - for (auto texGroup : model->TextureGroups) - { - ModelJob job; - job.TextureID = texGroup.Texture->ResourceID; - job.DiffuseTexture = *texGroup.Texture; - job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0; - job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0; - job.VAO = model->VAO; - job.StartIndex = texGroup.StartIndex; - job.EndIndex = texGroup.EndIndex; - job.ModelMatrix = modelMatrix; - job.Transparent = transparent; - job.Color = color; - - if(job.Transparent) - { - RenderQueue.Forward.Add(job); - } - else - { - RenderQueue.Deferred.Add(job); - } - } - } - - void EnqueueBlendMapModel(Model* model, BlendMapTexture textureRed, BlendMapTexture textureGreen, BlendMapTexture textureBlue, float textureRepeat, glm::mat4 modelMatrix, glm::vec4 color) - { - for (auto texGroup : model->TextureGroups) - { - BlendMapModelJob job; - job.TextureID = texGroup.Texture->ResourceID; - job.DiffuseTexture = *texGroup.Texture; - job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0; - job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0; - job.BlendMapTextureRed = textureRed.Diffuse; - job.BlendMapTextureRedNormal = textureRed.Normal; - job.BlendMapTextureRedSpecular = textureRed.Specular; - job.BlendMapTextureGreen = textureGreen.Diffuse; - job.BlendMapTextureGreenNormal = textureGreen.Normal; - job.BlendMapTextureGreenSpecular = textureGreen.Specular; - job.BlendMapTextureBlue = textureBlue.Diffuse; - job.BlendMapTextureBlueNormal = textureBlue.Normal; - job.BlendMapTextureBlueSpecular = textureBlue.Specular; - job.TextureRepeat = textureRepeat; - job.VAO = model->VAO; - job.StartIndex = texGroup.StartIndex; - job.EndIndex = texGroup.EndIndex; - job.ModelMatrix = modelMatrix; - job.Color = color; - - RenderQueue.Deferred.Add(job); - } - } - - void EnqueueSprite(Texture* texture, glm::mat4 modelMatrix, glm::vec4 color) - { - SpriteJob job; - job.TextureID = texture->ResourceID; - job.Texture = *texture; - job.ModelMatrix = modelMatrix; - job.Color = color; - - RenderQueue.Forward.Add(job); - } - -}; - -} - -#endif // GUI_WorldFrame_h__ diff --git a/include/Game/MainMenu.h b/include/Game/MainMenu.h new file mode 100644 index 0000000..f2c6a02 --- /dev/null +++ b/include/Game/MainMenu.h @@ -0,0 +1,46 @@ +#ifndef GUI_MAINMENU_H__ +#define GUI_MAINMENU_H__ + +#include "GUI/TextureFrame.h" +#include "Game/MainMenuMain.h" +#include "Game/MainMenuOptions.h" + +namespace dd +{ +namespace GUI +{ + +class MainMenu : public TextureFrame +{ +public: + MainMenu(Frame* parent, std::string name) + : TextureFrame(parent, name) + { + SetTexture("Textures/GUI/Menu/Background.png"); + Width = 675; + Height = 1080; + + m_LeftBanner = new GUI::TextureFrame(this, "MainMenuLeftBanner"); + m_LeftBanner->SetTexture("Textures/GUI/Menu/Left.png"); + m_LeftBanner->Width = 231; + m_LeftBanner->Height = 1080; + + m_MainMenuMain = new GUI::MainMenuMain(this, "MainMenuMain"); + m_MainMenuMain->SetLeft(m_LeftBanner->Right()); + m_MainMenuMain->SetTop(60); + + m_MainMenuOptions = new GUI::MainMenuOptions(this, "MainMenuOptions"); + m_MainMenuOptions->SetLeft(m_LeftBanner->Right()); + m_MainMenuOptions->SetTop(m_MainMenuMain->Bottom()); + } + +private: + TextureFrame* m_LeftBanner; + MainMenuMain* m_MainMenuMain; + MainMenuOptions* m_MainMenuOptions; +}; + +} +} +#endif + diff --git a/include/Game/MainMenuMain.h b/include/Game/MainMenuMain.h new file mode 100644 index 0000000..7181c6e --- /dev/null +++ b/include/Game/MainMenuMain.h @@ -0,0 +1,55 @@ +#ifndef GUI_MAINMENUMAIN_H__ +#define GUI_MAINMENUMAIN_H__ + +#include "GUI/TextureFrame.h" +#include "GUI/Button.h" + +namespace dd +{ +namespace GUI +{ + +class MainMenuMain : public TextureFrame +{ +public: + MainMenuMain(Frame* parent, std::string name) + : TextureFrame(parent, name) + { + Width = 409; + Height = 543; + + m_Title = new GUI::TextureFrame(this, "MainMenuMainTitle"); + m_Title->SetTexture("Textures/GUI/Menu/MainTitle.png"); + + m_SquidoutButton = new GUI::Button(this, "MainMenuMainSquidoutButton"); + m_SquidoutButton->SetTop(m_Title->Bottom()); + m_SquidoutButton->SetTextureReleased("Textures/GUI/Menu/MainSquidout.png"); + m_SquidoutButton->SetTextureHover("Textures/GUI/Menu/MainSquidoutHover.png"); + m_SquidoutButton->SetTexturePressed("Textures/GUI/Menu/MainSquidoutClick.png"); + m_SquidoutButton->SizeToTexture(); + + m_TimeAttackButton = new GUI::Button(this, "MainMenuMainTimeAttackButton"); + m_TimeAttackButton->SetTop(m_SquidoutButton->Bottom()); + m_TimeAttackButton->SetTextureReleased("Textures/GUI/Menu/MainTimeAttack.png"); + m_TimeAttackButton->SetTextureHover("Textures/GUI/Menu/MainTimeAttackHover.png"); + m_TimeAttackButton->SetTexturePressed("Textures/GUI/Menu/MainTimeAttackClick.png"); + m_TimeAttackButton->SizeToTexture(); + + m_OptionsButton = new GUI::Button(this, "MainMenuMainOptionsButton"); + m_OptionsButton->SetTop(m_TimeAttackButton->Bottom()); + m_OptionsButton->SetTextureReleased("Textures/GUI/Menu/MainOptions.png"); + m_OptionsButton->SetTextureHover("Textures/GUI/Menu/MainOptionsHover.png"); + m_OptionsButton->SetTexturePressed("Textures/GUI/Menu/MainOptionsClick.png"); + m_OptionsButton->SizeToTexture(); + } + +private: + TextureFrame* m_Title; + Button* m_SquidoutButton; + Button* m_TimeAttackButton; + Button* m_OptionsButton; +}; + +} +} +#endif diff --git a/include/Game/MainMenuOptions.h b/include/Game/MainMenuOptions.h new file mode 100644 index 0000000..2ac81e7 --- /dev/null +++ b/include/Game/MainMenuOptions.h @@ -0,0 +1,49 @@ +#ifndef GUI_MAINMENUOPTIONS_H__ +#define GUI_MAINMENUOPTIONS_H__ + +#include "GUI/TextureFrame.h" +#include "GUI/Button.h" +#include "GUI/Slider.h" + +namespace dd +{ +namespace GUI +{ + +class MainMenuOptions : public TextureFrame +{ +public: + MainMenuOptions(Frame* parent, std::string name) + : TextureFrame(parent, name) + { + Width = 409; + Height = 1080; + + m_Title = new GUI::TextureFrame(this, "MainMenuOptionsTitle"); + m_Title->SetTexture("Textures/GUI/Menu/OptionsTitle.png"); + + m_TitleSFX = new GUI::TextureFrame(this, "MainMenuOptionsSFXTitle"); + m_TitleSFX->SetTop(m_Title->Bottom() + 20); + m_TitleSFX->SetTexture("Textures/GUI/Menu/OptionsSFXTitle.png"); + m_SFXSlider = new GUI::Slider(this, "MainMenuOptionsSFXSlider"); + m_SFXSlider->X = 66; + m_SFXSlider->SetTop(m_TitleSFX->Bottom()); + m_SFXSlider->SetTexture("Textures/GUI/Menu/SliderBackground.png"); + m_SFXSlider->SetTextureReleased("Textures/GUI/Menu/SliderHandle.png"); + m_SFXSlider->CenterSlider(); + + m_TitleBGM = new GUI::TextureFrame(this, "MainMenuOptionsBGMTitle"); + m_TitleBGM->SetTop(m_TitleSFX->Bottom()); + m_TitleBGM->SetTexture("Textures/GUI/Menu/OptionsBGMTitle.png"); + } + +private: + TextureFrame* m_Title; + TextureFrame* m_TitleSFX; + Slider* m_SFXSlider; + TextureFrame* m_TitleBGM; +}; + +} +} +#endif diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index badf9e0..6834897 100755 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -79,13 +79,10 @@ file(GLOB SOURCE_FILES_Sound ) source_group(Sound FILES ${SOURCE_FILES_Sound}) -#file(GLOB SOURCE_FILES_GUI -# "${INCLUDE_PATH}/GUI/*.h" -# "GUI/*.cpp" -#) -set(SOURCE_FILES_GUI - "${INCLUDE_PATH}/GUI/Frame.h" - ../../include/GUI/Button.h) +file(GLOB SOURCE_FILES_GUI + "${INCLUDE_PATH}/GUI/*.h" + "GUI/*.cpp" +) source_group(GUI FILES ${SOURCE_FILES_GUI}) set(SOURCE_FILES @@ -102,7 +99,8 @@ set(SOURCE_FILES if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") - set(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + set(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS}") endif() add_library(game ${SOURCE_FILES}) diff --git a/src/game/Core/Renderer.cpp b/src/game/Core/Renderer.cpp index 23e9444..0c93e1d 100755 --- a/src/game/Core/Renderer.cpp +++ b/src/game/Core/Renderer.cpp @@ -477,7 +477,6 @@ void dd::Renderer::DebugKeys() void dd::Renderer::DrawGUI(dd::RenderQueue& rq) { glBindFramebuffer(GL_FRAMEBUFFER, m_fbDeferred3); - glEnable(GL_SCISSOR_TEST); glDisable(GL_CULL_FACE); glCullFace(GL_BACK); glDisable(GL_DEPTH_TEST); @@ -492,6 +491,7 @@ void dd::Renderer::DrawGUI(dd::RenderQueue& rq) for (auto &job : rq) { auto frameJob = std::dynamic_pointer_cast(job); if (frameJob) { + FrameJob jobCopy = *(frameJob.get()); glm::mat4 viewMatrix = glm::mat4(1); //frameJob->ViewMatrix; glm::mat4 PV = glm::mat4(1); //frameJob->ProjectionMatrix * viewMatrix; glm::mat4 modelMatrix = glm::mat4(1); //frameJob->ModelMatrix; @@ -510,7 +510,12 @@ void dd::Renderer::DrawGUI(dd::RenderQueue& rq) Rectangle& vp = frameJob->Viewport; glViewport(vp.X, m_Resolution.Height - vp.Y - vp.Height, vp.Width, vp.Height); Rectangle& sc = frameJob->Scissor; - glScissor(sc.X, m_Resolution.Height - sc.Y - sc.Height, sc.Width, sc.Height); + if (sc == Rectangle()) { + glDisable(GL_SCISSOR_TEST); + } else { + glEnable(GL_SCISSOR_TEST); + glScissor(sc.X, m_Resolution.Height - sc.Y - sc.Height, sc.Width, sc.Height); + } glBindVertexArray(m_ScreenQuad); glDrawArrays(GL_TRIANGLES, 0, 6); diff --git a/src/game/Core/Texture.cpp b/src/game/Core/Texture.cpp index f9ba46e..8fb8b33 100755 --- a/src/game/Core/Texture.cpp +++ b/src/game/Core/Texture.cpp @@ -31,6 +31,9 @@ dd::Texture::Texture(std::string path) } } + this->Width = image->Width; + this->Height = image->Height; + GLint format; switch (image->Format) { case Image::ImageFormat::RGB: