X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=59b75beeb797e89aab8356eeedc5002cc77fa079;hb=c2d67378dd5c82de50b8fbbbe222ec6be2da4eee;hp=24dacb875434d57f2328f0034edb24c7ce10ca6e;hpb=ba5f879f85b9cab1e2b37241399d79709fe4f584;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index 24dacb8..59b75be 100644 --- a/model.h +++ b/model.h @@ -184,7 +184,8 @@ struct glmesh u32 indice_count; }; -static void mesh_upload( glmesh *mesh, +__attribute__((warn_unused_result)) +static int mesh_upload( glmesh *mesh, mdl_vert *verts, u32 vert_count, u32 *indices, u32 indice_count ) { @@ -232,9 +233,13 @@ static void mesh_upload( glmesh *mesh, stride, (void *)offsetof(mdl_vert, groups) ); glEnableVertexAttribArray( 5 ); - - VG_CHECK_GL(); + if( VG_CHECK_GL_ERR() ) + { + return 0; + } + mesh->indice_count = indice_count; + return 1; } static void mesh_bind( glmesh *mesh ) @@ -465,13 +470,15 @@ static void mdl_node_transform( mdl_node *pnode, m4x3f transform ) v3_copy( pnode->co, transform[3] ); } -static void mdl_unpack_submesh( mdl_header *mdl, glmesh *mesh, mdl_submesh *sm ) +__attribute__((warn_unused_result)) +static int mdl_unpack_submesh( mdl_header *mdl, glmesh *mesh, mdl_submesh *sm ) { - mesh_upload( mesh, mdl_submesh_vertices( mdl, sm ), sm->vertex_count, - mdl_submesh_indices( mdl, sm ), sm->indice_count ); + return mesh_upload( mesh, mdl_submesh_vertices( mdl, sm ), sm->vertex_count, + mdl_submesh_indices( mdl, sm ), sm->indice_count ); } -static void mdl_unpack_glmesh( mdl_header *mdl, glmesh *mesh ) +__attribute__((warn_unused_result)) +static int mdl_unpack_glmesh( mdl_header *mdl, glmesh *mesh ) { u32 offset = mdl_submesh_from_id( mdl, 0 )->vertex_count; @@ -489,8 +496,8 @@ static void mdl_unpack_glmesh( mdl_header *mdl, glmesh *mesh ) mdl_vert *vertex_base = mdl_baseptr( mdl, mdl->vertex_offset ); u32 *indice_base = mdl_baseptr( mdl, mdl->indice_offset ); - mesh_upload( mesh, vertex_base, mdl->vertex_count, - indice_base, mdl->indice_count ); + return mesh_upload( mesh, vertex_base, mdl->vertex_count, + indice_base, mdl->indice_count ); } static void mdl_draw_submesh( mdl_submesh *sm )