summary refs log tree commit diff
path: root/src/GFX/Shading/Program.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-02-12 12:55:11 +0100
committerMel <einebeere@gmail.com>2024-02-12 12:55:11 +0100
commitd2b5fc5b3bc648afffa42375706429685ac63794 (patch)
treea2dfbb241e1d46e5616c5884e5f3d685de2a2cb6 /src/GFX/Shading/Program.cpp
parent588c7e87b7cab270698d43ca5c22d67793ae5fc4 (diff)
downloadmeowcraft-d2b5fc5b3bc648afffa42375706429685ac63794.tar.zst
meowcraft-d2b5fc5b3bc648afffa42375706429685ac63794.zip
Split rendering into own thread and sync through render action lists
Diffstat (limited to 'src/GFX/Shading/Program.cpp')
-rw-r--r--src/GFX/Shading/Program.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/GFX/Shading/Program.cpp b/src/GFX/Shading/Program.cpp
index ff10012..fe5d576 100644
--- a/src/GFX/Shading/Program.cpp
+++ b/src/GFX/Shading/Program.cpp
@@ -2,6 +2,8 @@
 #include <stdexcept>
 #include "Program.hpp"
 
+#include "../../Common/Assert.hpp"
+
 namespace MC::GFX::Shading {
 
 Program::Program(Shader vertex, Shader fragment) {
@@ -26,6 +28,7 @@ Program::Program(Shader vertex, Shader fragment) {
 }
 
 void Program::bind() const {
+    ASSERT(m_program != 0, "Program is not initialized");
     glUseProgram(m_program);
 }
 
@@ -33,10 +36,12 @@ void Program::unbind() const {
     glUseProgram(0);
 }
 
-Uniform Program::uniform(const std::string& name) const {
+std::optional<Uniform> Program::uniform(const std::string& name) const {
+    ASSERT(m_program != 0, "Program is not initialized");
     auto index = glGetUniformLocation(m_program, name.c_str());
 
-    return {name, static_cast<U32>(index)};
+    if (index == -1) return {};
+    return {{name, static_cast<U32>(index)}};
 }
 
 U32 Program::get() const {