Skip to content

Instantly share code, notes, and snippets.

@ashwin
Created June 18, 2013 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwin/5803417 to your computer and use it in GitHub Desktop.
Save ashwin/5803417 to your computer and use it in GitHub Desktop.
IronPython example program to demonstrate Tao Framework
# IronPython example program to demonstrate Tao Framework
#
# Steps:
# 1. Install Tao Framework.
# 2. Create an empty IronPython project in Visual Studio
# 3. Place Tao.OpenGl.dll and Tao.FreeGlut.dll in directory of Python source file.
# These DLL files are found in C:\Program Files (x86)\TaoFramework\bin
# 4. Place freeglut.dll in directory of Python source file.
# This DLL file is found in C:\Program Files (x86)\TaoFramework\lib
# 5. Paste this source code into the Python source file
# 6. Run. You should see a grey teapot.
#
# Copyright (c) 2013 Ashwin Nanjappa
# Released under the MIT License
import clr
clr.AddReferenceToFile("Tao.OpenGl.dll")
clr.AddReferenceToFile("Tao.FreeGlut.dll")
import Tao.OpenGl.Gl as Gl
import Tao.OpenGl.Glu as Glu
import Tao.FreeGlut.Glut as Glut
def init_graphics():
Gl.glEnable(Gl.GL_LIGHTING)
Gl.glEnable(Gl.GL_LIGHT0)
Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, (1, .5, 1))
Gl.glEnable(Gl.GL_DEPTH_TEST)
Gl.glClearColor(1, 1, 1, 1)
def on_display():
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT)
Gl.glLoadIdentity()
Glu.gluLookAt(0, 0, 5, 0, 0, 1, 0, 1, 0)
Glut.glutSolidTeapot(1)
Glut.glutSwapBuffers()
def on_reshape(w, h):
Gl.glMatrixMode(Gl.GL_PROJECTION)
Gl.glLoadIdentity()
Gl.glViewport(0, 0, w, h)
Glu.gluPerspective(40, float(w) / h, 1, 100)
Gl.glMatrixMode(Gl.GL_MODELVIEW)
def main():
Glut.glutInit()
Glut.glutInitWindowSize(500, 500)
Glut.glutCreateWindow("Tao Example")
init_graphics()
Glut.glutDisplayFunc(on_display)
Glut.glutReshapeFunc(on_reshape)
Glut.glutMainLoop()
if "__main__" == __name__:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment