Skip to content

Instantly share code, notes, and snippets.

@DanielShuey
Last active February 19, 2026 20:54
Show Gist options
  • Select an option

  • Save DanielShuey/aa812f51ddcae44d594a4b3859c8b05b to your computer and use it in GitHub Desktop.

Select an option

Save DanielShuey/aa812f51ddcae44d594a4b3859c8b05b to your computer and use it in GitHub Desktop.
Bindless OpenGL example (not sure performance)
inline static overload void glsetarg(u32 id, int n, gldt type, const void *ptr, bool normalized) {
glVertexAttribPointer(id, n, type, normalized, 0, ptr);
};
inline static void gltex(texture tex) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(gl_tex2D, 0, gl_rgba, tex.w, tex.h, 0, gl_rgba, gl_u8, &tex.img[0]);
};
mesh m = obj.mesh;
gluseprog(prog_diffuse.id);
glEnableVertexAttribArray(prog_diffuse.vtx);
glEnableVertexAttribArray(prog_diffuse.nrm);
glEnableVertexAttribArray(prog_diffuse.uv);
glsetarg(prog_diffuse.vtx, 3, gl_i16, m.vtx, true);
glsetarg(prog_diffuse.nrm, 3, gl_i16, m.nrm, true);
glsetarg(prog_diffuse.uv, 2, gl_i16, m.uv, true);
glsetuni4(prog_diffuse.proj, cam.proj);
glsetuni4(prog_diffuse.tf, obj.mat4);
glsetuni1(prog_diffuse.amb, (float[4]){1, 1, 1, 1});
gltex(obj.tex);
gldraw(gl_u16, m.len, m.idc);
glDisableVertexAttribArray(prog_diffuse.vtx);
glDisableVertexAttribArray(prog_diffuse.nrm);
glDisableVertexAttribArray(prog_diffuse.uv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment