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 {
55 struct { uint32_t type : 16, subtype : 16; };
59 typedef struct c3geometry_t {
60 c3geometry_type_t type; // GL_LINES etc
62 texture : 1, // has a valid material.texture
63 custom : 1; // has a custom driver
64 str_p name; // optional
66 struct c3object_t * object;
67 const struct c3driver_geometry_t ** driver;
69 c3vertex_array_t vertice;
70 c3tex_array_t textures;
71 c3colorf_array_t colorf;
72 c3vertex_array_t normals;
74 // projected version of the vertice
75 c3vertex_array_t projected;
77 } c3geometry_t, *c3geometry_p;
79 DECLARE_C_ARRAY(c3geometry_p, c3geometry_array, 4);
83 c3geometry_type_t type,
84 struct c3object_t * o /* = NULL */);
88 c3geometry_type_t type,
89 struct c3object_t * o /* = NULL */);
101 //! allocate (if not there) and return a custom driver for this geometry
102 struct c3driver_geometry_t *
103 c3geometry_get_custom(
106 IMPLEMENT_C_ARRAY(c3geometry_array);
107 IMPLEMENT_C_ARRAY(c3vertex_array);
108 IMPLEMENT_C_ARRAY(c3tex_array);
109 IMPLEMENT_C_ARRAY(c3colorf_array);
111 static inline c3geometry_type_t
112 c3geometry_type(int type, int subtype)
114 c3geometry_type_t r = { .type = type, .subtype = subtype };
118 #endif /* __C3GEOMETRY_H___ */