ADD: Dimming textures + pushing newGameLayer
All checks were successful
Tests / test (push) Successful in 2m36s
All checks were successful
Tests / test (push) Successful in 2m36s
This commit is contained in:
parent
8d6a314a3c
commit
def763d6ae
@ -14,6 +14,7 @@ uniform float tintStrength; // 0.0 = aus
|
|||||||
uniform bool hasForeground;
|
uniform bool hasForeground;
|
||||||
uniform bool hasBackground;
|
uniform bool hasBackground;
|
||||||
|
|
||||||
|
uniform float dimFactor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 fg = hasForeground ? texture(guiTexture, textureCoords) : vec4(0.0);
|
vec4 fg = hasForeground ? texture(guiTexture, textureCoords) : vec4(0.0);
|
||||||
@ -28,4 +29,5 @@ void main(void) {
|
|||||||
textureColor.rgb = mix(textureColor.rgb, tintColor, tintStrength);
|
textureColor.rgb = mix(textureColor.rgb, tintColor, tintStrength);
|
||||||
|
|
||||||
color = textureColor;
|
color = textureColor;
|
||||||
|
color *= dimFactor;
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@
|
|||||||
#include "SceneManager.h"
|
#include "SceneManager.h"
|
||||||
#include "../../renderer/loader/AssetManager.h"
|
#include "../../renderer/loader/AssetManager.h"
|
||||||
#include "../../renderer/GUIRenderer.h"
|
#include "../../renderer/GUIRenderer.h"
|
||||||
|
#include "../../renderer/RenderContext.h"
|
||||||
#include "../gui/uiComponent/UiImage.h"
|
#include "../gui/uiComponent/UiImage.h"
|
||||||
#include "../gui/uiComponent/UiProgressbar.h"
|
#include "../gui/uiComponent/UiProgressbar.h"
|
||||||
#include "../gui/uiMain/UiContainer.h"
|
#include "../gui/uiMain/UiContainer.h"
|
||||||
@ -23,7 +24,8 @@ void SplashScreenLayer::onRender() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto guis = renderBundle.getGUITextures();
|
auto guis = renderBundle.getGUITextures();
|
||||||
guiRenderer->render(guis);
|
RenderContext ctx = RenderContext::Default();
|
||||||
|
guiRenderer->render(guis, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplashScreenLayer::onUpdate() {
|
void SplashScreenLayer::onUpdate() {
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "RenderContext.h"
|
||||||
#include "components/UiRenderBundle.h"
|
#include "components/UiRenderBundle.h"
|
||||||
#include "../toolbox/MathUtils.h"
|
#include "../toolbox/MathUtils.h"
|
||||||
#include "loader/Loader.h"
|
#include "loader/Loader.h"
|
||||||
@ -17,8 +18,9 @@ GUIRenderer::GUIRenderer(Loader &loader) {
|
|||||||
rawModel = std::make_unique<RawModel>(model);
|
rawModel = std::make_unique<RawModel>(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIRenderer::render(std::vector<std::shared_ptr<GUITexture>>& gui_textures) {
|
void GUIRenderer::render(std::vector<std::shared_ptr<GUITexture>>& gui_textures, RenderContext& ctx) {
|
||||||
guiShader.start();
|
guiShader.start();
|
||||||
|
guiShader.loadDimFactor(ctx.dimFactor);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
#include "shaders/GUIShader.h"
|
#include "shaders/GUIShader.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct RenderContext;
|
||||||
class Loader;
|
class Loader;
|
||||||
|
|
||||||
class GUIRenderer {
|
class GUIRenderer {
|
||||||
@ -22,7 +22,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
GUIShader guiShader;
|
GUIShader guiShader;
|
||||||
explicit GUIRenderer(Loader& loader);
|
explicit GUIRenderer(Loader& loader);
|
||||||
void render(std::vector<std::shared_ptr<GUITexture>> &gui_textures);
|
void render(std::vector<std::shared_ptr<GUITexture>> &gui_textures, RenderContext& ctx);
|
||||||
|
|
||||||
void cleanUp();
|
void cleanUp();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -24,6 +24,10 @@ void GUIShader::loadBackgroundTexture(int textureBankIndex, bool useTexture) {
|
|||||||
ShaderProgram::loadInt(getUniformLocation("backgroundTexture"), textureBankIndex);
|
ShaderProgram::loadInt(getUniformLocation("backgroundTexture"), textureBankIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIShader::loadDimFactor(float dim_factor) {
|
||||||
|
ShaderProgram::loadFloat(getUniformLocation("dimFactor"), dim_factor);
|
||||||
|
}
|
||||||
|
|
||||||
void GUIShader::bindAttributes() const {
|
void GUIShader::bindAttributes() const {
|
||||||
ShaderProgram::bindAttribute(0, "position");
|
ShaderProgram::bindAttribute(0, "position");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,8 @@ public:
|
|||||||
void loadForegroundTexture(int textureBankIndex, bool useTexture);
|
void loadForegroundTexture(int textureBankIndex, bool useTexture);
|
||||||
void loadBackgroundTexture(int textureBankIndex, bool useTexture);
|
void loadBackgroundTexture(int textureBankIndex, bool useTexture);
|
||||||
|
|
||||||
|
void loadDimFactor(float dim_factor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static const std::string VERTEX_FILE = "assets/shaders/guiVertexShader.glsl";
|
inline static const std::string VERTEX_FILE = "assets/shaders/guiVertexShader.glsl";
|
||||||
inline static const std::string FRAGMENT_FILE = "assets/shaders/guiFragmentShader.glsl";
|
inline static const std::string FRAGMENT_FILE = "assets/shaders/guiFragmentShader.glsl";
|
||||||
|
|||||||
@ -156,11 +156,11 @@ void UILayer::onRender() {
|
|||||||
if (rootContainer) {
|
if (rootContainer) {
|
||||||
rootContainer->collectRenderData(renderBundle);
|
rootContainer->collectRenderData(renderBundle);
|
||||||
}
|
}
|
||||||
|
RenderContext ctx = RenderContext::Default();
|
||||||
auto guis = renderBundle.getGUITextures();
|
auto guis = renderBundle.getGUITextures();
|
||||||
guiRenderer->render(guis);
|
guiRenderer->render(guis, ctx);
|
||||||
|
|
||||||
auto renderTexts = renderBundle.getGUITexts();
|
auto renderTexts = renderBundle.getGUITexts();
|
||||||
RenderContext ctx = RenderContext::Default();
|
|
||||||
textRenderer->renderGuiTexts(renderTexts, Application::getInstance().getWindow().GetWidth(), Application::getInstance().getWindow().GetHeight(), ctx);
|
textRenderer->renderGuiTexts(renderTexts, Application::getInstance().getWindow().GetWidth(), Application::getInstance().getWindow().GetHeight(), ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,8 +30,15 @@ void MainUiLayer::onAttach() {
|
|||||||
btnStyle2.width = SizeValue(350, SizeUnit::Pixels);
|
btnStyle2.width = SizeValue(350, SizeUnit::Pixels);
|
||||||
btnStyle2.height = SizeValue(90, SizeUnit::Pixels);
|
btnStyle2.height = SizeValue(90, SizeUnit::Pixels);
|
||||||
|
|
||||||
rootContainer->addChild<UiButton>(std::make_unique<UiButton>(AssetManager::getTexture("btn_background")->getTextureID(), "New Game",
|
auto newGameBtn = rootContainer->addChild<UiButton>(std::make_unique<UiButton>(AssetManager::getTexture("btn_background")->getTextureID(), "New Game",
|
||||||
*AssetManager::getUiTheme("default")->large, btnStyle2));
|
*AssetManager::getUiTheme("default")->large, btnStyle2));
|
||||||
|
newGameBtn->addMouseListener([this](const MouseEventData& eventData) {
|
||||||
|
if (eventData.isCompleteClick(MouseButton::LEFT)) {
|
||||||
|
auto newGameContainer = std::make_unique<UiContainer>();
|
||||||
|
|
||||||
|
uiStack->push(std::move(newGameContainer));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
LayoutStyle btnStyle3;
|
LayoutStyle btnStyle3;
|
||||||
btnStyle3.margin.top = SizeValue(15, SizeUnit::Pixels);
|
btnStyle3.margin.top = SizeValue(15, SizeUnit::Pixels);
|
||||||
@ -68,7 +75,7 @@ void MainUiLayer::onRender() {
|
|||||||
if (uiStack) {
|
if (uiStack) {
|
||||||
for (const auto& panel : uiStack->getPanels()) {
|
for (const auto& panel : uiStack->getPanels()) {
|
||||||
RenderContext ctx;
|
RenderContext ctx;
|
||||||
if (!uiStack->isTop(panel.get())) {
|
if (uiStack->isTop(panel.get())) {
|
||||||
ctx = RenderContext::Default();
|
ctx = RenderContext::Default();
|
||||||
} else {
|
} else {
|
||||||
ctx = RenderContext::Dimmed(uiConfig.backgroundDim);
|
ctx = RenderContext::Dimmed(uiConfig.backgroundDim);
|
||||||
@ -78,7 +85,7 @@ void MainUiLayer::onRender() {
|
|||||||
panel->collectRenderData(renderBundle);
|
panel->collectRenderData(renderBundle);
|
||||||
|
|
||||||
auto guis = renderBundle.getGUITextures();
|
auto guis = renderBundle.getGUITextures();
|
||||||
guiRenderer->render(guis);
|
guiRenderer->render(guis, ctx);
|
||||||
|
|
||||||
const auto renderTexts = renderBundle.getGUITexts();
|
const auto renderTexts = renderBundle.getGUITexts();
|
||||||
textRenderer->renderGuiTexts(renderTexts, static_cast<float>(Application::getInstance().getWindow().GetWidth()),
|
textRenderer->renderGuiTexts(renderTexts, static_cast<float>(Application::getInstance().getWindow().GetWidth()),
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
#include "../../../engine/layer/Layer.h"
|
#include "../../../engine/layer/Layer.h"
|
||||||
#include "../../../engine/renderer/GUIRenderer.h"
|
#include "../../../engine/renderer/GUIRenderer.h"
|
||||||
#include "../../../engine/renderer/loader/Loader.h"
|
#include "../../../engine/renderer/loader/Loader.h"
|
||||||
#include "../../../engine/core/gui/uiMain/UiContainer.h"
|
|
||||||
#include "../../../engine/core/gui/uiMain/UiStack.h"
|
#include "../../../engine/core/gui/uiMain/UiStack.h"
|
||||||
#include "../../../engine/renderer/TextRenderer.h"
|
#include "../../../engine/renderer/TextRenderer.h"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user