hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/platform/opengl
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2025-08-12 18:41:26 +0200
committerhachem <im@hachem.wtf>2025-08-12 18:41:26 +0200
commit7e06a916e6a385c37075abcb83d14b8c1fef7bc0 (patch)
tree8054d96e89d43b0f98b75af726079d723a70ca2a /src/platform/opengl
parent50cdd344a3ed87c75a67739e2ffd34762e9b0895 (diff)
feat: camera
Diffstat (limited to 'src/platform/opengl')
-rw-r--r--src/platform/opengl/opengl_renderer_api.cpp5
-rw-r--r--src/platform/opengl/opengl_renderer_api.h1
-rw-r--r--src/platform/opengl/opengl_shader.cpp3
-rw-r--r--src/platform/opengl/opengl_vertex_array.cpp2
4 files changed, 9 insertions, 2 deletions
diff --git a/src/platform/opengl/opengl_renderer_api.cpp b/src/platform/opengl/opengl_renderer_api.cpp
index 9fb911a..49b4e53 100644
--- a/src/platform/opengl/opengl_renderer_api.cpp
+++ b/src/platform/opengl/opengl_renderer_api.cpp
@@ -25,6 +25,11 @@ namespace Donut
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
+ void OpenGLRendererAPI::enable_depth_test()
+ {
+ glEnable(GL_DEPTH_TEST);
+ }
+
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();
diff --git a/src/platform/opengl/opengl_renderer_api.h b/src/platform/opengl/opengl_renderer_api.h
index 26e779a..30be426 100644
--- a/src/platform/opengl/opengl_renderer_api.h
+++ b/src/platform/opengl/opengl_renderer_api.h
@@ -13,6 +13,7 @@ namespace Donut
virtual void set_viewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
virtual void set_clear_color(const glm::vec4& color) override;
virtual void clear() override;
+ virtual void enable_depth_test() override;
virtual void draw_indexed(const std::shared_ptr<VertexArray>& vertex_array, uint32_t index_count = 0) override;
};
diff --git a/src/platform/opengl/opengl_shader.cpp b/src/platform/opengl/opengl_shader.cpp
index e2e6279..39e582a 100644
--- a/src/platform/opengl/opengl_shader.cpp
+++ b/src/platform/opengl/opengl_shader.cpp
@@ -65,7 +65,8 @@ namespace Donut
const char* type_token = "#type";
size_t type_token_length = strlen(type_token);
size_t pos = source.find(type_token, 0);
- while (pos != std::string::npos) {
+ while (pos != std::string::npos)
+ {
size_t eol = source.find_first_of("\r\n", pos);
size_t begin = pos + type_token_length + 1;
std::string type = source.substr(begin, eol - begin);
diff --git a/src/platform/opengl/opengl_vertex_array.cpp b/src/platform/opengl/opengl_vertex_array.cpp
index 14d4e63..c57479b 100644
--- a/src/platform/opengl/opengl_vertex_array.cpp
+++ b/src/platform/opengl/opengl_vertex_array.cpp
@@ -39,7 +39,7 @@ namespace Donut
element.type,
element.normalized ? GL_TRUE : GL_FALSE,
layout.get_stride(),
- (const void*)element.offset);
+ reinterpret_cast<const void*>(static_cast<uintptr_t>(element.offset)));
m_vertex_buffer_index++;
}