aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL
diff options
context:
space:
mode:
Diffstat (limited to 'include/RenderBackend/OpenGL')
-rw-r--r--include/RenderBackend/OpenGL/DeviceMemory.hpp3
-rw-r--r--include/RenderBackend/OpenGL/ShaderProgram.hpp7
-rw-r--r--include/RenderBackend/OpenGL/Uniform.hpp29
3 files changed, 37 insertions, 2 deletions
diff --git a/include/RenderBackend/OpenGL/DeviceMemory.hpp b/include/RenderBackend/OpenGL/DeviceMemory.hpp
index c9c8b23..3ccd0c9 100644
--- a/include/RenderBackend/OpenGL/DeviceMemory.hpp
+++ b/include/RenderBackend/OpenGL/DeviceMemory.hpp
@@ -2,7 +2,7 @@
#include "../../DataView.hpp"
#include "../../utils.hpp"
-#include "../../Triangle2D.hpp"
+#include "../../Triangle.hpp"
namespace amalgine {
enum class DeviceMemoryType {
@@ -37,6 +37,7 @@ namespace amalgine {
~DeviceMemory();
//void copy(const DataView<f32> &data, StorageType storageType, PrimitiveType primitiveType = PrimitiveType::TRIANGLE);
void copy(const DataView<Triangle2D> &triangles, StorageType storageType);
+ void copy(const DataView<Triangle3D> &triangles, StorageType storageType);
void draw();
DeviceMemoryType get_type() const { return type; }
diff --git a/include/RenderBackend/OpenGL/ShaderProgram.hpp b/include/RenderBackend/OpenGL/ShaderProgram.hpp
index ca96d0c..f1fea00 100644
--- a/include/RenderBackend/OpenGL/ShaderProgram.hpp
+++ b/include/RenderBackend/OpenGL/ShaderProgram.hpp
@@ -4,9 +4,13 @@
#include "../../types.hpp"
#include "../../utils.hpp"
#include "../../Vec.hpp"
+#include "Uniform.hpp"
#include "DeviceMemory.hpp"
+
#include <vector>
#include <memory>
+#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/type_ptr.hpp>
namespace amalgine {
class Shader;
@@ -17,7 +21,8 @@ namespace amalgine {
public:
~ShaderProgram();
static Result<std::unique_ptr<ShaderProgram>> build(const std::vector<Shader*> &shaders);
- int set_uniform(const char *name, const vec3f &value);
+
+ Result<Uniform> get_uniform_by_name(const char *name);
int set_vertex_input(const char *name, const DeviceMemory &data);
void use();
diff --git a/include/RenderBackend/OpenGL/Uniform.hpp b/include/RenderBackend/OpenGL/Uniform.hpp
new file mode 100644
index 0000000..288c9b8
--- /dev/null
+++ b/include/RenderBackend/OpenGL/Uniform.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "../../Result.hpp"
+#include "../../types.hpp"
+#include "../../utils.hpp"
+#include "../../Vec.hpp"
+
+#include <glm/gtc/type_ptr.hpp>
+
+namespace amalgine {
+ class Uniform {
+ DISABLE_COPY(Uniform)
+ friend class ShaderProgram;
+ friend class Result<Uniform>;
+ public:
+ Uniform(Uniform&&) = default;
+ ~Uniform();
+
+ void set(const vec3f &value);
+ void set(const glm::mat4 &value);
+ private:
+ Uniform(){}
+ Uniform(i32 uniform_id, u32 shader_program_id);
+ void use();
+ private:
+ i32 uniform_id;
+ u32 program_id;
+ };
+}