[nostalgia/glutils] Upgrade non-Apple platforms to GLES 3.2

This commit is contained in:
Gary Talent 2021-12-11 18:47:10 -06:00
parent 5ed806f4c0
commit 20a8d34e11
2 changed files with 17 additions and 14 deletions

View File

@ -49,26 +49,30 @@ static ox::Result<GLShader> buildShader(GLuint shaderType, const GLchar *src, co
GLint status;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (status != GL_TRUE) {
ox::BString<1000> errMsg;
glGetShaderInfoLog(shader, errMsg.cap(), nullptr, errMsg.data());
oxErrorf("shader compile error in {}: {}", shaderName, errMsg);
ox::Vector<char, 1000> errMsg(1000);
glGetShaderInfoLog(shader, static_cast<GLsizei>(errMsg.size()), nullptr, errMsg.data());
oxErrorf("shader compile error in {}: {}", shaderName, errMsg.data());
return OxError(1, "shader compile error");
}
return shader;
}
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept {
oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert, "vshad"));
oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag, "fshad"));
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag, [[maybe_unused]] const GLchar *geo) noexcept {
GLProgram prgm(glCreateProgram());
oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert, "vshad"));
glAttachShader(prgm, vs);
oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag, "fshad"));
glAttachShader(prgm, fs);
if (geo && ox_strlen(geo) != 0) {
oxRequire(gs, buildShader(GL_GEOMETRY_SHADER, geo, "gshad"));
glAttachShader(prgm, gs);
}
glLinkProgram(prgm);
return prgm;
}
ox::Result<GLProgram> buildShaderProgram(const ox::String &vert, const ox::String &frag) noexcept {
return buildShaderProgram(vert.c_str(), frag.c_str());
ox::Result<GLProgram> buildShaderProgram(const ox::String &vert, const ox::String &frag, const ox::String &geo) noexcept {
return buildShaderProgram(vert.c_str(), frag.c_str(), geo.c_str());
}
GLVertexArray generateVertexArrayObject() noexcept {
@ -105,7 +109,6 @@ FrameBuffer generateFrameBuffer(int width, int height) noexcept {
oxAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Frame Buffer is incomplete");
// restore primary FB
glBindFramebuffer(GL_FRAMEBUFFER, 0);
oxAssert(glGetError() == 0, "Framebuffer creation failed");
return fb;
}

View File

@ -18,7 +18,7 @@
#endif
#include <OpenGL/gl3.h>
#else
#include <GLES3/gl3.h>
#include <GLES3/gl32.h>
#endif
#include <ox/std/error.hpp>
@ -66,7 +66,7 @@ struct GLObject: public Base {
this->id = id;
}
constexpr GLObject(GLObject &&o) noexcept: Base(ox::move(o)) {
constexpr GLObject(GLObject &&o) noexcept: Base(std::move(o)) {
id = o.id;
o.id = 0;
}
@ -78,7 +78,7 @@ struct GLObject: public Base {
GLObject &operator=(GLObject &&o) noexcept {
if (this != &o) {
del(id);
Base::operator=(ox::move(o));
Base::operator=(std::move(o));
id = o.id;
o.id = 0;
}
@ -145,9 +145,9 @@ struct FrameBuffer {
};
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag) noexcept;
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag, const GLchar *geo = nullptr) noexcept;
ox::Result<GLProgram> buildShaderProgram(const ox::String &vert, const ox::String &frag) noexcept;
ox::Result<GLProgram> buildShaderProgram(const ox::String &vert, const ox::String &frag, const ox::String &geo = "") noexcept;
glutils::GLVertexArray generateVertexArrayObject() noexcept;