hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/rendering
diff options
context:
space:
mode:
Diffstat (limited to 'src/rendering')
-rw-r--r--src/rendering/renderer.h6
-rw-r--r--src/rendering/texture.cpp32
-rw-r--r--src/rendering/texture.h30
3 files changed, 68 insertions, 0 deletions
diff --git a/src/rendering/renderer.h b/src/rendering/renderer.h
index 09e9521..7bbdd4b 100644
--- a/src/rendering/renderer.h
+++ b/src/rendering/renderer.h
@@ -34,6 +34,7 @@ namespace Donut
virtual void set_clear_color(const glm::vec4& color) = 0;
virtual void clear() = 0;
virtual void enable_depth_test() = 0;
+ virtual void set_face_culling(bool enabled) = 0;
virtual void draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, uint32_t index_count = 0) = 0;
@@ -72,6 +73,11 @@ namespace Donut
s_renderer_api->enable_depth_test();
}
+ inline static void set_face_culling(bool enabled)
+ {
+ s_renderer_api->set_face_culling(enabled);
+ }
+
inline static void draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, uint32_t index_count = 0)
{
s_renderer_api->draw_indexed(vertex_array, index_count);
diff --git a/src/rendering/texture.cpp b/src/rendering/texture.cpp
new file mode 100644
index 0000000..9603034
--- /dev/null
+++ b/src/rendering/texture.cpp
@@ -0,0 +1,32 @@
+#include "texture.h"
+#include "renderer.h"
+#include "../platform/opengl/opengl_texture.h"
+
+namespace Donut
+{
+ std::shared_ptr<Texture2D> Texture2D::create(uint32_t width, uint32_t height)
+ {
+ switch (Renderer::get_api())
+ {
+ case RendererAPI::API::OpenGL:
+ return std::make_shared<OpenGLTexture2D>(width, height);
+ case RendererAPI::API::None:
+ return nullptr;
+ default:
+ return nullptr;
+ }
+ }
+
+ std::shared_ptr<Texture2D> Texture2D::create(const std::string& path)
+ {
+ switch (Renderer::get_api())
+ {
+ case RendererAPI::API::OpenGL:
+ return std::make_shared<OpenGLTexture2D>(path);
+ case RendererAPI::API::None:
+ return nullptr;
+ default:
+ return nullptr;
+ }
+ }
+};
diff --git a/src/rendering/texture.h b/src/rendering/texture.h
new file mode 100644
index 0000000..e3c53f8
--- /dev/null
+++ b/src/rendering/texture.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <memory>
+#include <string>
+#include <glm/glm.hpp>
+
+namespace Donut
+{
+ class Texture
+ {
+ public:
+ virtual ~Texture() = default;
+
+ virtual uint32_t get_width() const = 0;
+ virtual uint32_t get_height() const = 0;
+ virtual uint32_t get_renderer_id() const = 0;
+
+ virtual void set_data(void* data, uint32_t size) = 0;
+ virtual void bind(uint32_t slot = 0) const = 0;
+
+ virtual bool operator==(const Texture& other) const = 0;
+ };
+
+ class Texture2D : public Texture
+ {
+ public:
+ static std::shared_ptr<Texture2D> create(uint32_t width, uint32_t height);
+ static std::shared_ptr<Texture2D> create(const std::string& path);
+ };
+};