[glutils] Add helper functions for setting up shaders
This commit is contained in:
34
deps/glutils/include/glutils/glutils.hpp
vendored
34
deps/glutils/include/glutils/glutils.hpp
vendored
@ -150,8 +150,38 @@ class FrameBufferBind {
|
||||
|
||||
void bind(const FrameBuffer &fb) noexcept;
|
||||
|
||||
struct ShaderVarSet {
|
||||
GLsizei len{};
|
||||
ox::String name;
|
||||
};
|
||||
|
||||
ox::Result<GLProgram> buildShaderProgram(ox::CStringView const&vert, ox::CStringView const&frag, ox::CStringView const&geo = "") noexcept;
|
||||
struct ProgramSource {
|
||||
ox::Vector<glutils::ShaderVarSet> const shaderParams;
|
||||
GLsizei const rowLen = [this] {
|
||||
GLsizei len{};
|
||||
for (auto const&v : shaderParams) {
|
||||
len += v.len;
|
||||
}
|
||||
return len;
|
||||
}();
|
||||
ox::String const vertShader{};
|
||||
ox::String const fragShader{};
|
||||
ox::String const geomShader{};
|
||||
};
|
||||
|
||||
ox::Result<GLProgram> buildShaderProgram(ProgramSource const&src) noexcept;
|
||||
|
||||
ox::Result<GLProgram> buildShaderProgram(
|
||||
ox::CStringView const&vert,
|
||||
ox::CStringView const&frag,
|
||||
ox::CStringView const&geo = "") noexcept;
|
||||
|
||||
void setupShaderParams(
|
||||
GLProgram const&shader,
|
||||
ox::Vector<ShaderVarSet> const&vars,
|
||||
GLsizei vertexRowLen) noexcept;
|
||||
|
||||
void setupShaderParams(GLProgram const&shader, ox::Vector<ShaderVarSet> const&vars) noexcept;
|
||||
|
||||
glutils::GLVertexArray generateVertexArrayObject() noexcept;
|
||||
|
||||
@ -160,6 +190,8 @@ glutils::GLBuffer generateBuffer() noexcept;
|
||||
[[nodiscard]]
|
||||
FrameBuffer generateFrameBuffer(int width, int height) noexcept;
|
||||
|
||||
void resizeFrameBuffer(FrameBuffer &fb, int width, int height) noexcept;
|
||||
|
||||
/**
|
||||
* Resizes a FrameBuffer, and creates if it does not already exist.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user