feat(shaders_lab): scaffold C++ app with GLSL live-reload canvas
- cpp/functions/gfx: gl_shader, gl_framebuffer, fullscreen_quad, shader_canvas - cpp/apps/shaders_lab: main + 3 seed shaders (plasma, circle, checker) - ImGui docking layout: Code | Canvas | Controls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#include "gfx/fullscreen_quad.h"
|
||||
|
||||
namespace fn::gfx {
|
||||
|
||||
void quad_init(Quad& q) {
|
||||
glGenVertexArrays(1, &q.vao);
|
||||
glGenBuffers(1, &q.vbo);
|
||||
// Vertex shader generates positions from gl_VertexID — VBO stays empty.
|
||||
glBindVertexArray(q.vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, q.vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void quad_draw(const Quad& q) {
|
||||
glBindVertexArray(q.vao);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void quad_destroy(Quad& q) {
|
||||
if (q.vao) { glDeleteVertexArrays(1, &q.vao); q.vao = 0; }
|
||||
if (q.vbo) { glDeleteBuffers(1, &q.vbo); q.vbo = 0; }
|
||||
}
|
||||
|
||||
} // namespace fn::gfx
|
||||
Reference in New Issue
Block a user