Blame view

stim/gl/gl_spider.h 18.8 KB
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
1
2
3
  #ifndef STIM_GL_SPIDER_H
  #define STIM_GL_SPIDER_H
  
a9b45efe   Pavel Govyadinov   changes to spider
4
  #include <GL/glew.h>
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
5
  #include <GL/glut.h>
a9b45efe   Pavel Govyadinov   changes to spider
6
7
8
  #include <cuda.h>
  #include <cuda_gl_interop.h>
  #include <cudaGL.h>
1a456186   Pavel Govyadinov   Added directional...
9
  #include <math.h>
556c4e15   Pavel Govyadinov   Changed the handl...
10
11
12
13
14
15
16
17
  #include "stim/gl/gl_texture.h"
  #include "stim/visualization/camera.h"
  #include "stim/gl/error.h"
  #include "stim/math/vector.h"
  #include "stim/math/rect.h"
  #include "stim/math/matrix.h"
  #include "stim/cuda/cost.h"
  #include "stim/cuda/glbind.h"
385d2447   Pavel Govyadinov   Checkpoint: Conve...
18
  #include <vector>
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
19
  
42145f38   Pavel Govyadinov   Fixed the issues ...
20
21
22
  #include <iostream>
  #include <fstream>
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
23
24
25
26
27
  
  
  /* Technically since gl_spider inherits from gl_texture, we could
  	call the init with a path to an image stack, and upload
  	the images while creating the spider (calling init) */
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
28
29
30
31
  namespace stim
  {
  
  template<typename T>
8e56a0a7   Pavel Govyadinov   Added the propose...
32
  class gl_spider
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
33
34
  {
  	//doen't use gl_texture really, just needs the GLuint id.
4cefeb6d   Pavel Govyadinov   Changes to the re...
35
  	//doesn't even need the texture iD really.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
36
  	private:
8e56a0a7   Pavel Govyadinov   Added the propose...
37
38
  		stim::vec<float> p;  	//vector designating the position of the spider.
  		stim::vec<float> d;	//vector designating the orientation of the spider
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
39
  						//always a unit vector.
8e56a0a7   Pavel Govyadinov   Added the propose...
40
  		stim::vec<float> m;	//magnitude of the spider vector.
4cefeb6d   Pavel Govyadinov   Changes to the re...
41
42
  						//mag[0] = length.
  						//mag[1] = width.
8e56a0a7   Pavel Govyadinov   Added the propose...
43
44
45
46
47
48
49
50
  		std::vector<stim::vec<float> > dV;
  		std::vector<stim::vec<float> > pV;
  		std::vector<stim::vec<float> > mV;
  		//currentTransform
  		stim::matrix<float, 4> cT;
  		GLuint texID;
  		stim::vec<float> S;
  		stim::vec<float> R;
a9b45efe   Pavel Govyadinov   changes to spider
51
  		cudaGraphicsResource_t resource;
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
52
  
db3c28c9   Pavel Govyadinov   Implemented glDis...
53
  		GLuint dList;
a9b45efe   Pavel Govyadinov   changes to spider
54
55
  		GLuint fboID;
  		GLuint texbufferID;
2a18be6d   Pavel Govyadinov   New comments and ...
56
57
  		int iter;		//temporary for testing
  		int numSamples;
8e56a0a7   Pavel Govyadinov   Added the propose...
58
  		float stepsize = 3.0;
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
59
60
61
62
63
64
65
  
  		/// Method for finding the best scale for the spider.
  		/// changes the x, y, z size of the spider to minimize the cost
  		/// function. 
  		void
  		findOptimalDirection()
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
66
67
  			//genTemplate(dV, 0);
  			setMatrix();
db3c28c9   Pavel Govyadinov   Implemented glDis...
68
  			glCallList(dList);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
69
  			int best = getCost();
556c4e15   Pavel Govyadinov   Changed the handl...
70
  			stim::vec<float, 4> next;
8e56a0a7   Pavel Govyadinov   Added the propose...
71
72
73
   			next[0] = dV[best][0]*S[0]*R[0];
  			next[1] = dV[best][1]*S[1]*R[1];
  			next[2] = dV[best][2]*S[2]*R[2];
556c4e15   Pavel Govyadinov   Changed the handl...
74
  			next[3] = 1;
8e56a0a7   Pavel Govyadinov   Added the propose...
75
76
77
78
  			next = (cT*next).norm();
  			setPosition(	p[0]+next[0]*m[0]/stepsize,
  					p[1]+next[1]*m[0]/stepsize,
  					p[2]+next[2]*m[0]/stepsize);
556c4e15   Pavel Govyadinov   Changed the handl...
79
  			setDirection(next[0], next[1], next[2]);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
80
81
  		}
  
8e56a0a7   Pavel Govyadinov   Added the propose...
82
83
84
  		/// Method for finding the best d for the spider.
  		/// Not sure if necessary since the next p for the spider
  		/// will be at d * m.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
85
86
87
  		void
  		findOptimalPosition()
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
88
  			setMatrix();
db3c28c9   Pavel Govyadinov   Implemented glDis...
89
  			glCallList(dList+1);
385d2447   Pavel Govyadinov   Checkpoint: Conve...
90
  			int best = getCost();
db3c28c9   Pavel Govyadinov   Implemented glDis...
91
  			stim::vec<float, 4> next;
8e56a0a7   Pavel Govyadinov   Added the propose...
92
93
94
   			next[0] = pV[best][0];
  			next[1] = pV[best][1];
  			next[2] = pV[best][2];
db3c28c9   Pavel Govyadinov   Implemented glDis...
95
  			next[3] = 1;
8e56a0a7   Pavel Govyadinov   Added the propose...
96
97
98
99
100
  			next = cT*next;
  			std::cout << "Optimal p:"<< next << std::endl;
  			setPosition(	next[0]*S[0]*R[0],
  					next[1]*S[1]*R[1],
  					next[2]*S[2]*R[2]);
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
101
102
  		}
  	
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
103
104
105
  		/// Method for finding the best scale for the spider.
  		/// changes the x, y, z size of the spider to minimize the cost
  		/// function. */
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
106
107
108
  		void
  		findOptimalScale()
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
109
  			setMatrix();
