commit 6b501d4323bd063183b803a73bf97c29827aeae2
parent 6bcd0b2b0160d63fd2aae98b90b683c735441262
Author: William Casarin <jb55@jb55.com>
Date: Sun, 10 May 2020 01:03:36 -0700
n_vertex_attrs -> MAX_VERTEX_ATTRS
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
6 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/game.h b/src/game.h
@@ -49,7 +49,7 @@ struct resources {
GLint view_proj;
} uniforms;
- gpu_addr vertex_attrs[n_vertex_attrs];
+ gpu_addr vertex_attrs[MAX_VERTEX_ATTRS];
node_id root_id;
entity_id player_id;
diff --git a/src/geometry.c b/src/geometry.c
@@ -11,9 +11,9 @@ struct resource_manager geom_manager;
void
destroy_buffer_geometry(geometry_id *geom_id) {
struct geometry *geom = get_geometry(geom_id);
- gpu_addr buffers[n_vertex_attrs];
+ gpu_addr buffers[MAX_VERTEX_ATTRS];
- for (int i = 0; i < n_vertex_attrs; i++)
+ for (int i = 0; i < MAX_VERTEX_ATTRS; i++)
buffers[i] = geom->vbos[i].handle;
/* void glDeleteVertexArrays(GLsizei n, const GLuint *arrays); */
/* glDisableVertexAttribArray(geom->buffer.vertex_buffer.handle); */
@@ -32,7 +32,7 @@ destroy_buffer_geometry(geometry_id *geom_id) {
void bind_geometry(struct geometry *geom, gpu_addr *vertex_attrs) {
struct vbo *vbo;
- for (int i = 0; i < n_vertex_attrs; i++) {
+ for (int i = 0; i < MAX_VERTEX_ATTRS; i++) {
vbo = &geom->vbos[i];
if (vbo->handle && vertex_attrs[i] != 0xFFFFFFFF) {
bind_vbo(vbo, vertex_attrs[i], vbo->component_type);
@@ -91,7 +91,7 @@ void init_make_geometry(struct make_geometry *mkgeom) {
void init_geometry(struct geometry *geom) {
geom->has_vbos = 0;
- for (int i = 0; i < n_vertex_attrs; i++)
+ for (int i = 0; i < MAX_VERTEX_ATTRS; i++)
init_vbo(&geom->vbos[i]);
geom->num_uv_components = 2;
@@ -203,7 +203,7 @@ void destroy_geometry(geometry_id *geom_id)
struct geometry *geom = get_geometry(geom_id); assert(geom);
struct vbo *vbo;
- for (int i = 0; i < n_vertex_attrs; i++) {
+ for (int i = 0; i < MAX_VERTEX_ATTRS; i++) {
vbo = &geom->vbos[i];
if (vbo->handle)
glDeleteBuffers(1, &vbo->handle);
diff --git a/src/geometry.h b/src/geometry.h
@@ -14,7 +14,7 @@
typedef struct resource_id geometry_id;
struct geometry {
- struct vbo vbos[n_vertex_attrs];
+ struct vbo vbos[MAX_VERTEX_ATTRS];
float min[3];
float max[3];
diff --git a/src/skybox.h b/src/skybox.h
@@ -10,7 +10,7 @@
struct skybox {
struct gpu_program *program;
model_id model_id;
- gpu_addr attrs[n_vertex_attrs];
+ gpu_addr attrs[MAX_VERTEX_ATTRS];
struct node node;
struct {
int mvp;
diff --git a/src/ui.h b/src/ui.h
@@ -9,7 +9,7 @@
struct ui {
struct gpu_program *shader;
geometry_id quad_geom_id;
- gpu_addr attrs[n_vertex_attrs];
+ gpu_addr attrs[MAX_VERTEX_ATTRS];
struct ui_uniforms {
GLint mvp;
diff --git a/src/vbo.h b/src/vbo.h
@@ -6,8 +6,6 @@
typedef GLuint gpu_addr;
-#define VERT_ATTRS 6
-
enum vertex_attr {
va_position,
va_normal,
@@ -16,7 +14,7 @@ enum vertex_attr {
va_tex_coord,
va_joint_ids,
va_joint_weights,
- n_vertex_attrs
+ MAX_VERTEX_ATTRS
};
struct vbo {