This commit is contained in:
offtkp 2024-07-31 03:16:38 +03:00
parent 78ac8d2c0d
commit ab4c9b2ae5
7 changed files with 100 additions and 65 deletions

View file

@ -29,6 +29,7 @@
#include <string_view>
#include <type_traits>
#include <utility>
#include "helpers.hpp"
#include <glad/gl.h>
@ -432,6 +433,24 @@ namespace OpenGL {
return m_handle != 0;
}
bool createFromBinary(const std::vector<u8>& binary, GLenum format) {
m_handle = glCreateProgram();
glProgramBinary(m_handle, format, binary.data(), binary.size());
GLint success;
glGetProgramiv(m_handle, GL_LINK_STATUS, &success);
if (!success) {
char buf[4096];
glGetProgramInfoLog(m_handle, 4096, nullptr, buf);
fprintf(stderr, "Failed to link program\nError: %s\n", buf);
glDeleteProgram(m_handle);
m_handle = 0;
}
return m_handle != 0;
}
GLuint handle() const { return m_handle; }
bool exists() const { return m_handle != 0; }
void use() const { glUseProgram(m_handle); }