db3c28c9   Pavel Govyadinov   Implemented glDis...
110
  			glCallList(dList+2);
385d2447   Pavel Govyadinov   Checkpoint: Conve...
111
  			int best = getCost();
db3c28c9   Pavel Govyadinov   Implemented glDis...
112
  			stim::vec<float, 4> next;
8e56a0a7   Pavel Govyadinov   Added the propose...
113
114
115
   			next[0] = mV[best][0]*S[0]*R[0];
  			next[1] = mV[best][1]*S[1]*R[1];
  			next[2] = mV[best][2]*S[2]*R[2];
db3c28c9   Pavel Govyadinov   Implemented glDis...
116
  			next[3] = 1;
8e56a0a7   Pavel Govyadinov   Added the propose...
117
  			next = cT*next;
db3c28c9   Pavel Govyadinov   Implemented glDis...
118
119
  			std::cout << "Optimal Scale:"<< next << std::endl;
  			setMagnitude(next[0]);
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
120
121
  		}
  
f31bf86d   Pavel Govyadinov   Added skeleton fu...
122
123
124
125
126
127
128
129
130
131
132
  		void
  		branchDetection()
  		{
  			Bind();
  			positionTemplate();
  			glCallList(dList+3);
  			
  			int best = getCost();
  			
  		}
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
133
134
  
  		
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
135
  		void
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
136
  		Optimize()
385d2447   Pavel Govyadinov   Checkpoint: Conve...
137
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
138
  			/*find the optimum d and scale */ 
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
139
  		}
385d2447   Pavel Govyadinov   Checkpoint: Conve...
140
  
a9b45efe   Pavel Govyadinov   changes to spider
141
  		
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
142
143
144
145
146
147
148
149
  		
  		
  //--------------------------------------------------------------------------//
  //---------------------TEMPLATE CREATION METHODS----------------------------//
  //--------------------------------------------------------------------------//
  
  		///@param solidAngle, the size of the arc to sample.
  		///Method for populating the vector arrays with sampled vectors.
8e56a0a7   Pavel Govyadinov   Added the propose...
150
  		///uses the default d vector <0,0,1>
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
151
  		void
25580fe7   Pavel Govyadinov   minor bug fix in ...
152
  		genDirectionVectors(float solidAngle = M_PI)
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
153
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
154
  			//Set up the vectors necessary for Rectangle creation.
22e7d0c5   Pavel Govyadinov   Minor changes in ...
155
156
157
158
159
  			vec<float> Y(1.0,0.0,0.0);
  			vec<float> pos(0.0,0.0,0.0);
  			vec<float> mag(1.0, 1.0, 1.0);
  			vec<float> dir(0.0, 0.0, 1.0);
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
160
  			vec<float> d_s = direction.cart2sph().norm();
8e56a0a7   Pavel Govyadinov   Added the propose...
161
162
  			//Set up the variable necessary for vector creation.
  			vec<float> d_s = d.cart2sph().norm();
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
163
164
  			vec<float> temp;
  			int dim = (sqrt(numSamples)-1)/2;
25580fe7   Pavel Govyadinov   minor bug fix in ...
165
166
167
  			float p0  	= -M_PI;
  			float dt  	= solidAngle/(2.0 * ((float)dim + 1.0));
  			float dp  	= p0/(2.0*((float)dim + 1.0));
8e56a0a7   Pavel Govyadinov   Added the propose...
168
169
170
171
  			
  			glNewList(dList, GL_COMPILE);
  			//Loop over the space
  			int idx = 0;
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
172
173
  			for(int i = -dim; i <= dim; i++){
  				for(int j = -dim; j <= dim; j++){
22e7d0c5   Pavel Govyadinov   Minor changes in ...
174
  				
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
175
  					//Create linear index
8e56a0a7   Pavel Govyadinov   Added the propose...
176
  					idx = (j+dim)+(i+dim)*((dim*2)+1);	
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
177
  					temp[0] = d_s[0]; 			//rotate vector
25580fe7   Pavel Govyadinov   minor bug fix in ...
178
179
  					temp[1] = d_s[1]+dp*(float) i;
  					temp[2] = d_s[2]+dt*(float) j;
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
180
181
  					
  					temp = (temp.sph2cart()).norm();	//back to cart
8e56a0a7   Pavel Govyadinov   Added the propose...
182
183
184
185
186
187
188
189
190
191
192
193
  					dV.push_back(temp);
  				 	if(cos(Y.dot(temp))< 0.087){                                                                             Y[0] = 0.0; Y[1] = 1.0;}
  					else{Y[0] = 1.0; Y[1] = 0.0;}
  
                                         	hor = stim::rect<float>(mag,
  						 pos, temp,
                         				((Y.cross(temp)).cross(temp)).norm());
         				 	ver = stim::rect<float>(mag,
  						 pos, temp,
                         				hor.n());
  					UpdateBuffer(0.0, 0.0+idx*10.0);
  					CHECK_OPENGL_ERROR
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
194
195
  				}
  			}
