light/modules/engine/src/platform/graphics/opengl/render_command.cpp

50 lines
1 KiB
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#include <engine/platform/graphics/opengl/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
namespace Light {
glRenderCommand::glRenderCommand(GLFWwindow *windowHandle): m_window_handle(windowHandle)
2022-03-08 21:19:19 +03:30
{
}
void glRenderCommand::SwapBuffers()
{
glfwSwapBuffers(m_window_handle);
2022-03-08 21:19:19 +03:30
}
2025-07-05 13:28:41 +03:30
void glRenderCommand::ClearBackBuffer(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)
{
glDrawArrays(GL_TRIANGLES, 0, count);
}
void glRenderCommand::DrawIndexed(unsigned int count)
{
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr);
}
void glRenderCommand::DefaultTargetFramebuffer()
{
glBindFramebuffer(GL_FRAMEBUFFER, NULL);
}
2025-07-05 13:28:41 +03:30
void glRenderCommand::SetViewport(
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);
}
} // namespace Light