00001 #ifndef RC_VERTEXARRAY_H
00002 #define RC_VERTEXARRAY_H
00003
00004 typedef enum {
00005
00006 TRIANGLES = 0,
00007 TRIANGLE_STRIP,
00008 TRIANGLE_FAN,
00009
00010 LINES,
00011 LINE_LOOP,
00012 LINE_STRIP,
00013
00014 INDEX_ARRAY_LAST
00015
00016 } PrimitiveLayout_t;
00017
00018 typedef struct {
00019
00020 char *name;
00021 u32 length;
00022 u32 offset;
00023
00024 AttributeType_t type;
00025 bool normalized;
00026
00027 } Attribute_t;
00028
00029
00087 class VertexArray : public Resource {
00088
00089 friend class SceneGraph;
00090 friend class Geometry;
00091
00092
00093
00094 private:
00111 VertexArray(
00112 const char *nidentifier,
00113
00114 void *new_array,
00115 u32 nstride,
00116 u32 n,
00117
00118 PrimitiveLayout_t layout,
00119
00120 AttributeUsage_t nusage
00121 );
00122
00126 VertexArray(
00127 const char *nidentifier,
00128
00129 u32 nstride,
00130
00131 PrimitiveLayout_t layout,
00132
00133 AttributeUsage_t nusage
00134 );
00135
00136 virtual ~VertexArray();
00137
00138 public:
00139
00160 void setAttribute(
00161 const char *name,
00162 u32 offset,
00163 u32 length,
00164 AttributeType_t type,
00165
00166 bool normalize_int = false
00167 );
00168
00178 void setIndexArray(
00179 void *new_array,
00180 u32 type_size,
00181 u32 n
00182 );
00183
00184 void setArray(
00185 void *new_array,
00186 u32 n
00187 );
00188
00189 u32 getLength();
00190
00191 u32 getStride();
00192
00193 u32 getAttributeCount();
00194
00195 Attribute_t *getAttribute(
00196 u32 i
00197 );
00198
00199 Attribute_t *getAttribute(
00200 char *name
00201 );
00202
00203 PrimitiveLayout_t getPrimitiveLayout();
00204
00205 u32 getIndexTypeSize();
00206
00207 u32 getIndexLength();
00208
00209 AttributeUsage_t getUsage();
00210
00211 AttributeUsage_t getIndexUsage();
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 void *getHandle();
00223
00224 void setHandle(
00225 void *nhandle
00226 );
00227
00228 protected:
00229
00230 AABox getBoundingBox();
00231
00232 private:
00233
00234
00235 static void setVertexArray(
00236 VertexArray **target_vertex_array,
00237 VertexArray *new_vertex_array,
00238
00239 bool instantiate_resource = true
00240 );
00241
00242 #ifdef DEBUG
00243 protected:
00244 void print(
00245 FILE *f
00246 );
00247 #endif
00248
00249
00250
00251 private:
00252
00253 bool has_bounds;
00254 AABox bounds;
00255
00256 void *varray;
00257 u32 n_elements;
00258 u32 stride;
00259
00260 AttributeUsage_t usage;
00261 bool holds_array;
00262
00263
00264 u32 n_attribs;
00265 Attribute_t attrib[RC_MAX_ATTRIBS];
00266
00267
00268 PrimitiveLayout_t primitiveLayout;
00269 void *iarray;
00270 u32 indexArrayTypeSize;
00271 u32 n_indices;
00272 bool holds_index_array;
00273
00274 AttributeUsage_t index_usage;
00275
00276 void *handle;
00277
00278 };
00279
00280 #endif
00281