8e56a0a7   Pavel Govyadinov   Added the propose...
196
  			glEndList();
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
197
  		}
2a18be6d   Pavel Govyadinov   New comments and ...
198
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
199
200
201
  		///@param solidAngle, the size of the arc to sample.
  		///Method for populating the buffer with the sampled texture.
  		///uses the default vector <0,0,0>
a9f956be   Pavel Govyadinov   Fixed the cost fu...
202
  		void
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
203
  		genPositionVectors(float delta = 0.2)
a9f956be   Pavel Govyadinov   Fixed the cost fu...
204
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
205
206
207
208
209
210
211
  			//Set up the vectors necessary for Rectangle creation.
  			vec<float> Y(1.0,0.0,0.0);
  			vec<float> pos(0.0,0.0,0.0);
  			vec<float> mag(1.0, 1.0, 1.0);
  			vec<float> dir(0.0, 0.0, 1.0);
  
  			//Set up the variable necessary for vector creation.
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
212
213
214
  			vec<float> temp;
  			int dim = (sqrt(numSamples)-1)/2;
  			stim::rect<float> samplingPlane =
8e56a0a7   Pavel Govyadinov   Added the propose...
215
  				 stim::rect<float>(m[0]*delta, p, d);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
216
  			float step = 1.0/(dim);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
217
  
8e56a0a7   Pavel Govyadinov   Added the propose...
218
219
220
221
  			//Loop over the samples, keeping the original p sample
  			//in the center of the resulting texture.
  			int idx;
  			glNewList(dList+1, GL_COMPILE);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
222
223
224
  			for(int i = -dim; i <= dim; i++){
  				for(int j = -dim; j <= dim; j++){
  					//Create linear index
8e56a0a7   Pavel Govyadinov   Added the propose...
225
  					idx = (j+dim)+(i+dim)*((dim*2)+1);	
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
226
227
228
229
230
  
  					temp = samplingPlane.p(
  							0.5+step*i,
  								 0.5+step*j
  										);
8e56a0a7   Pavel Govyadinov   Added the propose...
231
232
233
234
235
236
237
238
239
240
  					pV.push_back(temp);
                  			hor = stim::rect<float>(mag,
  						 temp, dir,
                        				((Y.cross(d)).cross(d))
  						.norm());
                  			ver = stim::rect<float>(mag,
  						 temp, dir,
                          			hor.n());
  					UpdateBuffer(0.0, 0.0+idx*10.0);
  				CHECK_OPENGL_ERROR
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
241
242
  				}
  			}
8e56a0a7   Pavel Govyadinov   Added the propose...
243
  			glEndList();
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
244
245
246
247
  		}
  
  		///@param solidAngle, the size of the arc to sample.
  		///Method for populating the buffer with the sampled texture.
8e56a0a7   Pavel Govyadinov   Added the propose...
248
  		///uses the default m <1,1,0>
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
249
250
251
252
  		void
  		genMagnitudeVectors(float delta = 0.5)
  		{
  			
8e56a0a7   Pavel Govyadinov   Added the propose...
253
254
255
256
257
258
259
  			//Set up the vectors necessary for Rectangle creation.
  			vec<float> Y(1.0,0.0,0.0);
  			vec<float> pos(0.0,0.0,0.0);
  			vec<float> mag(1.0, 1.0, 1.0);
  			vec<float> dir(0.0, 0.0, 1.0);
  
  			//Set up the variable necessary for vector creation.
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
260
261
262
263
264
265
266
  			int dim = (sqrt(numSamples)-1)/2;
  			float min 	= 1.0-delta;
  			float max 	= 1.0+delta;
  			float step	= (max-min)/(numSamples-1);
  			float factor;
  			vec<float> temp;
  
8e56a0a7   Pavel Govyadinov   Added the propose...
267
  			glNewList(dList+2, GL_COMPILE);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
268
269
  			for(int i = 0; i < numSamples; i++){
  				//Create linear index
8e56a0a7   Pavel Govyadinov   Added the propose...
270
  				factor = (min+step*i)*m[0];
db3c28c9   Pavel Govyadinov   Implemented glDis...
271
  				temp = factor;
8e56a0a7   Pavel Govyadinov   Added the propose...
272
273
274
275
276
277
278
279
280
281
  				mV.push_back(temp);	
  				hor = stim::rect<float>(temp,
  					 pos, dir, 
         	       				((Y.cross(d)).cross(d))
  					.norm());
                 			ver = stim::rect<float>(temp,
  					 pos, dir,
                         			hor.n());
  				UpdateBuffer(0.0, 0.0+i*10.0);
  			CHECK_OPENGL_ERROR
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
282
  			}
8e56a0a7   Pavel Govyadinov   Added the propose...
283
  			glEndList();
a9f956be   Pavel Govyadinov   Fixed the cost fu...
284
  		}
