From cb06d775a511c82777aec9ef6974fb807cb2c733 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 7 Jun 2012 18:49:20 +0000 Subject: [PATCH] csg - visualization with vertex arrays --- libsrc/csg/vscsg.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libsrc/csg/vscsg.cpp b/libsrc/csg/vscsg.cpp index 7eba751e..dc72b51a 100644 --- a/libsrc/csg/vscsg.cpp +++ b/libsrc/csg/vscsg.cpp @@ -169,28 +169,36 @@ namespace netgen { trilists.Append (glGenLists (1)); glNewList (trilists.Last(), GL_COMPILE); - glEnable (GL_NORMALIZE); const TriangleApproximation & ta = *geometry->GetTriApprox(i); if (&ta) { - glBegin (GL_TRIANGLES); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_DOUBLE, 0, &ta.GetPoint(0)(0)); + + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_DOUBLE, 0, &ta.GetNormal(0)(0)); + + for (int j = 0; j < ta.GetNT(); j++) + glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, & (ta.GetTriangle(j)[0])); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + + /* for (int j = 0; j < ta.GetNT(); j++) { + glBegin (GL_TRIANGLES); for (int k = 0; k < 3; k++) { int pi = ta.GetTriangle(j)[k]; glNormal3dv (ta.GetNormal(pi)); glVertex3dv (ta.GetPoint(pi)); } - if (j % 1000 == 9999) // got crashes on NVIDA - { - glEnd (); - glBegin (GL_TRIANGLES); - } + glEnd (); } - glEnd (); + */ } glEndList (); }