From e780f55ddd43b8139429b5230d08951371cf803a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Tue, 1 Nov 2016 21:04:31 +0100 Subject: [PATCH 1/2] include glew --- libsrc/visualization/vssolution.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index bc73ad27..36484d3b 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -8,7 +8,9 @@ // #include #include - +#ifdef WIN32 +#include +#endif #include namespace netgen { From 08a662ae7731eefd40224807a2e7d3eea7a0914a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Wed, 2 Nov 2016 06:05:08 +0100 Subject: [PATCH 2/2] optional use of opengl-buffers (not supported on WIN without additional library) --- libsrc/visualization/vssolution.cpp | 27 +++++++++++++++++++-------- libsrc/visualization/vssolution.hpp | 3 +++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index 36484d3b..6a02e54e 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -8,9 +8,6 @@ // #include #include -#ifdef WIN32 -#include -#endif #include namespace netgen { @@ -441,10 +438,20 @@ namespace netgen // glEnable(GL_BLEND); glDisable(GL_BLEND); glCallList (surfellist); + +#ifdef USE_BUFFERS static int timer = NgProfiler::CreateTimer ("Solution::drawing - DrawSurfaceElements VBO"); NgProfiler::StartTimer(timer); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDrawElements(GL_TRIANGLES, surfel_vbo_size, GL_UNSIGNED_INT, 0); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); NgProfiler::StopTimer(timer); +#endif + glDisable(GL_BLEND); /* // transparent test ... @@ -1289,26 +1296,28 @@ namespace netgen if (sol && sol->draw_surface) mvalues.SetSize (npt * sol->components); Array > valuesc(npt); - + +#ifdef USE_BUFFERS if (has_surfel_vbo) glDeleteBuffers (4, &surfel_vbo[0]); glGenBuffers (4, &surfel_vbo[0]); + has_surfel_vbo = true; glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[0]); glBufferData (GL_ARRAY_BUFFER, nse*npt*sizeof(Point<3,double>), NULL, GL_STATIC_DRAW); glVertexPointer(3, GL_DOUBLE, 0, 0); - glEnableClientState(GL_VERTEX_ARRAY); + // glEnableClientState(GL_VERTEX_ARRAY); glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[1]); glBufferData (GL_ARRAY_BUFFER, nse*npt*sizeof(Vec<3,double>), NULL, GL_STATIC_DRAW); - glEnableClientState(GL_NORMAL_ARRAY); + // glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_DOUBLE, 0, 0); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + // glEnableClientState(GL_TEXTURE_COORD_ARRAY); glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[2]); glBufferData (GL_ARRAY_BUFFER, nse*npt*sizeof(double), NULL, GL_STATIC_DRAW); glTexCoordPointer(1, GL_DOUBLE, 0, 0); @@ -1316,6 +1325,7 @@ namespace netgen glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surfel_vbo[3]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, nse*npt*6*sizeof(int), NULL, GL_STATIC_DRAW); surfel_vbo_size = 0; +#endif NgProfiler::StopTimer(timerstart); @@ -1679,6 +1689,7 @@ namespace netgen NgProfiler::StartTimer(timer2); +#ifdef USE_BUFFERS if (drawelem && usetexture == 1 && !logscale) { glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[0]); @@ -1702,7 +1713,7 @@ namespace netgen } else - +#endif for (int iy = 0, ii = 0; iy < n; iy++) { glBegin (GL_TRIANGLE_STRIP); diff --git a/libsrc/visualization/vssolution.hpp b/libsrc/visualization/vssolution.hpp index 4dee9fe4..d8193d56 100644 --- a/libsrc/visualization/vssolution.hpp +++ b/libsrc/visualization/vssolution.hpp @@ -43,9 +43,12 @@ class DLL_HEADER VisualSceneSolution : public VisualScene Point<3> p; }; + // #define USE_BUFFERS +#ifdef USE_BUFFERS bool has_surfel_vbo = false; GLuint surfel_vbo[4]; // size_t surfel_vbo_size; +#endif int surfellist; int linelist; int element1dlist;