2a18be6d   Pavel Govyadinov   New comments and ...
285
286
  		///@param v_x x-coordinate in buffer-space,
  		///@param v_y y-coordinate in buffer-space.
22e7d0c5   Pavel Govyadinov   Minor changes in ...
287
  					 ilVertex2f(0.0, j*10.0);
2a18be6d   Pavel Govyadinov   New comments and ...
288
289
  		///Samples the texturespace and places a sample in the provided coordinates
  		///of bufferspace.
a9f956be   Pavel Govyadinov   Fixed the cost fu...
290
291
292
  		void
  		UpdateBuffer(float v_x, float v_y)
  		{	
a9f956be   Pavel Govyadinov   Fixed the cost fu...
293
294
295
296
297
  			float len = 10.0;
  			stim::vec<float>p1; 
          	        stim::vec<float>p2; 
  	                stim::vec<float>p3; 
                  	stim::vec<float>p4;	
a9f956be   Pavel Govyadinov   Fixed the cost fu...
298
  			p1 = hor.p(1,1);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
299
  			p2 = hor.p(1,0);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
300
  			p3 = hor.p(0,0);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
301
  			p4 = hor.p(0,1);
5e7c7581   Pavel Govyadinov   Debugging build f...
302
  			glBegin(GL_QUADS);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
303
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
304
305
306
307
  					p1[0],
  					p1[1],
  					p1[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
308
309
  				glVertex2f(v_x,v_y);
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
310
311
312
313
  					p2[0],
  					p2[1],
  					p2[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
314
315
  				glVertex2f(v_x+len, v_y);
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
316
317
318
319
  					p3[0],
  					p3[1],
  					p3[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
320
321
  				glVertex2f(v_x+len, v_y+len);
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
322
323
324
  					p4[0],
  					p4[1],
  					p4[2]
a9f956be   Pavel Govyadinov   Fixed the cost fu...
325
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
326
327
  				glVertex2f(v_x, v_y+len);
  			 glEnd();
5e7c7581   Pavel Govyadinov   Debugging build f...
328
  
a9f956be   Pavel Govyadinov   Fixed the cost fu...
329
  			 p1 = ver.p(1,1);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
330
  			 p2 = ver.p(1,0);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
331
  			 p3 = ver.p(0,0);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
332
  			 p4 = ver.p(0,1);
5e7c7581   Pavel Govyadinov   Debugging build f...
333
  		 	 glBegin(GL_QUADS);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
334
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
335
336
337
338
  					p1[0],
  					p1[1],
  					p1[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
339
340
  				glVertex2f(v_x+len, v_y);
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
341
342
343
344
  					p2[0],
  					p2[1],
  					p2[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
345
346
  				glVertex2f(v_x+2*len, v_y);
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
347
348
349
350
  					p3[0],
  					p3[1],
  					p3[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
351
352
  				glVertex2f(v_x+2*len, v_y+len);
  				glTexCoord3f(
a9f956be   Pavel Govyadinov   Fixed the cost fu...
353
354
355
356
  					p4[0],
  					p4[1],
  					p4[2]
  					);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
357
  				glVertex2f(v_x+len, v_y+len);
5e7c7581   Pavel Govyadinov   Debugging build f...
358
  			glEnd(); 
a9f956be   Pavel Govyadinov   Fixed the cost fu...
359
  		}
2a18be6d   Pavel Govyadinov   New comments and ...
360
  		
385d2447   Pavel Govyadinov   Checkpoint: Conve...
361
  
385d2447   Pavel Govyadinov   Checkpoint: Conve...
362
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
363
364
365
  //--------------------------------------------------------------------------//
  //--------------------------------GL METHODS--------------------------------//
  //--------------------------------------------------------------------------//
385d2447   Pavel Govyadinov   Checkpoint: Conve...
366
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
  		///@param width sets the width of the buffer.
  		///@param height sets the height of the buffer.
  		///Function for setting up the 2D buffer that stores the samples.
  		void
  		GenerateFBO(unsigned int width, unsigned int height)
  		{
  			glGenFramebuffers(1, &fboID);
  			glBindFramebuffer(GL_FRAMEBUFFER, fboID);
  			int numChannels = 1;
  			unsigned char* texels = new unsigned char[width * height * numChannels];
  			glGenTextures(1, &texbufferID);
  			glBindTexture(GL_TEXTURE_2D, texbufferID);
  			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  			glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
  				 width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texels);   
  			delete[] texels;
  			glBindFramebuffer(GL_FRAMEBUFFER, 0); 
  			glBindTexture(GL_TEXTURE_2D, 0);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
388
  		}
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
389
  
2a18be6d   Pavel Govyadinov   New comments and ...
390
391
  		///Method for controling the buffer and texture binding in order to properly
  		///do the render to texture.
a9f956be   Pavel Govyadinov   Fixed the cost fu...
392
  		void
2a18be6d   Pavel Govyadinov   New comments and ...
393
  		Bind()
a9f956be   Pavel Govyadinov   Fixed the cost fu...
394
  		{
5f81932b   David Mayerich   restored Pavel's ...
395
  			float len = 10.0;
a9f956be   Pavel Govyadinov   Fixed the cost fu...
396
397
398
399
400
401
402
403
404
405
406
  			glBindFramebuffer(GL_FRAMEBUFFER, fboID);//set up GL buffer		
  			glFramebufferTexture2D(
  				GL_FRAMEBUFFER,
  				GL_COLOR_ATTACHMENT0,
  				GL_TEXTURE_2D,
  				texbufferID,
  				0);
  			glBindFramebuffer(GL_FRAMEBUFFER, fboID);
  			GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
  			glDrawBuffers(1, DrawBuffers);
  			glBindTexture(GL_TEXTURE_2D, texbufferID);
5e7c7581   Pavel Govyadinov   Debugging build f...
407
  			glClearColor(1,1,1,1);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
408
  			glClear(GL_COLOR_BUFFER_BIT);
a9f956be   Pavel Govyadinov   Fixed the cost fu...
409
410
411
412
413
414
415
416
  			glMatrixMode(GL_PROJECTION);
  			glLoadIdentity();
  			glMatrixMode(GL_MODELVIEW);
  			glLoadIdentity();
  			glViewport(0,0,2.0*len, numSamples*len);
  			gluOrtho2D(0.0,2.0*len,0.0,numSamples*len);
  			glEnable(GL_TEXTURE_3D);
  			glBindTexture(GL_TEXTURE_3D, texID);
957a4248   Pavel Govyadinov   renamed getSample...
417
  
5e7c7581   Pavel Govyadinov   Debugging build f...
418
  			CHECK_OPENGL_ERROR
5f81932b   David Mayerich   restored Pavel's ...
419
420
  		}
  		
2a18be6d   Pavel Govyadinov   New comments and ...
421
  		///Method for Unbinding all of the texture resources
5f81932b   David Mayerich   restored Pavel's ...
422
423
424
425
426
427
428
429
430
  		void
  		Unbind()
  		{
  			//Finalize GL_buffer
  			glBindTexture(GL_TEXTURE_3D, 0);                      
  			glDisable(GL_TEXTURE_3D);
  			glBindFramebuffer(GL_FRAMEBUFFER,0);
  			glBindTexture(GL_TEXTURE_2D, 0);
  		}
385d2447   Pavel Govyadinov   Checkpoint: Conve...
431
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
432
433
  		///Method for using the gl manipulation to alighn templates from
  		///Template space (-0.5 0.5) to Texture space (0.0, 1.0),
8e56a0a7   Pavel Govyadinov   Added the propose...
434
435
  		///Based on the p of the spider in real space (arbitrary).
  		void setMatrix()
5f81932b   David Mayerich   restored Pavel's ...
436
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
437
  			stim::vec<float, 4> rot = getRotation(d);
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
438
439
  			glMatrixMode(GL_TEXTURE);
  			glLoadIdentity();
db3c28c9   Pavel Govyadinov   Implemented glDis...
440
441
  
  			glRotatef(rot[0], rot[1], rot[2], rot[3]);
8e56a0a7   Pavel Govyadinov   Added the propose...
442
443
444
445
446
447
448
  			glScalef(1.0/S[0]/R[0], 1.0/S[1]/R[1], 1.0/S[2]/R[2]);
  			glTranslatef(p[0],
  				     p[1],
  				     p[2]);
  			glScalef(m[0],
  				 m[1],
  				 m[0]);
db3c28c9   Pavel Govyadinov   Implemented glDis...
449
  
556c4e15   Pavel Govyadinov   Changed the handl...
450
451
  			float curTrans[16];
  			glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
b2d10ff1   Pavel Govyadinov   final edits, expa...
452
  			cT.set(curTrans);
556c4e15   Pavel Govyadinov   Changed the handl...
453
454
  			printTransform();
  			
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
455
456
  			CHECK_OPENGL_ERROR
  			glMatrixMode(GL_MODELVIEW);
5f81932b   David Mayerich   restored Pavel's ...
457
  		}
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
458
459
  		
  		
5f81932b   David Mayerich   restored Pavel's ...
460
  
42145f38   Pavel Govyadinov   Fixed the issues ...
461
462
463
464
465
  
  //--------------------------------------------------------------------------//
  //--------------------------------CUDA METHODS------------------------------//
  //--------------------------------------------------------------------------//
  		
2a18be6d   Pavel Govyadinov   New comments and ...
466
467
  		/// Method for registering the texture with Cuda for shared
  		///	access.
42145f38   Pavel Govyadinov   Fixed the issues ...
468
469
470
471
472
473
474
475
476
477
478
479
480
  		void
  		createResource()
  		{
  			HANDLE_ERROR(
  				cudaGraphicsGLRegisterImage(
  					 &resource,
  				 	texbufferID,
  				 	GL_TEXTURE_2D,
  				 	//CU_GRAPHICS_REGISTER_FLAGS_NONE)
  					cudaGraphicsMapFlagsReadOnly)
  			);
  		} 
  		
2a18be6d   Pavel Govyadinov   New comments and ...
481
  		///Method for freeing the texture from Cuda for gl access.
42145f38   Pavel Govyadinov   Fixed the issues ...
482
483
484
485
486
487
488
489
  		void
  		destroyResource()
  		{
  			HANDLE_ERROR(
  				cudaGraphicsUnregisterResource(resource)
  			);		
  		}
  
2a18be6d   Pavel Govyadinov   New comments and ...
490
491
  		///Entry-point into the cuda code for calculating the cost
  		///	of a given samples array (in texture form) 
42145f38   Pavel Govyadinov   Fixed the issues ...
492
493
494
495
  		int
  		getCost()
  		{
  			createResource();
5e7c7581   Pavel Govyadinov   Debugging build f...
496
  			int cost = 	get_cost(resource, iter, numSamples);
42145f38   Pavel Govyadinov   Fixed the issues ...
497
498
499
  			destroyResource();
  			iter++;
  			return cost;
a9f956be   Pavel Govyadinov   Fixed the cost fu...
500
501
  		}
  
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
502
  	public:
13c2a7d4   Pavel Govyadinov   some changes to t...
503
504
505
  		stim::rect<float> hor;
  		stim::rect<float> ver;	
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
506
507
508
509
510
  //--------------------------------------------------------------------------//
  //-----------------------------CONSTRUCTORS---------------------------------//
  //--------------------------------------------------------------------------//
  
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
511
512
513
  		///@param samples, the number of samples this spider is going to use.
  		///best results if samples is can create a perfect root.
  		///Default Constructor
2a18be6d   Pavel Govyadinov   New comments and ...
514
  		gl_spider
8e56a0a7   Pavel Govyadinov   Added the propose...
515
  		(int samples = 1089)
2a18be6d   Pavel Govyadinov   New comments and ...
516
517
518
519
520
  		{
  			setPosition(0.0,0.0,0.0);
  			setDirection(0.0,0.0,1.0);
  			setMagnitude(1.0);
  			numSamples = samples;
4cefeb6d   Pavel Govyadinov   Changes to the re...
521
522
  		}
  
385d2447   Pavel Govyadinov   Checkpoint: Conve...
523
  		///temporary constructor for convenience, will be removed in further updates.	
13c2a7d4   Pavel Govyadinov   some changes to t...
524
525
  		gl_spider
  		(float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z,
5f81932b   David Mayerich   restored Pavel's ...
526
  			float mag_x)
13c2a7d4   Pavel Govyadinov   some changes to t...
527
  		{
887a3e49   Pavel Govyadinov   fixed some order ...
528
529
530
  			setPosition(pos_x, pos_y, pos_z);
  			setDirection(dir_x, dir_y, dir_z);
  			setMagnitude(mag_x);
2a18be6d   Pavel Govyadinov   New comments and ...
531
  		
385d2447   Pavel Govyadinov   Checkpoint: Conve...
532
  		}
8e56a0a7   Pavel Govyadinov   Added the propose...
533
534
535
536
537
538
539
540
541
  	
  		~gl_spider
  		(void)
  		{
  			Unbind();
  			glDeleteTextures(1, &texbufferID);
  			glDeleteBuffers(1, &fboID);
  		}
  
385d2447   Pavel Govyadinov   Checkpoint: Conve...
542
  		///@param GLuint id texture that is going to be sampled.
385d2447   Pavel Govyadinov   Checkpoint: Conve...
543
  		///Attached the spider to the texture with the given GLuint ID.
8e56a0a7   Pavel Govyadinov   Added the propose...
544
  		///Samples in the default d acting as the init method.
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
545
  		///Also acts an init.	
a9b45efe   Pavel Govyadinov   changes to spider
546
  		void
2a18be6d   Pavel Govyadinov   New comments and ...
547
  		attachSpider(GLuint id)
a9b45efe   Pavel Govyadinov   changes to spider
548
549
  		{
  			texID = id;
2a18be6d   Pavel Govyadinov   New comments and ...
550
  			iter = 0; ///for debugging purposes
5f81932b   David Mayerich   restored Pavel's ...
551
  			GenerateFBO(20, numSamples*10);
8e56a0a7   Pavel Govyadinov   Added the propose...
552
553
  			setDims(0.6, 0.6, 1.0);
  			setSize(512.0, 512.0, 426.0);
db3c28c9   Pavel Govyadinov   Implemented glDis...
554
  
db3c28c9   Pavel Govyadinov   Implemented glDis...
555
  			dList = glGenLists(3);
db3c28c9   Pavel Govyadinov   Implemented glDis...
556
  			glListBase(dList);
8e56a0a7   Pavel Govyadinov   Added the propose...
557
558
559
560
  			Bind();
  			genDirectionVectors(5*M_PI/4);
  			genPositionVectors();
  			genMagnitudeVectors();
f31bf86d   Pavel Govyadinov   Added skeleton fu...
561
  			DrawCylinder();
8e56a0a7   Pavel Govyadinov   Added the propose...
562
  			Unbind();
a39577bf   Pavel Govyadinov   Changes to the sp...
563
  		}
5f81932b   David Mayerich   restored Pavel's ...
564
  		
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
565
566
567
  //--------------------------------------------------------------------------//
  //-----------------------------ACCESS METHODS-------------------------------//
  //--------------------------------------------------------------------------//
8e56a0a7   Pavel Govyadinov   Added the propose...
568
  		///Returns the p vector.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
569
  		vec<float>
a39577bf   Pavel Govyadinov   Changes to the sp...
570
  		getPosition()
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
571
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
572
  			return p;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
573
574
  		}
  	
8e56a0a7   Pavel Govyadinov   Added the propose...
575
  		///Returns the d vector.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
576
  		vec<float>
a39577bf   Pavel Govyadinov   Changes to the sp...
577
  		getDirection()
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
578
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
579
  			return d;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
580
581
  		}
  
8e56a0a7   Pavel Govyadinov   Added the propose...
582
  		///Returns the m vector.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
583
  		vec<float>
a39577bf   Pavel Govyadinov   Changes to the sp...
584
  		getMagnitude()
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
585
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
586
  			return m;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
587
588
  		}
  	
8e56a0a7   Pavel Govyadinov   Added the propose...
589
590
  		///@param vector pos, the new p.
  		///Sets the p vector to input vector pos.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
591
592
593
  		void
  		setPosition(vec<float> pos)
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
594
  			p = pos;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
595
  		}
