Commit 4cc75fd4e6e4d866f139fa1bc34ce4722eeefdff

Authored by Pavel Govyadinov
1 parent fc091644

cleaned things up

Showing 2 changed files with 47 additions and 57 deletions   Show diff stats
TextureTest.cu
... ... @@ -36,8 +36,6 @@
36 36 stim::vec<float> d;
37 37 static bool button1 = FALSE;
38 38 static float degtorad = 360/(2*M_PI);
39   - //static GLfloat viewDistance = 1.0;
40   - //static float pos = 1.0;
41 39 static GLfloat adjustTex = 1.0/426.0;
42 40 static GLfloat adjustDrw = 2.0/426.0;
43 41 static GLfloat oriTex[3] = {adjustTex*213+adjustTex/2
... ... @@ -50,7 +48,7 @@
50 48  
51 49 //init for a cube
52 50 void
53   -glInit(int w, int h)
  51 +glInit()
54 52 {
55 53 CHECK_OPENGL_ERROR
56 54 glEnable(GL_TEXTURE_3D);
... ... @@ -65,45 +63,34 @@ glInit(int w, int h)
65 63 p = cam.getPosition();
66 64 up = cam.getUp();
67 65 d = cam.getLookAt();
68   - //gluLookAt(d[0], d[1], d[2], p[0], p[1], p[2], up[0], up[1], up[2]);
69 66 glViewport(0, 0, size[0], size[1]);
70 67 glMatrixMode(GL_PROJECTION);
71 68 glLoadIdentity();
72   - //gluPerspective(60, 4.0/3.0, 0.1, 100.0);
73   - //glOrtho(-2.0, 2.0,-2.0, 2.0, -0.0, 3000.0);
74 69 glMatrixMode(GL_MODELVIEW);
75 70  
76 71 CHECK_OPENGL_ERROR
77 72 }
78 73  
79 74  
80   -
81   -//render cube
82 75 void
83   -renderScene()
84   -{
85   - glInitNames();
86   - glEnable(GL_TEXTURE_3D);
87   - glBindTexture(GL_TEXTURE_3D, texID);
88   - CHECK_OPENGL_ERROR
89   - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
90   - glMatrixMode(GL_MODELVIEW);
91   - glLoadIdentity();
92   - //glTranslatef(-0.5, -0.5, -pos);
93   -
94   - //cam.OrbitFocus(mousePos[0], mousePos[1]);
95   - p = cam.getPosition();
96   - up = cam.getUp();
97   - d = cam.getLookAt();
  76 +DrawCube()
  77 +{
  78 + glLineWidth(2.5);
  79 + glColor3f(1.0,0.0,0.0);
  80 + glBegin(GL_LINES);
98 81  
99   - gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], up[0], up[1], up[2]);
100   - //std::cout << "d:" << d << std::endl;
101   - //std::cout << "p:" << p << std::endl;
102   - //std::cout << "up:" <<up << std::endl;
103   - //gluLookAt(d[0], d[1], d[2], p[0], p[1], p[2], up[0], up[1], up[2]);
104   - //glRotatef(60.0, 1.0, 1.0, 1.0);
105   - //glRotatef((float)tick/100.0, 1.0, 1.0, 1.0);
106   - CHECK_OPENGL_ERROR
  82 + for (int i = 0; i < 24; i++)
  83 + {
  84 + glVertex3f(vertexDrw[lines[i]][0],
  85 + vertexDrw[lines[i]][1],
  86 + vertexDrw[lines[i]][2]);
  87 + }
  88 + glEnd();
  89 +}
  90 +
  91 +void
  92 +DrawPlanes()
  93 +{
107 94 glPushName(VERTICAL);
108 95 glBegin(GL_QUADS);
109 96 glTexCoord3f(
... ... @@ -148,7 +135,8 @@ renderScene()
148 135 );
149 136 glEnd();
150 137 glPopName();
151   - /*glBegin(GL_QUADS);
  138 + glPushName(HORIZONTAL);
  139 + glBegin(GL_QUADS);
152 140 glTexCoord3f(
153 141 vertexTex[3][0],
154 142 oriTex[1],
... ... @@ -189,27 +177,34 @@ renderScene()
189 177 oriDrw[1],
190 178 vertexDrw[6][2]
191 179 );
192   - glEnd();*/
  180 + glEnd();
  181 + glPopName();
  182 +}
  183 +
  184 +//render cube
  185 +void
  186 +renderScene()
  187 +{
  188 + glInitNames();
  189 + glEnable(GL_TEXTURE_3D);
  190 + glBindTexture(GL_TEXTURE_3D, texID);
193 191 CHECK_OPENGL_ERROR
  192 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  193 + glMatrixMode(GL_MODELVIEW);
  194 + glLoadIdentity();
  195 + p = cam.getPosition();
  196 + up = cam.getUp();
  197 + d = cam.getLookAt();
  198 + gluLookAt(p[0], p[1], p[2], d[0], d[1], d[2], up[0], up[1], up[2]);
  199 + DrawPlanes();
194 200 glDisable(GL_TEXTURE_3D);
195   - glLineWidth(2.5);
196   - glColor3f(1.0,0.0,0.0);
197   - glBegin(GL_LINES);
198   -
199   - for (int i = 0; i < 24; i++)
200   - {
201   - glVertex3f(vertexDrw[lines[i]][0],
202   - vertexDrw[lines[i]][1],
203   - vertexDrw[lines[i]][2]);
204   - }
205   - glEnd();
  201 + DrawCube();
206 202 glutSwapBuffers();
207   -
208   - //glutPostRedisplay();
209 203 }
210 204  
211 205  
212   -void MouseButton(int button, int state, int x, int y)
  206 +void
  207 +MouseButton(int button, int state, int x, int y)
