Download presentation
Presentation is loading. Please wait.
Published byGeorge Henderson Modified over 9 years ago
1
1 A first OpenGL program Brian Farrimond Robina Hetherington
2
2 Ex01 Build and run Ex01
3
3 Program structure Three function program
4
4 main
5
5 Always present Uses RGB colours (Red, Green, Blue)
6
6 main Sets up the scene window
7
7 Window exercises Double the size of the window height and width Make the window start at the top left corner of the screen Change the window title to “2D OpenGL”
8
8 main Set up the graphical characteristics of the new window
9
9 init Set the background colour: red green blue alpha (transparency) Min value: 0.0 Max value: 1.0 Exercise: Set the background colour to red
10
10 init Set projection to be orthographic
11
11 Projections Orthographic projection shows no perspective
12
12 Orthographic projection glOrtho(left, right, bottom, top, near, far)
13
13 main
14
14 main Name of the function that will draw the scene
15
15 display
16
16 display Clear the window using the background colour
17
17 display glColor3f(red, green, blue) Min value: 0.0 Max value: 1.0 Exercise: Make the rectangle yellow
18
18 display Draw the rectangle (polygon with four vertices)
19
19 glVertex(x, y, z)
20
20 glVertex(x, y, z)
21
21 glVertex(x, y, z)
22
22 glVertex(x, y, z)
23
23 glVertex(x, y, z)
24
24 glVertex(x, y, z) Vertices are in anticlockwise order
25
25 g lOrtho(left, right, bottom, top, near, far); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
26
26 g lOrtho(left, right, bottom, top, near, far); glOrtho(-0.5, 1.0, 0.0, 1.5, -1.0, 1.0);
27
27 The new projection
28
28 main How we manage animation and interaction
29
29 OpenGL drawing primitives
30
30 OpenGL drawing primitives
31
31 OpenGL drawing primitives
32
32 OpenGL drawing primitives
33
33 OpenGL drawing primitives
34
34 OpenGL drawing primitives
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.