73 lines
1.4 KiB
C++
73 lines
1.4 KiB
C++
// vertexbuf.h
|
|
//
|
|
// Copyright (C) 2001, Chris Laurel
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
|
|
#ifndef _VERTEXBUF_H_
|
|
#define _VERTEXBUF_H_
|
|
|
|
#include <celutil/color.h>
|
|
#include <celmath/vecmath.h>
|
|
#include <celmath/aabox.h>
|
|
|
|
|
|
class VertexBuffer
|
|
{
|
|
public:
|
|
enum {
|
|
VertexNormal = 0x01,
|
|
VertexColor = 0x02,
|
|
VertexColor0 = 0x02,
|
|
VertexColor1 = 0x04,
|
|
TexCoord0 = 0x08,
|
|
TexCoord1 = 0x10,
|
|
};
|
|
|
|
class Vertex
|
|
{
|
|
public:
|
|
Point3f point;
|
|
Vec3f normal;
|
|
Color color;
|
|
Point2f texCoords[2];
|
|
};
|
|
|
|
union VertexPart
|
|
{
|
|
float f;
|
|
unsigned char c[4];
|
|
};
|
|
|
|
public:
|
|
VertexList(uint32_t _parts, uint32_t initialVertexPoolSize = 0);
|
|
~VertexList();
|
|
|
|
void addVertex(const Vertex& v);
|
|
|
|
Color getDiffuseColor() const;
|
|
void setDiffuseColor(Color);
|
|
|
|
void render();
|
|
|
|
AxisAlignedBox getBoundingBox() const;
|
|
void transform(Vec3f translation, float scale);
|
|
|
|
private:
|
|
uint32_t parts;
|
|
uint32_t vertexSize;
|
|
|
|
uint32_t nVertices;
|
|
uint32_t maxVertices;
|
|
VertexPart* vertices;
|
|
|
|
Color diffuseColor;
|
|
|
|
AxisAlignedBox bbox;
|
|
};
|
|
|
|
#endif // _VERTEXBUF_H_
|