Python 2.5.2 installation by refering Ponta's blog. This blog is very helpfull for me to use OpenGL on Python first time.
http://ponta027.blog35.fc2.com/blog-date-200709.html
Environment:
Hardware: Sony VAIO notebook PC, VGN-SZ74B
CPU: Intel Core2 Duo T7300 2GHz
RAM: 3GB
OS: Windows Vista Home Premium
1. Download Python 2.5.2 Windows installer python-2.5.2.msi from http://www.python.jp/Zope/download/pythoncore
2. Double crick python-2.5.2.msi to start installation. You installed Python in C:\phyton25
3. Download glut, glut-3.7.6-bin.zip. Unzip and copy glut32.dll to both C:\WINDOWS\system and C:\WINDOWS\system32.
4. Doenload PyOpenGL, PyOpenGL-3.0.0b1.win32.exe. Double crick the file to install PyOpenGL.
5. Invoke MSDOS window in C:\phyton25. Make a sample program sample1.py by copying the following code. Then, type "python sample1.py" in MSDOS window. You can see a teapot diaplayed in a new window.
### sample1.py
###
import sys
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
init_flag = 0
def display():
global init_flag
if not init_flag:
glEnable( GL_LIGHTING )
glEnable( GL_LIGHT0 )
glEnable( GL_DEPTH_TEST )
init_flag = 1
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
glPushMatrix()
gluLookAt( 0,3,-10, 0,0,0, 0,1,0 )
glutSolidTeapot( 2 )
glPopMatrix()
glFlush()
def reshape(w,h):
glViewport( 0, 0, w, h )
glMatrixMode( GL_PROJECTION )
glLoadIdentity()
gluPerspective( 45.0, 1.0*w/h, 0.1, 100.0 )
glMatrixMode( GL_MODELVIEW )
glLoadIdentity()
def keyboard(key,x,y):
if key==chr(27): sys.exit(0)
glutInit( sys.argv )
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH )
glutInitWindowSize( 256, 256 )
glutCreateWindow( 'teapot' )
glutReshapeFunc( reshape )
glutKeyboardFunc( keyboard )
glutDisplayFunc( display )
glutMainLoop()
0 件のコメント:
コメントを投稿