diff --git a/include/Algo/Render/GL2/colorPerFaceRender.hpp b/include/Algo/Render/GL2/colorPerFaceRender.hpp index 7e19a7672a57c5d38014d9d47d0d757eccff2fa1..67957c1caf887d267b28e83a9def0f3f59c60ce1 100644 --- a/include/Algo/Render/GL2/colorPerFaceRender.hpp +++ b/include/Algo/Render/GL2/colorPerFaceRender.hpp @@ -162,6 +162,91 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNorma +/* + +template +void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, Utils::VBO& vboTexCoord, + typename PFP::MAP& map, + const VertexAttribute& positions, + const AttributeHandler& colorPerXXX, + CellMarker& specialVertices, + const VertexAttribute& texCoordPerVertex, + const AttributeHandler& texCoordPerDart) + +{ + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + + std::vector buffer; + buffer.reserve(16384); + + std::vector bufferColors; + bufferColors.reserve(16384); + + + std::vector bufferTC; + bufferColors.reserve(16384); + + TraversorCell traFace(map); + + for (Dart d=traFace.begin(); d!=traFace.end(); d=traFace.next()) + { + Dart a = d; + Dart b = map.phi1(a); + Dart c = map.phi1(b); + // loop to cut a polygon in triangle on the fly (works only with convex faces) + do + { + buffer.push_back(positions[d]); + bufferColors.push_back(colorPerXXX[d]); + if (specialVertices.isMarked(d)) + bufferTC.push_back(texCoordPerDart[d]); + else + bufferTC.push_back(texCoordPerVertex[d]); + + buffer.push_back(positions[b]); + bufferColors.push_back(colorPerXXX[b]); + if (specialVertices.isMarked(c)) + bufferTC.push_back(texCoordPerDart[b]); + else + bufferTC.push_back(texCoordPerVertex[b]); + + buffer.push_back(positions[c]); + bufferColors.push_back(colorPerXXX[c]); + if (specialVertices.isMarked(c)) + bufferTC.push_back(texCoordPerDart[c]); + else + bufferTC.push_back(texCoordPerVertex[c]); + + b = c; + c = map.phi1(b); + } while (c != d); + } + + m_nbTris = buffer.size()/3; + + vboPosition.setDataSize(3); + vboPosition.allocate(buffer.size()); + VEC3* ptrPos = reinterpret_cast(vboPosition.lockPtr()); + memcpy(ptrPos, &buffer[0], buffer.size()*sizeof(VEC3)); + vboPosition.releasePtr(); + + vboTexCoord.setDataSize(2); + vboTexCoord.allocate(bufferTC.size()); + VEC3* ptrTC = reinterpret_cast(vboTexCoord.lockPtr()); + memcpy(ptrTC, &bufferTC[0], bufferTC.size()*sizeof(VEC2)); + vboTexCoord.releasePtr(); + + vboColor.setDataSize(3); + vboColor.allocate(bufferColors.size()); + VEC3* ptrCol = reinterpret_cast(vboColor.lockPtr()); + memcpy(ptrCol, &bufferColors[0], bufferColors.size()*sizeof(VEC3)); + vboColor.releasePtr(); +} + +*/ + + inline void ColorPerFaceRender::draw(Utils::GLSLShader* sh) { sh->enableVertexAttribs();