44 #include <ACG/GL/acg_glew.hh> 45 #include "DrawMesh.hh" 49 DrawMeshBase::DrawMeshBase() :
51 numTris_(0), numVerts_(0),
58 vertexDecl_ =
new VertexDeclaration;
59 vertexDeclEdgeCol_ =
new VertexDeclaration;
60 vertexDeclHalfedgeCol_ =
new VertexDeclaration;
61 vertexDeclHalfedgePos_ =
new VertexDeclaration;
64 DrawMeshBase::~DrawMeshBase() {
65 if (vbo_) glDeleteBuffers(1, &vbo_);
66 if (ibo_) glDeleteBuffers(1, &ibo_);
67 if (lineIBO_) glDeleteBuffers(1, &lineIBO_);
68 if (heVBO_) glDeleteBuffers(1, &heVBO_);
71 delete vertexDeclEdgeCol_;
72 delete vertexDeclHalfedgeCol_;
73 delete vertexDeclHalfedgePos_;
75 if (pickVertexIBO_) glDeleteBuffers(1, &pickVertexIBO_);
78 void DrawMeshBase::deleteIbo() {
80 glDeleteBuffers(1, &ibo_);
84 void DrawMeshBase::bindVbo() {
86 glGenBuffers(1, &vbo_);
91 void DrawMeshBase::bindIbo() {
93 glGenBuffers(1, &ibo_);
98 void DrawMeshBase::bindLineIbo() {
100 glGenBuffers(1, &lineIBO_);
105 void DrawMeshBase::bindHEVbo() {
106 glGetIntegerv(GL_ARRAY_BUFFER_BINDING,&prevVBO_);
108 glGenBuffers(1, &heVBO_);
113 void DrawMeshBase::unbindHEVbo() {
117 void DrawMeshBase::bindPickVertexIbo() {
119 glGenBuffers(1, &pickVertexIBO_);
121 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, pickVertexIBO_);
124 void DrawMeshBase::createIndexBuffer() {
125 glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
126 numTris_ * 3 *
sizeof(
unsigned int),
127 meshComp_->getIndexBuffer(), GL_STATIC_DRAW_ARB);
130 void DrawMeshBase::fillLineBuffer(
size_t n_edges,
void *data) {
132 if (indexType_ == GL_UNSIGNED_SHORT)
133 glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
134 n_edges * 2 *
sizeof(
unsigned short),
135 data, GL_STATIC_DRAW_ARB);
137 glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
138 n_edges * 2 *
sizeof(
unsigned int),
139 data, GL_STATIC_DRAW_ARB);
142 void DrawMeshBase::fillHEVBO(
size_t numberOfElements_,
size_t sizeOfElements_,
void* data_)
145 glBufferData(GL_ARRAY_BUFFER,numberOfElements_ * sizeOfElements_, data_, GL_STATIC_DRAW);
149 void DrawMeshBase::fillVertexBuffer() {
150 if (!vertices_.empty())
151 glBufferData(GL_ARRAY_BUFFER_ARB, numVerts_ * vertexDecl_->getVertexStride(), &vertices_[0], GL_STATIC_DRAW_ARB);
154 void DrawMeshBase::fillInvVertexMap(
size_t n_vertices,
void *data) {
155 glBufferData(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