Add createFromBinary function

This commit is contained in:
offtkp 2024-08-08 17:07:28 +03:00
parent 0cf5687e64
commit 884b156595

View file

@ -432,6 +432,25 @@ namespace OpenGL {
return m_handle != 0;
}
bool createFromBinary(const uint8_t* binary, size_t size, GLenum format) {
m_handle = glCreateProgram();
glProgramBinary(m_handle, format, 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); }