$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
instanced_rendering.h
Go to the documentation of this file.
1 
10 #ifndef INSTANCED_RENDERING_H
11 #define INSTANCED_RENDERING_H
12 
13 #include "gl_common.h"
14 #include <cglm/cglm.h>
15 
23 typedef struct {
24  mat4 model;
25  vec3 albedo;
26  float metallic;
27  float roughness;
28  float ao;
29  float padding;
30 } __attribute__((aligned(SIMD_ALIGNMENT))) SphereInstance;
31 
36 typedef struct {
37  GLuint vao;
39  GLuint instance_vbo;
42 
49 void instanced_group_init(InstancedGroup* group, const SphereInstance* data,
50  int count);
51 
59 void instanced_group_bind_mesh(InstancedGroup* group, GLuint vbo, GLuint nbo,
60  GLuint ebo);
61 
67 void instanced_group_draw(InstancedGroup* group, size_t index_count);
68 
74 
75 #endif /* INSTANCED_RENDERING_H */
Common OpenGL definitions, RAII helpers, and utilities.
@ SIMD_ALIGNMENT
Definition: gl_common.h:131
void instanced_group_cleanup(InstancedGroup *group)
Releases all GPU resources for the instanced group.
Definition: instanced_rendering.c:74
void instanced_group_init(InstancedGroup *group, const SphereInstance *data, int count)
Allocates the instance VBO on the GPU.
Definition: instanced_rendering.c:7
void instanced_group_bind_mesh(InstancedGroup *group, GLuint vbo, GLuint nbo, GLuint ebo)
Binds a procedural mesh (e.g., icosphere) to the instanced group.
Definition: instanced_rendering.c:28
void instanced_group_draw(InstancedGroup *group, size_t index_count)
Executes an indexed instanced draw call.
Definition: instanced_rendering.c:67
Manages mesh-based instanced spheres on the GPU.
Definition: instanced_rendering.h:36
GLuint vao
Definition: instanced_rendering.h:37
GLuint instance_vbo
Definition: instanced_rendering.h:39
int instance_count
Definition: instanced_rendering.h:40
Per-instance data sent to the shader via an instanced VBO.
Definition: instanced_rendering.h:23
float padding
Definition: instanced_rendering.h:29
float metallic
Definition: instanced_rendering.h:26
mat4 model
Definition: instanced_rendering.h:24
float ao
Definition: instanced_rendering.h:28
float roughness
Definition: instanced_rendering.h:27
vec3 albedo
Definition: instanced_rendering.h:25