light/modules/renderer/src/gl/render_command.cpp

50 lines
1 KiB
C++
Raw Normal View History

#include <renderer/gl/render_command.hpp>
#include <glad/gl.h>
2022-03-08 21:19:19 +03:30
#ifndef DONT_FUCKING_ORDER_THESSE_PLEASE_FOR_THE_LOVE_OF_GOD_CLANG_FORMAT
#include <GLFW/glfw3.h>
#endif
2021-05-26 18:39:40 +04:30
2025-07-11 00:05:48 +03:30
namespace lt {
2021-05-26 18:39:40 +04:30
glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_window_handle(windowHandle)
2022-03-08 21:19:19 +03:30
{
}
void glRenderCommand::swap_buffers()
2022-03-08 21:19:19 +03:30
{
glfwSwapBuffers(m_window_handle);
2022-03-08 21:19:19 +03:30
}
void glRenderCommand::clear_back_buffer(const glm::vec4 &clearColor)
2022-03-08 21:19:19 +03:30
{
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
glClear(GL_COLOR_BUFFER_BIT);
}
void glRenderCommand::draw(unsigned int count)
2022-03-08 21:19:19 +03:30
{
glDrawArrays(GL_TRIANGLES, 0, count);
}
void glRenderCommand::draw_indexed(unsigned int count)
2022-03-08 21:19:19 +03:30
{
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr);
}
void glRenderCommand::default_target_framebuffer()
2022-03-08 21:19:19 +03:30
{
glBindFramebuffer(GL_FRAMEBUFFER, NULL);
}
void glRenderCommand::set_viewport(
2025-07-05 13:28:41 +03:30
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height
)
2022-03-08 21:19:19 +03:30
{
glViewport(x, y, width, height);
}
2025-07-11 00:05:48 +03:30
} // namespace lt