385d2447   Pavel Govyadinov   Checkpoint: Conve...
596
597
598
599
  
  		///@param x x-coordinate.
  		///@param y y-coordinate.
  		///@param z z-coordinate.
8e56a0a7   Pavel Govyadinov   Added the propose...
600
  		///Sets the p vector to the input float coordinates x,y,z.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
601
602
603
  		void
  		setPosition(float x, float y, float z)
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
604
605
606
  			p[0] = x;
  			p[1] = y;
  			p[2] = z;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
607
  		}
887a3e49   Pavel Govyadinov   fixed some order ...
608
  		
8e56a0a7   Pavel Govyadinov   Added the propose...
609
610
  		///@param vector dir, the new d.
  		///Sets the d vector to input vector dir.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
611
612
613
  		void
  		setDirection(vec<float> dir)
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
614
  			d = dir;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
615
616
  		}
  		
385d2447   Pavel Govyadinov   Checkpoint: Conve...
617
618
619
  		///@param x x-coordinate.
  		///@param y y-coordinate.
  		///@param z z-coordinate.
8e56a0a7   Pavel Govyadinov   Added the propose...
620
  		///Sets the d vector to the input float coordinates x,y,z.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
621
622
623
  		void
  		setDirection(float x, float y, float z)
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
624
625
626
  			d[0] = x;
  			d[1] = y;
  			d[2] = z;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
