diff --git a/stim/visualization/gl_network.h b/stim/visualization/gl_network.h index 9f5c84d..48765b9 100644 --- a/stim/visualization/gl_network.h +++ b/stim/visualization/gl_network.h @@ -13,13 +13,19 @@ protected: using stim::network::E; using stim::network::V; + GLuint dlist; + public: /// Default constructor - gl_network() : stim::network(){} + gl_network() : stim::network(){ + dlist = 0; + } /// Constructor creates a gl_network from a stim::network - gl_network(stim::network N) : stim::network(N){} + gl_network(stim::network N) : stim::network(N){ + dlist = 0; + } /// Fills the parameters with the minimum and maximum spatial positions in the network, /// specifying a bounding box for the network geometry @@ -40,14 +46,20 @@ public: /// Render the network centerline as a series of line strips. void glCenterline(){ - for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network - glBegin(GL_LINE_STRIP); - for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); - glTexCoord1f(E[e].ri(p)); + if(!glIsList(dlist)){ //if dlist isn't a display list, create it + dlist = glGenLists(1); //generate a display list + glNewList(dlist, GL_COMPILE); //start a new display list + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network + glBegin(GL_LINE_STRIP); + for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); + glTexCoord1f(E[e].ri(p)); + } + glEnd(); } - glEnd(); - } + glEndList(); //end the display list + } + glCallList(dlist); // render the display list } -- libgit2 0.21.4