#ifndef _VERTEXBUFFER_H #define _VERTEXBUFFER_H #include "common.h" #include "ravenmath.h" #include "vector.h" #define RAVEN_GEOMETRY_FLAG_INDICES 0x01 #define RAVEN_GEOMETRY_FLAG_VERTICES 0x02 #define RAVEN_GEOMETRY_FLAG_NORMALS 0x04 #define RAVEN_GEOMETRY_FLAG_COLORS 0x08 #define RAVEN_GEOMETRY_FLAG_TEXCOORDS 0x10 enum GeometryType { RAVEN_GEOMETRY_POINTS, RAVEN_GEOMETRY_LINES, RAVEN_GEOMETRY_LINE_STRIP, RAVEN_GEOMETRY_LINE_LOOP, RAVEN_GEOMETRY_TRIS, RAVEN_GEOMETRY_TRI_STRIP, RAVEN_GEOMETRY_TRI_FAN, RAVEN_GEOMETRY_QUADS, RAVEN_GEOMETRY_QUAD_STRIP }; class VertexBuffer { protected: unsigned int numindices; unsigned int numverts; // applies to each vertex AND it's normal and color + the number of pairs in each texture coord list unsigned int numtextures; int vbufattribs; int interleavedvertsize; unsigned int *indices; Vector3 *verts; Vector3 *norms; Vector4 *colors; Vector2 **texcoordsarr; public: VertexBuffer(): indices(NULL),verts(NULL),norms(NULL),colors(NULL), texcoordsarr(NULL),numindices(0),numverts(0),numtextures(0),vbufattribs(0) {} VertexBuffer(int attribs): indices(NULL),verts(NULL),norms(NULL),colors(NULL), texcoordsarr(NULL),numindices(0),numverts(0),numtextures(0),vbufattribs(0) {vbufattribs=attribs;} virtual ~VertexBuffer(); virtual void NumIndices(unsigned int num); virtual unsigned int NumIndices(); virtual void NumVerts(unsigned int num); virtual unsigned int NumVerts(); virtual void NumTextures(unsigned int num); virtual unsigned int NumTextures(); virtual void SetInterleaved(void *data); // all data (but indices) passed in interleaved format added for optimal D3D support virtual void Set(int type,int idx,void *data); // pass indices, vertices, normals, etc. idx is for texture coords virtual void Get(int type,int idx,void **data); // get that shit back virtual unsigned int Size(int type); virtual int GetBufAttribs(); // this is a software buffer, so no specific rendering virtual bool IsSoftBuffer(); virtual bool Render(GeometryType geomtype); }; #endif