Merge branch 'master' into codim2integrals

This commit is contained in:
Christopher Lackner 2016-11-03 14:34:06 +01:00
commit 191380e227
2 changed files with 22 additions and 6 deletions

View File

@ -8,7 +8,6 @@
// #include <parallel.hpp> // #include <parallel.hpp>
#include <visual.hpp> #include <visual.hpp>
#include <limits> #include <limits>
namespace netgen namespace netgen
{ {
@ -439,10 +438,20 @@ namespace netgen
// glEnable(GL_BLEND); // glEnable(GL_BLEND);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glCallList (surfellist); glCallList (surfellist);
#ifdef USE_BUFFERS
static int timer = NgProfiler::CreateTimer ("Solution::drawing - DrawSurfaceElements VBO"); static int timer = NgProfiler::CreateTimer ("Solution::drawing - DrawSurfaceElements VBO");
NgProfiler::StartTimer(timer); 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); 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); NgProfiler::StopTimer(timer);
#endif
glDisable(GL_BLEND); glDisable(GL_BLEND);
/* /*
// transparent test ... // transparent test ...
@ -1288,25 +1297,27 @@ namespace netgen
Array<complex<double> > valuesc(npt); Array<complex<double> > valuesc(npt);
#ifdef USE_BUFFERS
if (has_surfel_vbo) if (has_surfel_vbo)
glDeleteBuffers (4, &surfel_vbo[0]); glDeleteBuffers (4, &surfel_vbo[0]);
glGenBuffers (4, &surfel_vbo[0]); glGenBuffers (4, &surfel_vbo[0]);
has_surfel_vbo = true; has_surfel_vbo = true;
glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[0]); glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[0]);
glBufferData (GL_ARRAY_BUFFER, glBufferData (GL_ARRAY_BUFFER,
nse*npt*sizeof(Point<3,double>), nse*npt*sizeof(Point<3,double>),
NULL, GL_STATIC_DRAW); NULL, GL_STATIC_DRAW);
glVertexPointer(3, GL_DOUBLE, 0, 0); glVertexPointer(3, GL_DOUBLE, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY); // glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[1]); glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[1]);
glBufferData (GL_ARRAY_BUFFER, glBufferData (GL_ARRAY_BUFFER,
nse*npt*sizeof(Vec<3,double>), nse*npt*sizeof(Vec<3,double>),
NULL, GL_STATIC_DRAW); NULL, GL_STATIC_DRAW);
glEnableClientState(GL_NORMAL_ARRAY); // glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_DOUBLE, 0, 0); glNormalPointer(GL_DOUBLE, 0, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); // glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[2]); glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[2]);
glBufferData (GL_ARRAY_BUFFER, nse*npt*sizeof(double), NULL, GL_STATIC_DRAW); glBufferData (GL_ARRAY_BUFFER, nse*npt*sizeof(double), NULL, GL_STATIC_DRAW);
glTexCoordPointer(1, GL_DOUBLE, 0, 0); glTexCoordPointer(1, GL_DOUBLE, 0, 0);
@ -1314,6 +1325,7 @@ namespace netgen
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surfel_vbo[3]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surfel_vbo[3]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, nse*npt*6*sizeof(int), NULL, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, nse*npt*6*sizeof(int), NULL, GL_STATIC_DRAW);
surfel_vbo_size = 0; surfel_vbo_size = 0;
#endif
NgProfiler::StopTimer(timerstart); NgProfiler::StopTimer(timerstart);
@ -1677,6 +1689,7 @@ namespace netgen
NgProfiler::StartTimer(timer2); NgProfiler::StartTimer(timer2);
#ifdef USE_BUFFERS
if (drawelem && usetexture == 1 && !logscale) if (drawelem && usetexture == 1 && !logscale)
{ {
glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[0]); glBindBuffer (GL_ARRAY_BUFFER, surfel_vbo[0]);
@ -1700,7 +1713,7 @@ namespace netgen
} }
else else
#endif
for (int iy = 0, ii = 0; iy < n; iy++) for (int iy = 0, ii = 0; iy < n; iy++)
{ {
glBegin (GL_TRIANGLE_STRIP); glBegin (GL_TRIANGLE_STRIP);

View File

@ -43,9 +43,12 @@ class DLL_HEADER VisualSceneSolution : public VisualScene
Point<3> p; Point<3> p;
}; };
// #define USE_BUFFERS
#ifdef USE_BUFFERS
bool has_surfel_vbo = false; bool has_surfel_vbo = false;
GLuint surfel_vbo[4]; // GLuint surfel_vbo[4]; //
size_t surfel_vbo_size; size_t surfel_vbo_size;
#endif
int surfellist; int surfellist;
int linelist; int linelist;
int element1dlist; int element1dlist;