Commit 9a08b7b1 authored by untereiner's avatar untereiner

update mapRender index buffers management (dirty flag)

parent 8dbdbd97
...@@ -602,8 +602,10 @@ void MyQT::cb_Open() ...@@ -602,8 +602,10 @@ void MyQT::cb_Open()
void MyQT::cb_Save() void MyQT::cb_Save()
{ {
std::string filename = selectFileSave("Export SVG file ",".","(*.off)"); std::string filename = selectFileSave("Export MAP file ",".","(*.map)");
Algo::Surface::Export::exportOFF<PFP>(myMap, position, filename.c_str()); // ??? //Algo::Surface::Export::exportOFF<PFP>(myMap, position, filename.c_str()); // ???
if(!myMap.saveMapBin(filename))
std::cout << "could not save file : " << filename << std::endl;
} }
void MyQT::importMesh(std::string& filename) void MyQT::importMesh(std::string& filename)
......
...@@ -26,7 +26,7 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName) ...@@ -26,7 +26,7 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg); MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
PFP2::MAP* map = mh->getMap(); PFP2::MAP* map = mh->getMap();
std::vector<std::string> attrNames ; std::vector<std::string> attrNames;
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toUtf8().constData(), attrNames); Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toUtf8().constData(), attrNames);
// get vertex position attribute // get vertex position attribute
...@@ -37,11 +37,6 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName) ...@@ -37,11 +37,6 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
// compute map bounding box // compute map bounding box
mh->updateBB(position); mh->updateBB(position);
// compute primitive connectivity VBOs
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
} }
return mhg; return mhg;
} }
......
...@@ -37,11 +37,6 @@ MapHandlerGen* ImportVolumePlugin::importFromFile(const QString& fileName) ...@@ -37,11 +37,6 @@ MapHandlerGen* ImportVolumePlugin::importFromFile(const QString& fileName)
// compute map bounding box // compute map bounding box
mh->updateBB(position); mh->updateBB(position);
// compute primitive connectivity VBOs
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
} }
return mhg; return mhg;
} }
......
...@@ -44,9 +44,10 @@ void SubdivideSurfacePlugin::subdivideSurface() ...@@ -44,9 +44,10 @@ void SubdivideSurfacePlugin::subdivideSurface()
else if(m_subdivideSurfaceDialog->radio_trianguleFaces->isChecked()) else if(m_subdivideSurfaceDialog->radio_trianguleFaces->isChecked())
trianguleFaces(map, position); trianguleFaces(map, position);
mh->updatePrimitives(Algo::Render::GL2::POINTS); mh->setPrimitiveDirty(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES); mh->setPrimitiveDirty(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); mh->setPrimitiveDirty(Algo::Render::GL2::TRIANGLES);
mh->updateVBO(position); mh->updateVBO(position);
QList<View*> views = mh->getLinkedViews(); QList<View*> views = mh->getLinkedViews();
......
importPlugin = schnapps.loadPlugin("ImportSurface"); importPlugin = schnapps.loadPlugin("ImportSurface");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
renderPlugin = schnapps.loadPlugin("Render"); renderPlugin = schnapps.loadPlugin("Render");
renderVectorPlugin = schnapps.loadPlugin("RenderVector"); renderVectorPlugin = schnapps.loadPlugin("RenderVector");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface");
obj = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/midRes/bimba_75k.off"); #obj = importPlugin.importFromFile("/home/untereiner/Developments/meshes/egea.off");
v = schnapps.getView("view_0"); v = schnapps.getView("view_0");
schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName()); schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName()); schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
schnapps.linkViewAndMap(v.getName(), obj.getName()); #schnapps.linkViewAndMap(v.getName(), obj.getName());
differentialPropertiesPlugin.computeNormal(obj.getName()); #differentialPropertiesPlugin.computeNormal(obj.getName());
differentialPropertiesPlugin.computeCurvature(obj.getName()); #differentialPropertiesPlugin.computeCurvature(obj.getName());
...@@ -47,7 +47,9 @@ public slots: ...@@ -47,7 +47,9 @@ public slots:
bool isUsed() const { return !l_views.empty(); } bool isUsed() const { return !l_views.empty(); }
public: public:
void draw(Utils::GLSLShader* shader, int primitive) { m_render->draw(shader, primitive); } virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
void setPrimitiveDirty(int primitive) { m_render->setPrimitiveDirty(primitive); }
/********************************************************* /*********************************************************
* MANAGE ATTRIBUTES * MANAGE ATTRIBUTES
...@@ -143,6 +145,13 @@ public: ...@@ -143,6 +145,13 @@ public:
delete m_map; delete m_map;
} }
virtual void draw(Utils::GLSLShader* shader, int primitive)
{
if(!m_render->isPrimitiveUpToDate(primitive))
updatePrimitives(primitive);
m_render->draw(shader, primitive);
}
typename PFP::MAP* getMap() { return static_cast<typename PFP::MAP*>(m_map); } typename PFP::MAP* getMap() { return static_cast<typename PFP::MAP*>(m_map); }
void updateBB(const VertexAttribute<typename PFP::VEC3>& position) void updateBB(const VertexAttribute<typename PFP::VEC3>& position)
......
...@@ -539,18 +539,21 @@ MapHandlerGen* Window::addMap(const QString& name, unsigned int dim) ...@@ -539,18 +539,21 @@ MapHandlerGen* Window::addMap(const QString& name, unsigned int dim)
if (h_maps.contains(name)) if (h_maps.contains(name))
return NULL; return NULL;
GenericMap* map = NULL; MapHandlerGen* mh = NULL;
switch(dim) switch(dim)
{ {
case 2 : case 2 : {
map = new PFP2::MAP(); PFP2::MAP* map = new PFP2::MAP();
mh = new MapHandler<PFP2>(name, this, map);
break; break;
case 3 : }
map = new PFP3::MAP(); case 3 : {
PFP3::MAP* map = new PFP3::MAP();
mh = new MapHandler<PFP3>(name, this, map);
break; break;
}
} }
MapHandlerGen* mh = new MapHandlerGen(name, this, map);
h_maps.insert(name, mh); h_maps.insert(name, mh);
emit(mapAdded(mh)); emit(mapAdded(mh));
......
...@@ -138,10 +138,20 @@ public: ...@@ -138,10 +138,20 @@ public:
Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ; Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, df, m_position);
m_map.incCurrentLevel() ;
m_position[d] = p ; if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,df)
&& !Algo::Surface::Modelisation::isPrism<PFP>(m_map,df)
&& !Algo::Surface::Modelisation::isPyra<PFP>(m_map,df))
{
typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, df, m_position);
m_map.incCurrentLevel() ;
m_position[d] = p ;
}
else
m_map.incCurrentLevel() ;
return false ; return false ;
} }
......
...@@ -622,7 +622,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -622,7 +622,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
Dart dd = m_map.phi1(m_map.phi1(old)); Dart dd = m_map.phi1(m_map.phi1(old));
m_map.splitFace(old,dd) ; m_map.splitFace(old,dd) ;
centralDart = old; //centralDart = old;
} }
else else
{ {
...@@ -712,7 +712,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -712,7 +712,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
} }
//replonger l'orbit de ditV. //replonger l'orbit de ditV.
//m_map.template setOrbitEmbedding<VERTEX>(x, m_map.template getEmbedding<VERTEX>(d)); m_map.template setOrbitEmbedding<VERTEX>(centralDart, m_map.template getEmbedding<VERTEX>(centralDart));
(*volumeVertexFunctor)(centralDart) ; (*volumeVertexFunctor)(centralDart) ;
...@@ -747,6 +747,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -747,6 +747,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
//replonger l'orbit de ditV. //replonger l'orbit de ditV.
m_map.template setOrbitEmbedding<VERTEX>(x, m_map.template getEmbedding<VERTEX>(x)); m_map.template setOrbitEmbedding<VERTEX>(x, m_map.template getEmbedding<VERTEX>(x));
(*volumeVertexFunctor)(x) ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
} }
...@@ -786,8 +787,8 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -786,8 +787,8 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
} }
m_map.template setOrbitEmbedding<VERTEX>(centralDart, m_map.template getEmbedding<VERTEX>(centralDart)); m_map.template setOrbitEmbedding<VERTEX>(x, m_map.template getEmbedding<VERTEX>(x));
(*volumeVertexFunctor)(centralDart) ; (*volumeVertexFunctor)(x) ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
} }
...@@ -836,8 +837,8 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -836,8 +837,8 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
} }
m_map.incCurrentLevel(); m_map.incCurrentLevel();
m_map.popLevel() ; m_map.popLevel() ;
return vLevel; return vLevel;
......
...@@ -132,7 +132,6 @@ public: ...@@ -132,7 +132,6 @@ public:
template<typename PFP> template<typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ; void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;
/** /**
* draw edges * draw edges
*/ */
......
...@@ -58,22 +58,12 @@ namespace GL2 ...@@ -58,22 +58,12 @@ namespace GL2
enum drawingType enum drawingType
{ {
TRIANGLES = 1, POINTS = 0,
LINES = 2, LINES = 1,
POINTS = 4, TRIANGLES = 2,
EXPLODED = 8, FLAT_TRIANGLES = 3,
FLAT_TRIANGLES = 16, BOUNDARY = 4,
BOUNDARY = 32, EXPLODED = 5,
ERR = 64
} ;
enum bufferIndex
{
POINT_INDICES = 0,
LINE_INDICES = 1,
TRIANGLE_INDICES = 2,
FLAT_BUFFER = 3,
BOUNDARY_INDICES = 4,
SIZE_BUFFER SIZE_BUFFER
} ; } ;
...@@ -84,6 +74,7 @@ protected: ...@@ -84,6 +74,7 @@ protected:
* vbo buffers * vbo buffers
*/ */
GLuint m_indexBuffers[SIZE_BUFFER] ; GLuint m_indexBuffers[SIZE_BUFFER] ;
bool m_indexBufferUpToDate[SIZE_BUFFER];
/** /**
* nb indices * nb indices
...@@ -208,6 +199,7 @@ public: ...@@ -208,6 +199,7 @@ public:
*/ */
template <typename PFP> template <typename PFP>
void initBoundaries(typename PFP::MAP& map, const FunctorSelect& good, std::vector<GLuint>& tableIndices, unsigned int thread = 0) ; void initBoundaries(typename PFP::MAP& map, const FunctorSelect& good, std::vector<GLuint>& tableIndices, unsigned int thread = 0) ;
/** /**
* initialization of the VBO indices primitives * initialization of the VBO indices primitives
* computed by a traversal of the map * computed by a traversal of the map
...@@ -226,6 +218,20 @@ public: ...@@ -226,6 +218,20 @@ public:
*/ */
void initPrimitives(int prim, std::vector<GLuint>& tableIndices) ; void initPrimitives(int prim, std::vector<GLuint>& tableIndices) ;
/**
* initialization of the VBO indices primitives
* using the given table
* @param prim primitive to draw: POINT_INDICES, LINE_INDICES, TRIANGLE_INDICES
*/
bool isPrimitiveUpToDate(int prim) { return m_indexBufferUpToDate[prim]; }
/**
* initialization of the VBO indices primitives
* using the given table
* @param prim primitive to draw: POINT_INDICES, LINE_INDICES, TRIANGLE_INDICES
*/
void setPrimitiveDirty(int prim) { m_indexBufferUpToDate[prim] = false; }
/** /**
* draw the VBO (function to call in the drawing callback) * draw the VBO (function to call in the drawing callback)
*/ */
......
...@@ -495,48 +495,39 @@ void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good ...@@ -495,48 +495,39 @@ void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good
{ {
std::vector<GLuint> tableIndices; std::vector<GLuint> tableIndices;
// indice du VBO a utiliser
int vbo_ind = 0;
switch(prim) switch(prim)
{ {
case POINTS: case POINTS:
initPoints<PFP>(map, good, tableIndices, thread); initPoints<PFP>(map, good, tableIndices, thread);
m_nbIndices[POINT_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[POINT_INDICES];
break; break;
case LINES: case LINES:
if(optimized) if(optimized)
initLinesOptimized<PFP>(map, good, tableIndices, thread); initLinesOptimized<PFP>(map, good, tableIndices, thread);
else else
initLines<PFP>(map, good, tableIndices, thread) ; initLines<PFP>(map, good, tableIndices, thread) ;
m_nbIndices[LINE_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[LINE_INDICES];
break; break;
case TRIANGLES: case TRIANGLES:
if(optimized) if(optimized)
initTrianglesOptimized<PFP>(map, good, tableIndices, position, thread); initTrianglesOptimized<PFP>(map, good, tableIndices, position, thread);
else else
initTriangles<PFP>(map, good, tableIndices, position, thread) ; initTriangles<PFP>(map, good, tableIndices, position, thread) ;
m_nbIndices[TRIANGLE_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[TRIANGLE_INDICES];
break; break;
case FLAT_TRIANGLES: case FLAT_TRIANGLES:
break; break;
case BOUNDARY: case BOUNDARY:
initBoundaries<PFP>(map, good, tableIndices, thread) ; initBoundaries<PFP>(map, good, tableIndices, thread) ;
m_nbIndices[BOUNDARY_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[BOUNDARY_INDICES];
break; break;
default: default:
CGoGNerr << "problem initializing VBO indices" << CGoGNendl; CGoGNerr << "problem initializing VBO indices" << CGoGNendl;
break; break;
} }
unsigned int size = tableIndices.size();
m_nbIndices[prim] = tableIndices.size();
m_indexBufferUpToDate[prim] = true;
// setup du buffer d'indices // setup du buffer d'indices
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, vbo_ind); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[prim]);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(GLuint), &(tableIndices[0]), GL_STREAM_DRAW); glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, m_nbIndices[prim] * sizeof(GLuint), &(tableIndices[0]), GL_STREAM_DRAW);
} }
} // namespace GL2 } // namespace GL2
......
...@@ -41,7 +41,10 @@ MapRender::MapRender() ...@@ -41,7 +41,10 @@ MapRender::MapRender()
{ {
glGenBuffers(SIZE_BUFFER, m_indexBuffers) ; glGenBuffers(SIZE_BUFFER, m_indexBuffers) ;
for(unsigned int i = 0; i < SIZE_BUFFER; ++i) for(unsigned int i = 0; i < SIZE_BUFFER; ++i)
{
m_nbIndices[i] = 0 ; m_nbIndices[i] = 0 ;
m_indexBufferUpToDate[i] = false;
}
} }
MapRender::~MapRender() MapRender::~MapRender()
...@@ -51,65 +54,33 @@ MapRender::~MapRender() ...@@ -51,65 +54,33 @@ MapRender::~MapRender()
void MapRender::initPrimitives(int prim, std::vector<GLuint>& tableIndices) void MapRender::initPrimitives(int prim, std::vector<GLuint>& tableIndices)
{ {
// indice du VBO a utiliser m_nbIndices[prim] = tableIndices.size();
int vbo_ind = 0; m_indexBufferUpToDate[prim] = true;
int size = 0;
switch(prim)
{
case POINTS:
m_nbIndices[POINT_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[POINT_INDICES];
size = m_nbIndices[POINT_INDICES];
break;
case LINES:
m_nbIndices[LINE_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[LINE_INDICES];
size = m_nbIndices[LINE_INDICES];
break;
case TRIANGLES:
m_nbIndices[TRIANGLE_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[TRIANGLE_INDICES];
size = m_nbIndices[TRIANGLE_INDICES];
break;
case BOUNDARY:
m_nbIndices[BOUNDARY_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[BOUNDARY_INDICES];
size = m_nbIndices[BOUNDARY_INDICES];
break;
default:
CGoGNerr << "problem initializing VBO indices" << CGoGNendl;
break;
}
// setup du buffer d'indices // setup du buffer d'indices
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_ind); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[prim]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(GLuint), &(tableIndices[0]), GL_STREAM_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_nbIndices[prim] * sizeof(GLuint), &(tableIndices[0]), GL_STREAM_DRAW);
} }
void MapRender::draw(Utils::GLSLShader* sh, int prim) void MapRender::draw(Utils::GLSLShader* sh, int prim)
{ {
sh->enableVertexAttribs(); sh->enableVertexAttribs();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[prim]);
switch(prim) switch(prim)
{ {
case POINTS: case POINTS:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[POINT_INDICES]); glDrawElements(GL_POINTS, m_nbIndices[POINTS], GL_UNSIGNED_INT, 0) ;
glDrawElements(GL_POINTS, m_nbIndices[POINT_INDICES], GL_UNSIGNED_INT, 0) ;
break; break;
case LINES: case LINES:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[LINE_INDICES]); glDrawElements(GL_LINES, m_nbIndices[LINES], GL_UNSIGNED_INT, 0);
glDrawElements(GL_LINES, m_nbIndices[LINE_INDICES], GL_UNSIGNED_INT, 0);
break; break;
case TRIANGLES: case TRIANGLES:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[TRIANGLE_INDICES]); glDrawElements(GL_TRIANGLES, m_nbIndices[TRIANGLES], GL_UNSIGNED_INT, 0);
glDrawElements(GL_TRIANGLES, m_nbIndices[TRIANGLE_INDICES], GL_UNSIGNED_INT, 0);
break; break;
case BOUNDARY: case BOUNDARY:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[BOUNDARY_INDICES]); glDrawElements(GL_LINES, m_nbIndices[BOUNDARY], GL_UNSIGNED_INT, 0);
glDrawElements(GL_LINES, m_nbIndices[BOUNDARY_INDICES], GL_UNSIGNED_INT, 0);
break; break;
default: default:
break; break;
} }
...@@ -121,25 +92,22 @@ unsigned int MapRender::drawSub(Utils::GLSLShader* sh, int prim, unsigned int nb ...@@ -121,25 +92,22 @@ unsigned int MapRender::drawSub(Utils::GLSLShader* sh, int prim, unsigned int nb
{ {
sh->enableVertexAttribs(); sh->enableVertexAttribs();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[prim]);
switch(prim) switch(prim)
{ {
case POINTS: case POINTS:
if (nb_elm > m_nbIndices[POINT_INDICES]) if (nb_elm > m_nbIndices[POINTS])
nb_elm = m_nbIndices[POINT_INDICES]; nb_elm = m_nbIndices[POINTS];
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[POINT_INDICES]);
glDrawElements(GL_POINTS, nb_elm, GL_UNSIGNED_INT, 0) ; glDrawElements(GL_POINTS, nb_elm, GL_UNSIGNED_INT, 0) ;
break; break;
case LINES: case LINES:
if (2*nb_elm > m_nbIndices[LINE_INDICES]) if (2*nb_elm > m_nbIndices[LINES])
nb_elm = m_nbIndices[LINE_INDICES]/2; nb_elm = m_nbIndices[LINES]/2;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[LINE_INDICES]);
glDrawElements(GL_LINES, 2*nb_elm, GL_UNSIGNED_INT, 0); glDrawElements(GL_LINES, 2*nb_elm, GL_UNSIGNED_INT, 0);
break; break;
case TRIANGLES: case TRIANGLES:
if (3*nb_elm > m_nbIndices[TRIANGLE_INDICES]) if (3*nb_elm > m_nbIndices[TRIANGLES])
nb_elm = m_nbIndices[TRIANGLE_INDICES]/3; nb_elm = m_nbIndices[TRIANGLES]/3;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[TRIANGLE_INDICES]);
glDrawElements(GL_TRIANGLES, 3*nb_elm, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, 3*nb_elm, GL_UNSIGNED_INT, 0);
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment