From e4d073947d09634e95325ddaf8f1615f85e85901 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 15 Feb 2020 01:36:41 +0100 Subject: Load texture in obj model loader.. broken --- include/RenderBackend/OpenGL/DeviceMemory.hpp | 2 ++ include/RenderBackend/OpenGL/Image.hpp | 26 -------------------------- include/RenderBackend/OpenGL/ShaderProgram.hpp | 2 +- include/RenderBackend/OpenGL/Texture2D.hpp | 6 +++++- include/RenderBackend/OpenGL/Uniform.hpp | 3 +++ 5 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 include/RenderBackend/OpenGL/Image.hpp (limited to 'include/RenderBackend') 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 &data, StorageType storageType, PrimitiveType primitiveType = PrimitiveType::TRIANGLE); + void copy(const DataView &texture_coords, StorageType storageType); void copy(const DataView &triangles, StorageType storageType); void copy(const DataView &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 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> build(const std::vector &shaders); Result 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 @@ -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); -- cgit v1.2.3