1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 10:35:00 +00:00
serenity/Userland/Libraries/LibAccelGfx/Program.cpp
Aliaksandr Kalenik 048e179572 LibAccelGfx: Use wrapping functions with error check for OpenGL calls
This change introduces GL.h with error check wrappers for all the
OpenGL functions we used so far.

For now, the error check is simply:
`VERIFY(glGetError() == GL_NO_ERROR);`
but that is better than continuing execution after encounting an error.
2023-11-11 08:47:12 +01:00

44 lines
1,018 B
C++

/*
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Assertions.h>
#include <AK/Format.h>
#include <LibAccelGfx/GL.h>
#include <LibAccelGfx/Program.h>
namespace AccelGfx {
Program Program::create(char const* vertex_shader_source, char const* fragment_shader_source)
{
auto vertex_shader = GL::create_shader(GL::ShaderType::Vertex, vertex_shader_source);
auto fragment_shader = GL::create_shader(GL::ShaderType::Fragment, fragment_shader_source);
auto program = GL::create_program(vertex_shader, fragment_shader);
return Program { program };
}
void Program::use()
{
GL::use_program(m_program);
}
GL::VertexAttribute Program::get_attribute_location(char const* name)
{
return GL::get_attribute_location(m_program, name);
}
GL::Uniform Program::get_uniform_location(char const* name)
{
return GL::get_uniform_location(m_program, name);
}
Program::~Program()
{
GL::delete_program(m_program);
}
}