hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/platform/opengl/opengl_renderer_api.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/opengl/opengl_renderer_api.cpp')
-rw-r--r--src/platform/opengl/opengl_renderer_api.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/platform/opengl/opengl_renderer_api.cpp b/src/platform/opengl/opengl_renderer_api.cpp
new file mode 100644
index 0000000..9fb911a
--- /dev/null
+++ b/src/platform/opengl/opengl_renderer_api.cpp
@@ -0,0 +1,34 @@
+#include "opengl_renderer_api.h"
+#include <glad/glad.h>
+
+namespace Donut
+{
+ void OpenGLRendererAPI::init()
+ {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_DEPTH_TEST);
+ }
+
+ void OpenGLRendererAPI::set_viewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
+ {
+ glViewport(x, y, width, height);
+ }
+
+ void OpenGLRendererAPI::set_clear_color(const glm::vec4& color)
+ {
+ glClearColor(color.r, color.g, color.b, color.a);
+ }
+
+ void OpenGLRendererAPI::clear()
+ {
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ }
+
+ void OpenGLRendererAPI::draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, uint32_t index_count)
+ {
+ uint32_t count = index_count ? index_count : vertex_array->get_index_buffer()->get_count();
+ glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ }
+};