627
  		}
385d2447   Pavel Govyadinov   Checkpoint: Conve...
628
  			
8e56a0a7   Pavel Govyadinov   Added the propose...
629
630
  		///@param vector dir, the new d.
  		///Sets the m vector to the input vector mag.	
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
631
632
633
  		void
  		setMagnitude(vec<float> mag)
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
634
635
  			m[0] = mag[0];
  			m[1] = mag[0];
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
636
637
  		}
  		
385d2447   Pavel Govyadinov   Checkpoint: Conve...
638
  		///@param mag size of the sampled region.
8e56a0a7   Pavel Govyadinov   Added the propose...
639
  		///Sets the m vector to the input mag for both templates.
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
640
  		void
5f81932b   David Mayerich   restored Pavel's ...
641
  		setMagnitude(float mag)
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
642
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
643
644
  			m[0] = mag;
  			m[1] = mag;
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
645
  		}
5f81932b   David Mayerich   restored Pavel's ...
646
  		
8e56a0a7   Pavel Govyadinov   Added the propose...
647
648
649
650
651
652
653
654
655
  
  		void
  		setDims(float x, float y, float z)
  		{
  			S[0] = x;
  			S[1] = y;
  			S[2] = z;
  		}
  
b710b044   Pavel Govyadinov   Added more tempor...
656
  		void
