aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Image.hpp (renamed from include/RenderBackend/OpenGL/Image.hpp)6
-rw-r--r--include/RenderBackend/OpenGL/DeviceMemory.hpp2
-rw-r--r--include/RenderBackend/OpenGL/ShaderProgram.hpp2
-rw-r--r--include/RenderBackend/OpenGL/Texture2D.hpp6
-rw-r--r--include/RenderBackend/OpenGL/Uniform.hpp3
-rw-r--r--include/Triangle.hpp4
-rw-r--r--include/Vec.hpp10
-rw-r--r--include/Vertex.hpp10
-rw-r--r--include/model_loader/ObjModelLoader.hpp5
9 files changed, 27 insertions, 21 deletions
diff --git a/include/RenderBackend/OpenGL/Image.hpp b/include/Image.hpp
index 06f0630..19a5e8b 100644
--- a/include/RenderBackend/OpenGL/Image.hpp
+++ b/include/Image.hpp
@@ -1,8 +1,8 @@
#pragma once
-#include "../../utils.hpp"
-#include "../../types.hpp"
-#include "../../Result.hpp"
+#include "utils.hpp"
+#include "types.hpp"
+#include "Result.hpp"
namespace amalgine
{
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/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);
diff --git a/include/Triangle.hpp b/include/Triangle.hpp
index 5caff05..393c45a 100644
--- a/include/Triangle.hpp
+++ b/include/Triangle.hpp
@@ -5,8 +5,6 @@
namespace amalgine {
class Triangle2D {
public:
- Triangle2D(const Vertex2D &_p1, const Vertex2D &_p2, const Vertex2D &_p3) : p1(_p1), p2(_p2), p3(_p3) {}
-
Vertex2D p1;
Vertex2D p2;
Vertex2D p3;
@@ -14,8 +12,6 @@ namespace amalgine {
class Triangle3D {
public:
- Triangle3D(const Vertex3D &_p1, const Vertex3D &_p2, const Vertex3D &_p3) : p1(_p1), p2(_p2), p3(_p3) {}
-
Vertex3D p1;
Vertex3D p2;
Vertex3D p3;
diff --git a/include/Vec.hpp b/include/Vec.hpp
index 339a98b..87e9bea 100644
--- a/include/Vec.hpp
+++ b/include/Vec.hpp
@@ -3,12 +3,20 @@
#include "types.hpp"
namespace amalgine {
+ struct vec2f {
+ f32 x;
+ f32 y;
+
+ vec2f() : x(0.0f), y(0.0f) {}
+ vec2f(f32 x, f32 y) : x(x), y(y) {}
+ };
+
struct vec3f {
f32 x;
f32 y;
f32 z;
- vec3f() : x(0.0f), y(0.0f) {}
+ vec3f() : x(0.0f), y(0.0f), z(0.0f) {}
vec3f(f32 x, f32 y, f32 z) : x(x), y(y), z(z) {}
};
} \ No newline at end of file
diff --git a/include/Vertex.hpp b/include/Vertex.hpp
index ab98d3b..3526d99 100644
--- a/include/Vertex.hpp
+++ b/include/Vertex.hpp
@@ -5,22 +5,12 @@
namespace amalgine {
class Vertex2D {
public:
- Vertex2D(f32 _x = 0.0f, f32 _y = 0.0f) : x(_x), y(_y)
- {
-
- }
-
f32 x;
f32 y;
};
class Vertex3D {
public:
- Vertex3D(f32 _x = 0.0f, f32 _y = 0.0f, f32 _z = 0.0f) : x(_x), y(_y), z(_z)
- {
-
- }
-
f32 x;
f32 y;
f32 z;
diff --git a/include/model_loader/ObjModelLoader.hpp b/include/model_loader/ObjModelLoader.hpp
index 3cdeb7d..5078244 100644
--- a/include/model_loader/ObjModelLoader.hpp
+++ b/include/model_loader/ObjModelLoader.hpp
@@ -1,11 +1,14 @@
#pragma once
#include "../Triangle.hpp"
+#include "../Vec.hpp"
#include <vector>
namespace amalgine {
+ class Image;
+
class ObjModelLoader {
public:
- static void load_from_file(const char *filepath, std::vector<Triangle3D> &triangles);
+ static void load_from_file(const char *filepath, std::vector<Triangle3D> &triangles, std::vector<vec2f> &texture_coords, Image **image);
};
} \ No newline at end of file