50 #include <ACG/GL/acg_glew.hh> 51 #include "DrawMesh.hh" 55 DrawMeshBase::DrawMeshBase() :
57 numTris_(0), numVerts_(0),
63 vertexDecl_ =
new VertexDeclaration;
64 vertexDeclEdgeCol_ =
new VertexDeclaration;
65 vertexDeclHalfedgeCol_ =
new VertexDeclaration;
66 vertexDeclHalfedgePos_ =
new VertexDeclaration;
69 DrawMeshBase::~DrawMeshBase() {
70 if (vbo_) glDeleteBuffersARB(1, &vbo_);
71 if (ibo_) glDeleteBuffersARB(1, &ibo_);
72 if (lineIBO_) glDeleteBuffersARB(1, &lineIBO_);
75 delete vertexDeclEdgeCol_;
76 delete vertexDeclHalfedgeCol_;
77 delete vertexDeclHalfedgePos_;
79 if (pickVertexIBO_) glDeleteBuffersARB(1, &pickVertexIBO_);
82 void DrawMeshBase::deleteIbo() {
84 glDeleteBuffers(1, &ibo_);
88 void DrawMeshBase::bindVbo() {
90 glGenBuffersARB(1, &vbo_);
95 void DrawMeshBase::bindIbo() {
97 glGenBuffersARB(1, &ibo_);
102 void DrawMeshBase::bindLineIbo() {
104 glGenBuffersARB(1, &lineIBO_);
109 void DrawMeshBase::bindPickVertexIbo() {
111 glGenBuffersARB(1, &pickVertexIBO_);
113 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, pickVertexIBO_);
116 void DrawMeshBase::createIndexBuffer() {
117 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
118 numTris_ * 3 *
sizeof(
unsigned int),
119 meshComp_->getIndexBuffer(), GL_STATIC_DRAW_ARB);
122 void DrawMeshBase::fillLineBuffer(
size_t n_edges,
void *data) {
124 if (indexType_ == GL_UNSIGNED_SHORT)
125 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
126 n_edges * 2 *
sizeof(
unsigned short),
127 data, GL_STATIC_DRAW_ARB);
129 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
130 n_edges * 2 *
sizeof(
unsigned int),
131 data, GL_STATIC_DRAW_ARB);
134 void DrawMeshBase::fillVertexBuffer() {
135 if (!vertices_.empty())
136 glBufferDataARB(GL_ARRAY_BUFFER_ARB, numVerts_ * vertexDecl_->getVertexStride(), &vertices_[0], GL_STATIC_DRAW_ARB);
139 void DrawMeshBase::fillInvVertexMap(
size_t n_vertices,
void *data) {
140 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
sizeof(
int) * n_vertices, data, GL_STATIC_DRAW);
Namespace providing different geometric functions concerning angles.
static void bindBufferARB(GLenum _target, GLuint _buffer)
same function as bindBuffer