213 208 {
214 209 if (button == GLUT_LEFT_BUTTON)
215 210 {
... ... @@ -239,10 +234,7 @@ void MouseMotion(int x, int y)
239 234 mousePos[1] = ((float)y - prevmousePos[1])*0.0005;
240 235 prevmousePos[0] = (float)x;
241 236 prevmousePos[1] = (float)y;
242   - //std::cout << x << " " << y << std::endl;
243   - //std::cout << mousePos[0] << " " << mousePos[1] << std::endl;
244 237 cam.OrbitFocus(mousePos[0]*degtorad, mousePos[1]*degtorad);
245   - //glutPostRedisplay();
246 238 }
247 239 }
248 240  
... ... @@ -327,7 +319,7 @@ main(int argc, char **argv)
327 319 glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
328 320 glutInitWindowSize(size[0], size[1]);
329 321 glutCreateWindow("gl_texture");
330   - std::cout << " Initialization is complete in Glut" << std::endl;
  322 + //std::cout << " Initialization is complete in Glut" << std::endl;
331 323  
332 324 CHECK_OPENGL_ERROR
333 325 glutKeyboardFunc(processKeys);
... ... @@ -342,17 +334,15 @@ main(int argc, char **argv)
342 334 CHECK_OPENGL_ERROR
343 335 glutMotionFunc(MouseMotion);
344 336  
345   - glPixelStorei(GL_UNPACK_ALIGNMENT,1);
346   - glPixelStorei(GL_PACK_ALIGNMENT,1);
347   - std::cerr << " Keyboard and Reshape is complete in Glut" << std::endl;
  337 + //std::cerr << " Keyboard and Reshape is complete in Glut" << std::endl;
348 338  
349 339 stim::gl_texture<unsigned char> stack ("/home/pavel/Documents/Test_Data/");
350 340 stack.createTexture();
351 341 texID = stack.getTexture();
352   - std::cout << ("I have started an instance of the class") << std::endl;
  342 + //std::cout << ("I have started an instance of the class") << std::endl;
353 343  
354 344  
355   - glInit(6, 6);
  345 + glInit();
356 346 CHECK_OPENGL_ERROR
357 347 glutIdleFunc(idleFunction);
358 348 CHECK_OPENGL_ERROR
... ...
1   -Subproject commit 9650806e9d2d28b1752c89aefc6869acd5cd1dc9
  1 +Subproject commit 5f54af5bd29311434eee0930989babd057bfb7c5
... ...