Commit 649a5e3459e07375283e53fc4ba9221e81acf199
1 parent
c184655c
implemented display lists for interactive rendering of stim::gl_network
Showing
1 changed file
with
21 additions
and
9 deletions
Show diff stats
stim/visualization/gl_network.h
@@ -13,13 +13,19 @@ protected: | @@ -13,13 +13,19 @@ protected: | ||
13 | using stim::network<T>::E; | 13 | using stim::network<T>::E; |
14 | using stim::network<T>::V; | 14 | using stim::network<T>::V; |
15 | 15 | ||
16 | + GLuint dlist; | ||
17 | + | ||
16 | public: | 18 | public: |
17 | 19 | ||
18 | /// Default constructor | 20 | /// Default constructor |
19 | - gl_network() : stim::network<T>(){} | 21 | + gl_network() : stim::network<T>(){ |
22 | + dlist = 0; | ||
23 | + } | ||
20 | 24 | ||
21 | /// Constructor creates a gl_network from a stim::network | 25 | /// Constructor creates a gl_network from a stim::network |
22 | - gl_network(stim::network<T> N) : stim::network<T>(N){} | 26 | + gl_network(stim::network<T> N) : stim::network<T>(N){ |
27 | + dlist = 0; | ||
28 | + } | ||
23 | 29 | ||
24 | /// Fills the parameters with the minimum and maximum spatial positions in the network, | 30 | /// Fills the parameters with the minimum and maximum spatial positions in the network, |
25 | /// specifying a bounding box for the network geometry | 31 | /// specifying a bounding box for the network geometry |
@@ -40,14 +46,20 @@ public: | @@ -40,14 +46,20 @@ public: | ||
40 | /// Render the network centerline as a series of line strips. | 46 | /// Render the network centerline as a series of line strips. |
41 | void glCenterline(){ | 47 | void glCenterline(){ |
42 | 48 | ||
43 | - for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
44 | - glBegin(GL_LINE_STRIP); | ||
45 | - for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge | ||
46 | - glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
47 | - glTexCoord1f(E[e].ri(p)); | 49 | + if(!glIsList(dlist)){ //if dlist isn't a display list, create it |
50 | + dlist = glGenLists(1); //generate a display list | ||
51 | + glNewList(dlist, GL_COMPILE); //start a new display list | ||
52 | + for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network | ||
53 | + glBegin(GL_LINE_STRIP); | ||
54 | + for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge | ||
55 | + glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); | ||
56 | + glTexCoord1f(E[e].ri(p)); | ||
57 | + } | ||
58 | + glEnd(); | ||
48 | } | 59 | } |
49 | - glEnd(); | ||
50 | - } | 60 | + glEndList(); //end the display list |
61 | + } | ||
62 | + glCallList(dlist); // render the display list | ||
51 | 63 | ||
52 | } | 64 | } |
53 | 65 |