gba-x3dtest

annotate src/mesh.c @ 20:2e903e27e35a

fixed x3d_disable_texture added runtime teture checks in the rasterizer
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 01 Jul 2014 23:23:37 +0300
parents 2070a81127f2
children
rev   line source
nuclear@12 1 #include <stdlib.h>
nuclear@12 2 #include "mesh.h"
nuclear@12 3 #include "x3d.h"
nuclear@12 4
nuclear@12 5 void init_mesh(struct mesh *m)
nuclear@12 6 {
nuclear@12 7 m->prim = X3D_TRIANGLES;
nuclear@12 8 m->verts = 0;
nuclear@13 9 m->colors = 0;
nuclear@15 10 m->texcoords = 0;
nuclear@12 11 m->nverts = 0;
nuclear@12 12 }
nuclear@12 13
nuclear@12 14 void destroy_mesh(struct mesh *m)
nuclear@12 15 {
nuclear@12 16 free(m->verts);
nuclear@13 17 free(m->colors);
nuclear@15 18 free(m->texcoords);
nuclear@12 19 }
nuclear@12 20
nuclear@12 21 void draw_mesh(struct mesh *m)
nuclear@12 22 {
nuclear@12 23 x3d_vertex_array(m->nverts, m->verts);
nuclear@13 24 if(m->colors) {
nuclear@13 25 x3d_color_array(m->nverts, m->colors);
nuclear@13 26 }
nuclear@15 27 if(m->texcoords) {
nuclear@15 28 x3d_texcoord_array(m->nverts, m->texcoords);
nuclear@15 29 }
nuclear@13 30
nuclear@12 31 x3d_draw(m->prim, m->nverts);
nuclear@13 32
nuclear@12 33 x3d_vertex_array(0, 0);
nuclear@13 34 x3d_color_array(0, 0);
nuclear@15 35 x3d_texcoord_array(0, 0);
nuclear@12 36 }