[glutils] Do some cleanup with ox::CStringView
This commit is contained in:
parent
a37df08c19
commit
95ba8eb138
@ -88,27 +88,23 @@ static ox::Result<GLShader> buildShader(
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag, const GLchar *geo) noexcept {
|
ox::Result<GLProgram> buildShaderProgram(
|
||||||
|
ox::CStringView const&vert,
|
||||||
|
ox::CStringView const&frag,
|
||||||
|
ox::CStringView const&geo) noexcept {
|
||||||
GLProgram prgm(glCreateProgram());
|
GLProgram prgm(glCreateProgram());
|
||||||
oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert, "vshad"));
|
oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert.c_str(), "vshad"));
|
||||||
glAttachShader(prgm, vs);
|
glAttachShader(prgm, vs);
|
||||||
if (geo && ox_strlen(geo) != 0) {
|
if (geo.c_str() && geo.bytes() != 0) {
|
||||||
oxRequire(gs, buildShader(GL_GEOMETRY_SHADER, geo, "gshad"));
|
oxRequire(gs, buildShader(GL_GEOMETRY_SHADER, geo.c_str(), "gshad"));
|
||||||
glAttachShader(prgm, gs);
|
glAttachShader(prgm, gs);
|
||||||
}
|
}
|
||||||
oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag, "fshad"));
|
oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag.c_str(), "fshad"));
|
||||||
glAttachShader(prgm, fs);
|
glAttachShader(prgm, fs);
|
||||||
glLinkProgram(prgm);
|
glLinkProgram(prgm);
|
||||||
return prgm;
|
return prgm;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
GLVertexArray generateVertexArrayObject() noexcept {
|
||||||
GLVertexArray vao;
|
GLVertexArray vao;
|
||||||
glGenVertexArrays(1, &vao.id);
|
glGenVertexArrays(1, &vao.id);
|
||||||
|
@ -9,13 +9,14 @@
|
|||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
#include <ox/std/bounds.hpp>
|
#include <ox/std/bounds.hpp>
|
||||||
|
#include <ox/std/cstringview.hpp>
|
||||||
#include <ox/std/error.hpp>
|
#include <ox/std/error.hpp>
|
||||||
#include <ox/std/string.hpp>
|
#include <ox/std/string.hpp>
|
||||||
#include <ox/std/vector.hpp>
|
#include <ox/std/vector.hpp>
|
||||||
|
|
||||||
namespace glutils {
|
namespace glutils {
|
||||||
|
|
||||||
constexpr ox::StringView GlslVersion = "#version 330";
|
constexpr ox::CStringView GlslVersion = "#version 330";
|
||||||
|
|
||||||
struct Empty {
|
struct Empty {
|
||||||
virtual ~Empty() noexcept = default;
|
virtual ~Empty() noexcept = default;
|
||||||
@ -151,9 +152,7 @@ class FrameBufferBind {
|
|||||||
void bind(const FrameBuffer &fb) noexcept;
|
void bind(const FrameBuffer &fb) noexcept;
|
||||||
|
|
||||||
|
|
||||||
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag, const GLchar *geo = nullptr) noexcept;
|
ox::Result<GLProgram> buildShaderProgram(ox::CStringView const&vert, ox::CStringView const&frag, ox::CStringView const&geo = "") noexcept;
|
||||||
|
|
||||||
ox::Result<GLProgram> buildShaderProgram(const ox::String &vert, const ox::String &frag, const ox::String &geo = "") noexcept;
|
|
||||||
|
|
||||||
glutils::GLVertexArray generateVertexArrayObject() noexcept;
|
glutils::GLVertexArray generateVertexArrayObject() noexcept;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user