50 #include <ACG/GL/acg_glew.hh> 51 #include "MeshNode2T.hh" 56 MeshNodeBase::MeshNodeBase(
BaseNode* _parent, std::string _name) :
64 void MeshNodeBase::supplyDrawMesh(DrawMeshBase *drawMeshBase) {
70 throw std::runtime_error(
"MeshNodeBase::supplyDrawMesh called " 73 throw std::runtime_error(
"MeshNodeBase::supplyDrawMesh called " 74 "with NULL parameter.");
76 drawMeshBase_ = drawMeshBase;
79 void MeshNodeBase::updatePolyEdgeBuf()
82 #ifdef GL_ARB_texture_buffer_object 84 assert(drawMeshBase_);
86 MeshCompiler *
const mc = drawMeshBase_->getMeshCompiler();
87 if (mc && !mc->isTriangleMesh())
91 glGenBuffers(1, &polyEdgeBuf_);
93 const int nTris = mc->getNumTriangles();
95 const int newBufSize = (nTris/2+1);
97 if (polyEdgeBufSize_ != newBufSize)
99 glBindBuffer(GL_TEXTURE_BUFFER, polyEdgeBuf_);
111 polyEdgeBufSize_ = newBufSize;
112 unsigned char* polyEdgeBufData =
new unsigned char[newBufSize];
115 memset(polyEdgeBufData, 0, newBufSize);
118 for (
int i = 0; i < nTris; ++i)
121 int bitidx = (i&1) * 3;
123 for (
int k = 0; k < 3; ++k)
124 if (mc->isFaceEdge(i, k))
125 polyEdgeBufData[byteidx] += 1 << (k + bitidx);
128 glBufferData(GL_TEXTURE_BUFFER, polyEdgeBufSize_, polyEdgeBufData, GL_STATIC_DRAW);
131 delete [] polyEdgeBufData;
136 if (!polyEdgeBufTex_)
138 glGenTextures(1, &polyEdgeBufTex_);
140 glActiveTexture(GL_TEXTURE0);
141 glBindTexture(GL_TEXTURE_BUFFER, polyEdgeBufTex_);
142 glTexBuffer(GL_TEXTURE_BUFFER, GL_R8UI, polyEdgeBuf_);
144 glBindTexture(GL_TEXTURE_2D, 0);
Namespace providing different geometric functions concerning angles.