aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend
diff options
context:
space:
mode:
Diffstat (limited to 'include/RenderBackend')
-rw-r--r--include/RenderBackend/OpenGL/DeviceMemory.hpp2
-rw-r--r--include/RenderBackend/OpenGL/Image.hpp26
-rw-r--r--include/RenderBackend/OpenGL/ShaderProgram.hpp2
-rw-r--r--include/RenderBackend/OpenGL/Texture2D.hpp6
-rw-r--r--include/RenderBackend/OpenGL/Uniform.hpp3
5 files changed, 11 insertions, 28 deletions
diff --git a/include/RenderBackend/OpenGL/DeviceMemory.hpp b/include/RenderBackend/OpenGL/DeviceMemory.hpp
index 3ccd0c9..3e0fede 100644
--- a/include/RenderBackend/OpenGL/DeviceMemory.hpp
+++ b/include/RenderBackend/OpenGL/DeviceMemory.hpp
@@ -3,6 +3,7 @@
#include "../../DataView.hpp"
#include "../../utils.hpp"
#include "../../Triangle.hpp"
+#include "../../Vec.hpp"
namespace amalgine {
enum class DeviceMemoryType {
@@ -36,6 +37,7 @@ namespace amalgine {
~DeviceMemory();
//void copy(const DataView<f32> &data, StorageType storageType, PrimitiveType primitiveType = PrimitiveType::TRIANGLE);
+ void copy(const DataView<vec2f> &texture_coords, StorageType storageType);
void copy(const DataView<Triangle2D> &triangles, StorageType storageType);
void copy(const DataView<Triangle3D> &triangles, StorageType storageType);
void draw();
diff --git a/include/RenderBackend/OpenGL/Image.hpp b/include/RenderBackend/OpenGL/Image.hpp
deleted file mode 100644
index 06f0630..0000000
--- a/include/RenderBackend/OpenGL/Image.hpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include "../../utils.hpp"
-#include "../../types.hpp"
-#include "../../Result.hpp"
-
-namespace amalgine
-{
- class Image
- {
- DISABLE_COPY(Image)
- public:
- static Result<Image*> loadFromFile(const char *filepath);
- ~Image();
-
- const unsigned char* getData() const;
- i32 getWidth() const;
- i32 getHeight() const;
- private:
- Image(unsigned char *_imageData, i32 width, i32 height);
- private:
- unsigned char *imageData;
- i32 width;
- i32 height;
- };
-}
diff --git a/include/RenderBackend/OpenGL/ShaderProgram.hpp b/include/RenderBackend/OpenGL/ShaderProgram.hpp
index f1fea00..177e43c 100644
--- a/include/RenderBackend/OpenGL/ShaderProgram.hpp
+++ b/include/RenderBackend/OpenGL/ShaderProgram.hpp
@@ -23,7 +23,7 @@ namespace amalgine {
static Result<std::unique_ptr<ShaderProgram>> build(const std::vector<Shader*> &shaders);
Result<Uniform> get_uniform_by_name(const char *name);
- int set_vertex_input(const char *name, const DeviceMemory &data);
+ int set_input_data(const char *name, const DeviceMemory &data);
void use();
private:
diff --git a/include/RenderBackend/OpenGL/Texture2D.hpp b/include/RenderBackend/OpenGL/Texture2D.hpp
index 9f7c855..48b613b 100644
--- a/include/RenderBackend/OpenGL/Texture2D.hpp
+++ b/include/RenderBackend/OpenGL/Texture2D.hpp
@@ -11,9 +11,13 @@ namespace amalgine
{
DISABLE_COPY(Texture2D)
public:
+ // Not thread safe
Texture2D(Image *image);
~Texture2D();
+
+ i32 get_texture_id() const { return texture_id; }
private:
- u32 textureId;
+ i32 texture_id;
+ u32 texture_ref;
};
}
diff --git a/include/RenderBackend/OpenGL/Uniform.hpp b/include/RenderBackend/OpenGL/Uniform.hpp
index 288c9b8..dbffa03 100644
--- a/include/RenderBackend/OpenGL/Uniform.hpp
+++ b/include/RenderBackend/OpenGL/Uniform.hpp
@@ -4,6 +4,7 @@
#include "../../types.hpp"
#include "../../utils.hpp"
#include "../../Vec.hpp"
+#include "Texture2D.hpp"
#include <glm/gtc/type_ptr.hpp>
@@ -16,8 +17,10 @@ namespace amalgine {
Uniform(Uniform&&) = default;
~Uniform();
+ void set(float value);
void set(const vec3f &value);
void set(const glm::mat4 &value);
+ void set(const Texture2D &texture);
private:
Uniform(){}
Uniform(i32 uniform_id, u32 shader_program_id);