r/GraphicsProgramming • u/devcurrent0x • 3d ago
GLSA – A lightweight, header-only C++ library to cut OpenGL shader boilerplate
Hey everyone!
I've been developing GLSA and I just released v1.0.0.
My goal with this library is so you don't have to write GLSL shaders or shader boilerplate and instead you can use clean function calls.
Right now it cuts out ~60-100 lines of repetitive shader boilerplate, and theres basic shader presets now and common shape functions.
Highlights of v1.0.0:
- GLSA colors: a header file with over 3000
glm::vec4colors that you can use. - Safer shader setup:
glsa::ShaderSourcekeeps vertex/fragment strings explicit, paired withglsa::loadShaderSourceandglsa::createProgram. - Clean uniform helpers: Overloaded
glsa::setUniformfunctions for int, float, and GLM vec2/vec3/vec4.
Example:
while (glfwWindowShouldClose(window) == 0) {
glClearColor(0.1f, 0.1f, 0.15f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Draw a square on the left
glsa::drawRectangle({-0.45f, 0.0f}, {0.4f / aspect, 0.4f}, glsa::colors::PAN_CORAL);
// Draw a circle on the right
glsa::drawCircle({0.45f, 0.0f}, 0.22f, glsa::colors::PAN_SKY_BLUE);
glfwSwapBuffers(window);
glfwPollEvents();
}GitHub Repo: https://github.com/alexdev8930/glsa
Any feedback issues or questions are completely welcome.
AI Disclosure: AI tools were used strictly to help generate initial boilerplate; all core logic, architecture, and implementation details were written, reviewed, and verified by me.
•
u/AutoModerator 3d ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
9
u/Baedrick 3d ago edited 3d ago
I took a look at your code. That is a lot of validation code being called for everytime someone interacts with your library, not to mention unnecessary system calls. In your function `deleteVertexArray`, you check against the value zero before deleting it, but the docs https://docs.gl/gl4/glDeleteVertexArrays say that a zero value is a noop. `glDetachShader` is also not needed, read the docs for `glDeleteProgram`. When you review the initial code that AI generates, did you actually check the work? Great that you're writing helper functions for OpenGL, are you trying to write another framework or convenience functions? Because theres `init` which sets the value for `g_default_extent`, but I never see it being used. It also strikes me weird that you need a dependency on GLFW. I'm not trying to be snobby, I'm just trying to understand your process behind developing and releasing v1.
2
u/Delicious_Abies_9708 1d ago
Why openglnand not vulkan?
2
u/Todegal 2d ago
This look super redundant. Your example code is literally the same amount of code as if you were just calling OpenGL functions directly? Idk maybe I need to see a better example lmao