Commit b97049a6a013c2b06c071319c9c76236022a08bf
1 parent
b745544e
add moving light sources
Showing
1 changed file
with
7 additions
and
17 deletions
Show diff stats
main.cu
... | ... | @@ -132,16 +132,14 @@ void glut_render(void) { |
132 | 132 | |
133 | 133 | // light |
134 | 134 | stim::vec3<float> eye = cam.getPosition(); //get the camera position (eye point) |
135 | - if (l1[0] + l1[1] + l1[2] + l2[0] + l2[1] + l2[2] == 0) { | |
136 | - stim::vec3<float> s = bb.size(); | |
135 | + stim::vec3<float> s = bb.size(); | |
137 | 136 | |
138 | - l1[0] = eye[0] + s[0] / 2; | |
139 | - l1[1] = eye[1] + s[1] / 2; | |
140 | - l1[2] = eye[2] + s[2] / 2; | |
141 | - l2[0] = eye[0] - s[0] / 2; | |
142 | - l2[1] = eye[1] - s[1] / 2; | |
143 | - l2[2] = eye[2] - s[2] / 2; | |
144 | - } | |
137 | + l1[0] = eye[0] + s[0] / 2; | |
138 | + l1[1] = eye[1] + s[1] / 2; | |
139 | + l1[2] = eye[2] + s[2] / 2; | |
140 | + l2[0] = eye[0] - s[0] / 2; | |
141 | + l2[1] = eye[1] - s[1] / 2; | |
142 | + l2[2] = eye[2] - s[2] / 2; | |
145 | 143 | |
146 | 144 | GLfloat global_ambient[] = { 0.3, 0.3, 0.3, 1.0 }; |
147 | 145 | GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; |
... | ... | @@ -150,7 +148,6 @@ void glut_render(void) { |
150 | 148 | GLfloat specular[] = { 0.6, 0.6, 0.6, 1.0 }; |
151 | 149 | GLfloat position1[] = { l1[0], l1[1], 50, 0.0 }; // upper right light source |
152 | 150 | GLfloat position2[] = { l2[0], l2[1], 0, 0.0 }; // lower left light source |
153 | - GLfloat position[] = { eye[0], eye[1], 50, 1.0 }; | |
154 | 151 | |
155 | 152 | glClearColor(0.0, 0.0, 0.0, 1.0); |
156 | 153 | glShadeModel(GL_SMOOTH); |
... | ... | @@ -166,11 +163,6 @@ void glut_render(void) { |
166 | 163 | glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse2); |
167 | 164 | glLightfv(GL_LIGHT1, GL_SPECULAR, specular); |
168 | 165 | glLightfv(GL_LIGHT1, GL_POSITION, position2); |
169 | - | |
170 | - glLightfv(GL_LIGHT2, GL_AMBIENT, ambient); | |
171 | - glLightfv(GL_LIGHT2, GL_DIFFUSE, diffuse1); | |
172 | - glLightfv(GL_LIGHT2, GL_SPECULAR, specular); | |
173 | - glLightfv(GL_LIGHT2, GL_POSITION, position); | |
174 | 166 | |
175 | 167 | glEnable(GL_COLOR_MATERIAL); |
176 | 168 | |
... | ... | @@ -460,14 +452,12 @@ void glut_keyboard(unsigned char key, int x, int y){ |
460 | 452 | glEnable(GL_LIGHTING); |
461 | 453 | glEnable(GL_LIGHT0); |
462 | 454 | glEnable(GL_LIGHT1); |
463 | - glEnable(GL_LIGHT2); | |
464 | 455 | } |
465 | 456 | else if (light_fac && !adjoint_fac) { |
466 | 457 | light_fac = 0; |
467 | 458 | glDisable(GL_LIGHTING); |
468 | 459 | glDisable(GL_LIGHT0); |
469 | 460 | glDisable(GL_LIGHT1); |
470 | - glDisable(GL_LIGHT2); | |
471 | 461 | } |
472 | 462 | break; |
473 | 463 | ... | ... |