2 // See original source
and C based tutorial at
:
3 // http
://nehe
.gamedev
.net
/data
/lessons
/lesson
.asp?lesson
=03
5 // Ported to Io by Steve Dekorte
2003
6 // 2004-08-01 Updated by Doc O
'Leary
9 Demo appendProto(OpenGL)
11 Demo reshape := method(w, h,
12 glViewport(0, 0, w, h)
13 glMatrixMode(GL_PROJECTION)
15 gluPerspective(45.0, w / h, 0.1, 100.0)
16 glMatrixMode(GL_MODELVIEW)
20 Demo InitGL := method(
21 glShadeModel(GL_SMOOTH)
22 glClearColor(0, 0, 0, 0)
24 glEnable(GL_DEPTH_TEST)
25 glDepthFunc(GL_LEQUAL)
27 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
30 // Ooooo, pretty colors!
31 Demo display := method(
32 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
35 // Move Left 1.5 units and into the screen 6.0 units.
36 glTranslated(-1.5, 0.0, -6.0)
39 glBegin(GL_TRIANGLES) // Start drawing a triangle
40 glColor3d(1, 0, 0) // Set the color to red
41 glVertex3d(0, 1, 0) // Top
42 glColor3d(0, 1, 0) // Set the color to green
43 glVertex3d(1, -1, 0) // Bottom Right
44 glColor3d(0, 0, 1) // Set the color to blue
45 glVertex3d(-1, -1, 0) // Bottom Left
46 glEnd // We are done with the triangle
48 glTranslated(3.0, 0.0, 0.0)
50 // Draw a square (quadrilateral)
51 glColor3d(0.5, 0.5, 1) // Set The Color To Blue One Time Only
52 glBegin(GL_QUADS) // Start drawing a 4 sided polygon
53 glVertex3d(-1.0, 1.0, 0.0) // Top Left
54 glVertex3d(1.0, 1.0, 0.0) // Top Right
55 glVertex3d(1.0, -1.0, 0.0) // Bottom Right
56 glVertex3d(-1.0, -1.0, 0.0) // Bottom Left
64 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
65 glutInitWindowSize(640, 480)
66 glutCreateWindow("Jeff Molofee's
GL Code Tutorial
... NeHe
'99")