8e56a0a7   Pavel Govyadinov   Added the propose...
657
  		setSize(float x, float y, float z)
b710b044   Pavel Govyadinov   Added more tempor...
658
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
659
660
661
  			R[0] = x;
  			R[1] = y;
  			R[2] = z;
b710b044   Pavel Govyadinov   Added more tempor...
662
663
  		}
  		
f304d6de   Pavel Govyadinov   added rotation to...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
  		///@param dir, the vector to which we are rotating
  		///given a vector to align to, finds the required
  		///axis and angle for glRotatef
  		stim::vec<float, 4>
  		getRotation(stim::vec<float> dir)
  		{
  			stim::vec<float, 4> out;
  			stim::vec<float> from(0,0,1);
  			out[0] = acos(from.dot(dir))*M_PI/180;
  			if(out[0] < 0.0001){
  				out[0] = 0.0;
  				out[1] = 0.0;
  				out[2] = 0.0;
  				out[3] = 1.0;
  			} else {
  				stim::vec<float> temp;
  				temp = (from.cross(dir)).norm();
  				out[1] = temp[0];
  				out[2] = temp[1];
  				out[3] = temp[2];
  			}
  			return out;
  		}
f304d6de   Pavel Govyadinov   added rotation to...
687
  		
db3c28c9   Pavel Govyadinov   Implemented glDis...
688
689
  		///Function to get back the framebuffer Object attached to the spider.
  		///For external access.
