diff --git a/src/glutils/glutils.cpp b/src/glutils/glutils.cpp index 30fbd66f..a5a2e95e 100644 --- a/src/glutils/glutils.cpp +++ b/src/glutils/glutils.cpp @@ -88,27 +88,23 @@ static ox::Result buildShader( return shader; } -ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag, const GLchar *geo) noexcept { +ox::Result buildShaderProgram( + ox::CStringView const&vert, + ox::CStringView const&frag, + ox::CStringView const&geo) noexcept { GLProgram prgm(glCreateProgram()); - oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert, "vshad")); + oxRequire(vs, buildShader(GL_VERTEX_SHADER, vert.c_str(), "vshad")); glAttachShader(prgm, vs); - if (geo && ox_strlen(geo) != 0) { - oxRequire(gs, buildShader(GL_GEOMETRY_SHADER, geo, "gshad")); + if (geo.c_str() && geo.bytes() != 0) { + oxRequire(gs, buildShader(GL_GEOMETRY_SHADER, geo.c_str(), "gshad")); glAttachShader(prgm, gs); } - oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag, "fshad")); + oxRequire(fs, buildShader(GL_FRAGMENT_SHADER, frag.c_str(), "fshad")); glAttachShader(prgm, fs); glLinkProgram(prgm); return prgm; } -ox::Result 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 vao; glGenVertexArrays(1, &vao.id); diff --git a/src/glutils/glutils.hpp b/src/glutils/glutils.hpp index f46aabce..a41a1ae4 100644 --- a/src/glutils/glutils.hpp +++ b/src/glutils/glutils.hpp @@ -9,13 +9,14 @@ #include #include +#include #include #include #include namespace glutils { -constexpr ox::StringView GlslVersion = "#version 330"; +constexpr ox::CStringView GlslVersion = "#version 330"; struct Empty { virtual ~Empty() noexcept = default; @@ -151,9 +152,7 @@ class FrameBufferBind { void bind(const FrameBuffer &fb) noexcept; -ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag, const GLchar *geo = nullptr) noexcept; - -ox::Result buildShaderProgram(const ox::String &vert, const ox::String &frag, const ox::String &geo = "") noexcept; +ox::Result buildShaderProgram(ox::CStringView const&vert, ox::CStringView const&frag, ox::CStringView const&geo = "") noexcept; glutils::GLVertexArray generateVertexArrayObject() noexcept;