Changes between Version 18 and Version 19 of tutorial
- Timestamp:
- Jun 28, 2013, 10:02:05 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
tutorial
v18 v19 100 100 101 101 102 == Exercises #1:==102 === Exercises #1: === 103 103 1. Add RGB color to vertices with {{{ glColor3f(0.0, 0.4, 1.0);}}}. 104 104 2. Replace single line drawing in {{{display()}}} with the following snippet … … 251 251 }}} 252 252 [[Image(triangle.png,align=bottom,right,title=Triangles )]] 253 == Exercises #2==253 === Exercises #2 === 254 254 1. To be able to continue and not get lost introduce shader compiler logs in case of compilation errors by adding the following code into {{{setShaders()}}} right at after vertex shader compilation: 255 255 {{{ … … 479 479 } 480 480 }}} 481 481 === Exercises #3 === 482 1. Introduce zoom in/out functionality of the viewer by adding mouse wheel events to the end of `mouse()` 483 {{{ 484 #!c 485 if (button == 3 && state == GLUT_DOWN) 486 { zoom *= 1.1; glutPostRedisplay(); } 487 else if (button == 4 && state == GLUT_DOWN) 488 { zoom /= 1.1; glutPostRedisplay(); } 489 }}} 490 and introduction of global variable `float zoom = 1.0;` that is communicated to GPU by additional `uniform float Zoom;` in the `vertex_shader[]`. Last line is replaced by 491 {{{ 492 #!c 493 gl_Position = gl_ProjectionMatrix * RotationMatrix \ 494 * gl_ModelViewMatrix*vec4(Zoom*gl_Vertex.xyz, 1.0); \ 495 }}} 496 In the `display()` we add zooming by 497 {{{ 498 #!c 499 location = glGetUniformLocation(p, "Zoom"); 500 if (location >= 0) glUniform1f(location, zoom); 501 }}} 482 502 503 504 505