summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-07-04 12:05:00 +0200
committerLaG1924 <lag1924@gmail.com>2021-07-04 12:05:00 +0200
commit2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1 (patch)
treeb3baecdd94f46ca121e9da6f1c93954874a1c191
parentAdded Respawn screen (diff)
downloadAltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.tar
AltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.tar.gz
AltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.tar.bz2
AltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.tar.lz
AltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.tar.xz
AltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.tar.zst
AltCraft-2d2fc243662fe5a24b4e3e388d3a3525a0bd48f1.zip
-rw-r--r--src/Render.cpp18
-rw-r--r--src/Rml.cpp10
-rw-r--r--src/Rml.hpp1
3 files changed, 27 insertions, 2 deletions
diff --git a/src/Render.cpp b/src/Render.cpp
index 6aecd88..a76bba7 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -4,6 +4,7 @@
#include <optick.h>
#include <RmlUi/Core.h>
#include <RmlUi/Lua.h>
+#include <RmlUi/Debugger.h>
#include "Shader.hpp"
#include "AssetManager.hpp"
@@ -293,6 +294,15 @@ void Render::HandleEvents() {
break;
}
+ case SDL_SCANCODE_F8:
+ Rml::Debugger::SetVisible(!Rml::Debugger::IsVisible());
+ break;
+
+ case SDL_SCANCODE_F7: {
+ SetMouseCapture(!isMouseCaptured);
+ break;
+ }
+
default:
break;
}
@@ -358,6 +368,11 @@ void Render::HandleEvents() {
break;
}
+ case SDL_MOUSEWHEEL: {
+ rmlContext->ProcessMouseWheel(-event.wheel.y, rmlKeymods);
+ break;
+ }
+
case SDL_TEXTINPUT: {
rmlContext->ProcessTextInput(Rml::String(event.text.text));
break;
@@ -567,4 +582,7 @@ void Render::InitRml() {
Rml::Lua::Initialise(PluginSystem::GetLuaState());
rmlContext = Rml::CreateContext("default", Rml::Vector2i(renderState.WindowWidth, renderState.WindowHeight));
+
+ if (!Rml::Debugger::Initialise(rmlContext))
+ LOG(WARNING) << "Rml debugger not initialized";
}
diff --git a/src/Rml.cpp b/src/Rml.cpp
index 6ed83c1..179d4b9 100644
--- a/src/Rml.cpp
+++ b/src/Rml.cpp
@@ -117,11 +117,15 @@ void RmlRenderInterface::RenderGeometry(Rml::Vertex* vertices, int num_vertices,
}
void RmlRenderInterface::EnableScissorRegion(bool enable) {
-
+ if (enable)
+ glEnable(GL_SCISSOR_TEST);
+ else
+ glDisable(GL_SCISSOR_TEST);
}
void RmlRenderInterface::SetScissorRegion(int x, int y, int width, int height) {
-
+ glScissor(x, vpHeight - (y + height), width, height);
+ glCheckError();
}
bool RmlRenderInterface::LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) {
@@ -161,6 +165,8 @@ void RmlRenderInterface::Update(unsigned int windowWidth, unsigned int windowHei
AssetManager::GetAsset<AssetShader>("/altcraft/shaders/rmltex")->shader->SetUniform("viewportSize", windowWidth, windowHeight);
AssetManager::GetAsset<AssetShader>("/altcraft/shaders/rmltex")->shader->SetUniform("fontTexture", 0);
glCheckError();
+ vpWidth = windowWidth;
+ vpHeight = windowHeight;
}
Rml::FileHandle RmlFileInterface::Open(const Rml::String& path) {
diff --git a/src/Rml.hpp b/src/Rml.hpp
index 6e4d857..edcdc8b 100644
--- a/src/Rml.hpp
+++ b/src/Rml.hpp
@@ -34,6 +34,7 @@ class RmlRenderInterface : public Rml::RenderInterface {
GLuint Vao, Vbo, Ebo;
+ unsigned int vpWidth, vpHeight;
public:
RmlRenderInterface(RenderState &renderState);