4 Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef __C3GEOMETRY_H___
24 #define __C3GEOMETRY_H___
26 #include "c3/c3algebra.h"
29 typedef c3vec3 c3vertex;
30 typedef c3vec4 c3colorf;
35 DECLARE_C_ARRAY(c3vertex, c3vertex_array, 16);
36 DECLARE_C_ARRAY(c3tex, c3tex_array, 16);
37 DECLARE_C_ARRAY(c3colorf, c3colorf_array, 16);
39 typedef struct c3material_t {
44 typedef struct c3bbox_t {
48 #define C3_RAW_TYPE (0)
51 struct { uint32_t type : 16, subtype : 16; };
55 typedef struct c3geometry_t {
56 c3geometry_type_t type; // GL_LINES etc
57 int dirty : 1, texture : 1;
58 str_p name; // optional
60 struct c3object_t * object;
61 const struct c3driver_geometry_t ** driver;
62 c3vertex_array_t vertice;
63 c3tex_array_t textures;
64 c3colorf_array_t colorf;
66 // projected version of the vertice
67 c3vertex_array_t projected;
71 * optional, geometry dependant custom draw method
72 * return nonzero will orevent the default drawing code
73 * from being called (c3context one)
75 int (*draw)(struct c3geometry_t *);
76 } c3geometry_t, *c3geometry_p;
78 DECLARE_C_ARRAY(c3geometry_p, c3geometry_array, 4);
82 c3geometry_type_t type,
83 struct c3object_t * o /* = NULL */);
87 c3geometry_type_t type,
88 struct c3object_t * o /* = NULL */);
97 IMPLEMENT_C_ARRAY(c3geometry_array);
98 IMPLEMENT_C_ARRAY(c3vertex_array);
99 IMPLEMENT_C_ARRAY(c3tex_array);
100 IMPLEMENT_C_ARRAY(c3colorf_array);
102 static inline c3geometry_type_t
103 c3geometry_type(int type, int subtype)
105 c3geometry_type_t r = { .type = type, . subtype = subtype };
109 #endif /* __C3GEOMETRY_H___ */