Statistics
| Revision:

root / PyOpenGL-Demo / proesch / simple / simpleQuad.py @ 1

History | View | Annotate | Download (998 Bytes)

1
#!/usr/bin/python2.4
2
# Copyright (C) 2007  "Peter Roesch" <Peter.Roesch@fh-augsburg.de>
3
#
4
# This code is licensed under the PyOpenGL License.
5
# Details are given in the file license.txt included in this distribution.
6

    
7
import sys
8
try:
9
  from OpenGL.GLUT import *
10
  from OpenGL.GL import *
11
  from OpenGL.GLU import *
12
except:
13
  print ''' Error PyOpenGL not installed properly !!'''
14
  sys.exit(  )
15

    
16
def display(  ):
17
        """OpenGL display method."""
18
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
19
        glColor3f( 1, 1, 1 )
20
        glBegin( GL_QUADS )
21
        glVertex3f( -0.5, 0.5, 0 )
22
        glVertex3f( -0.5, -0.5, 0 )
23
        glVertex3f( 0.5, -0.5, 0 )
24
        glVertex3f( 0.5, 0.5, 0 )
25
        glEnd(  )
26
        glFlush (  )
27

    
28
def init(  ):
29
        """OpenGL/glut init method."""
30
        glClearColor ( 0, 0, 0, 0 )
31
        glShadeModel( GL_SMOOTH )
32

    
33
glutInit( sys.argv )
34
glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB )
35
glutInitWindowSize( 250, 250 )
36
glutInitWindowPosition( 100, 100 )
37
glutCreateWindow( sys.argv[0] )
38
init(  )
39
glutDisplayFunc( display )
40
glutMainLoop(  )