41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
#ifndef __PLANETINDEXBUFFER_H__
|
|
#define __PLANETINDEXBUFFER_H__
|
|
|
|
#include "util/Common.h"
|
|
|
|
enum Direction
|
|
{
|
|
TOP, RIGHT,
|
|
BOTTOM, LEFT,
|
|
};
|
|
|
|
|
|
typedef std::vector<GLushort> TriangleFan;
|
|
typedef std::vector<TriangleFan> TriangleFanList;
|
|
|
|
class PlanetIndexBuffer {
|
|
public:
|
|
PlanetIndexBuffer(unsigned int resolution, const unsigned int detailTop, const unsigned int detailRight, const unsigned int detailBottom, const unsigned int detailLeft);
|
|
~PlanetIndexBuffer();
|
|
|
|
// Instance methods
|
|
GLsizei getVertexCount() const;
|
|
GLuint getIbo() const;
|
|
private:
|
|
void rotateIndices(unsigned int &x, unsigned int &y, const unsigned int rotation);
|
|
void addTriangleFan(TriangleFanList &triangleFans);
|
|
void addTriangleFanVertex(TriangleFanList &triangleFans, unsigned int x, unsigned int y, const unsigned int rotation = 0);
|
|
void buildEdge(TriangleFanList &triangleFans, const unsigned int side, const unsigned int detail = 0);
|
|
|
|
// Instance variables
|
|
GLsizei m_vertexCount;
|
|
GLuint m_ibo;
|
|
|
|
// TODO: move to utility
|
|
unsigned int index1D(const unsigned int x, const unsigned int y);
|
|
|
|
unsigned int m_resolution;
|
|
};
|
|
|
|
#endif // __PLANETINDEXBUFFER_H__
|