a9b45efe   Pavel Govyadinov   changes to spider
690
691
692
693
694
  		GLuint
  		getFB()
  		{
  			return fboID;
  		}
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
695
  
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
696
697
698
699
700
701
702
703
704
  //--------------------------------------------------------------------------//
  //-----------------------------TEMPORARY METHODS----------------------------//
  //--------------------------------------------------------------------------//
  
  		///temporary Method necessary for visualization and testing.
  		void
  		Update()
  		{
  			vec<float> Y(1.0,0.0,0.0);
8e56a0a7   Pavel Govyadinov   Added the propose...
705
  			if(cos(Y.dot(d))< 0.087){
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
706
  				Y[0] = 0.0; Y[1] = 1.0;}
8e56a0a7   Pavel Govyadinov   Added the propose...
707
708
709
  			hor = stim::rect<float>(m, p, d.norm(),
  				((Y.cross(d)).cross(d)).norm());
  			ver = stim::rect<float>(m, p, d.norm(),
266aa74a   Pavel Govyadinov   CHECKPOINT: Minor...
710
711
712
713
  				 hor.n());
  		}
  
  
13c2a7d4   Pavel Govyadinov   some changes to t...
714
715
716
  		void
  		Step()
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
717
  			Bind();
42145f38   Pavel Govyadinov   Fixed the issues ...
718
  			findOptimalDirection();
db3c28c9   Pavel Govyadinov   Implemented glDis...
719
720
  			findOptimalPosition();
  			findOptimalScale();
f31bf86d   Pavel Govyadinov   Added skeleton fu...
721
  			branchDetection();
8e56a0a7   Pavel Govyadinov   Added the propose...
722
  			Unbind();
13c2a7d4   Pavel Govyadinov   some changes to t...
723
  		}
a9b45efe   Pavel Govyadinov   changes to spider
724
  
556c4e15   Pavel Govyadinov   Changed the handl...
725
726
727
728
  
  		void
  		printTransform()
  		{
8e56a0a7   Pavel Govyadinov   Added the propose...
729
  			std::cout << cT << std::endl;
b710b044   Pavel Govyadinov   Added more tempor...
730
  		}
a9b45efe   Pavel Govyadinov   changes to spider
731
  
42145f38   Pavel Govyadinov   Fixed the issues ...
732
733
734
735
736
  		/* Method for initializing the cuda devices, necessary only
  			there are multiple cuda devices */
  		void
  		initCuda()
  		{	
2a18be6d   Pavel Govyadinov   New comments and ...
737
  			stim::cudaSetDevice();
42145f38   Pavel Govyadinov   Fixed the issues ...
738
739
740
  			//GLint max;
  			//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
  			//std::cout << max << std::endl;
a9b45efe   Pavel Govyadinov   changes to spider
741
  		}
f31bf86d   Pavel Govyadinov   Added skeleton fu...
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
  
  //--------------------------------------------------------------------------//
  //-----------------------------EXPERIMENTAL METHODS-------------------------//
  //--------------------------------------------------------------------------//
  
  		void
  		DrawCylinder()
  		{	 
  			 Bind();
  			 glNewList(dList+3, GL_COMPILE);
  			 float z0 = -0.5; float z1 = 0.5; float r0 = 0.5;
  			 float x,y;
  			 float xold = 0.5; float yold = 0.5;
  			 float step = 360.0/numSamples;
  		 	 int j = 0;
  			 glEnable(GL_TEXTURE_3D);
  			 glBindTexture(GL_TEXTURE_3D, texID);
  			 glBegin(GL_QUAD_STRIP);
  			 	for(float i = step; i <= 360.0; i += step)
  			 	{
  					 x=r0*cos(i*2.0*M_PI/360.0);
  					 y=r0*sin(i*2.0*M_PI/360.0);
  					 glTexCoord3f(x,y,z0); 
22e7d0c5   Pavel Govyadinov   Minor changes in ...
765
  					 glVertex2f(0.0, j*0.1+0.1);
f31bf86d   Pavel Govyadinov   Added skeleton fu...
766
  					 glTexCoord3f(x,y,z1); 
22e7d0c5   Pavel Govyadinov   Minor changes in ...
767
  					 glVertex2f(20.0, j*0.1+0.1);
f31bf86d   Pavel Govyadinov   Added skeleton fu...
768
  					 glTexCoord3f(xold,yold,z1); 
22e7d0c5   Pavel Govyadinov   Minor changes in ...
769
  					 glVertex2f(20.0, j*0.1); 
f31bf86d   Pavel Govyadinov   Added skeleton fu...
770
  					 glTexCoord3f(xold,yold,z0); 
22e7d0c5   Pavel Govyadinov   Minor changes in ...
771
  					 glVertex2f(0.0, j*0.1);
f31bf86d   Pavel Govyadinov   Added skeleton fu...
772
773
774
775
776
777
778
779
  					 xold=x;
  					 yold=y;
  					 j++;
  				}
  		      	 glEnd();  
  			 glEndList();
  			 Unbind();
  		}
4cefeb6d   Pavel Govyadinov   Changes to the re...
780
  };
fb0bc2f1   Pavel Govyadinov   added the gl_spid...
781
782
  }
  #endif