Jump to content

OpenGL/Utah teapot: Difference between revisions

added Phix
m (→‎{{header|C}}: Remove vanity tags)
(added Phix)
Line 243:
(for-each render Spout:))
</lang>
 
=={{header|Phix}}==
{{trans|C}}
<lang Phix>include GL/gl.e
include GL/freeglut.e
atom rot = 0;
atom matCol = allocate(16)
poke(matCol,
atom_to_float32(1) &
atom_to_float32(0) &
atom_to_float32(0) &
atom_to_float32(0)
)
function display()
glClear(or_bits(GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT))
glPushMatrix()
glRotatef(30,1,1,0)
glRotatef(rot,0,1,1)
glMaterialfv(GL_FRONT,GL_DIFFUSE,matCol)
glutWireTeapot(0.5)
glPopMatrix()
glFlush()
return 0
end function
function onIdle()
rot += 0.01
glutPostRedisplay()
return 0
end function
procedure init()
atom white = allocate(16)
poke(white,
atom_to_float32(1) &
atom_to_float32(1) &
atom_to_float32(1) &
atom_to_float32(0)
)
atom shini = allocate(4)
poke(shini,
atom_to_float32(70)
)
glClearColor(.5,.5,.5,0)
glShadeModel(GL_SMOOTH)
glLightfv(GL_LIGHT0,GL_AMBIENT,white)
glLightfv(GL_LIGHT0,GL_DIFFUSE,white)
glMaterialfv(GL_FRONT,GL_SHININESS,shini)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glEnable(GL_DEPTH_TEST)
end procedure
procedure main()
glutInit()
glutInitDisplayMode(or_all({GLUT_SINGLE,GLUT_RGB,GLUT_DEPTH}))
glutInitWindowSize(900,700)
{} = glutCreateWindow("The Amazing, Rotating Utah Teapot brought to you in OpenGL via freeglut.")
init()
glutDisplayFunc(call_back(routine_id("display")))
glutIdleFunc(call_back(routine_id("onIdle")))
glutMainLoop()
end procedure
 
main()</lang>
To run this, you will need the freeglut package from [http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.Freeglut-TheFreeOpenglUtilityToolkit PCAN]
7,806

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.