Statistics
| Revision:

root / PyOpenGL-Demo / tom / cone.py @ 1

History | View | Annotate | Download (1.4 kB)

1
#!/usr/bin/python
2

    
3
# This is statement is required by the build system to query build info
4
if __name__ == '__build__':
5
        raise Exception
6

    
7

    
8
import string
9
__version__ = string.split('$Revision: 1.1.1.1 $')[1]
10
__date__ = string.join(string.split('$Date: 2007/02/15 19:25:38 $')[1:3], ' ')
11
__author__ = 'Tarn Weisner Burton <twburton@users.sourceforge.net>'
12

    
13
from OpenGL.GL import *
14
from OpenGL.GLUT import *
15
from OpenGL.Tk import *
16

    
17
def init():
18
        glutInit([])
19
        glMaterialfv(GL_FRONT, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
20
        glMaterialfv(GL_FRONT, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0])
21
        glMaterialfv(GL_FRONT, GL_SPECULAR, [1.0, 0.0, 1.0, 1.0])
22
        glMaterialfv(GL_FRONT, GL_SHININESS, 50.0)
23
        glLightfv(GL_LIGHT0, GL_AMBIENT, [0.0, 1.0, 0.0, 1.0])
24
        glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
25
        glLightfv(GL_LIGHT0, GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
26
        glLightfv(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0]);   
27
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
28
        glEnable(GL_LIGHTING)
29
        glEnable(GL_LIGHT0)
30
        glDepthFunc(GL_LESS)
31
        glEnable(GL_DEPTH_TEST)
32

    
33

    
34
def redraw(o):
35
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
36
        glPushMatrix()
37
        glTranslatef(0, -1, 0)
38
        glRotatef(250, 1, 0, 0)
39
        glutSolidCone(1, 2, 50, 10)
40
        glPopMatrix()
41

    
42
def main():
43
        o = Opengl(width = 200, height = 200, double = 1, depth = 1)
44
        o.redraw = redraw
45
        o.autospin_allowed = 1
46
        o.pack(side = TOP, expand = YES, fill = BOTH)
47
        init()
48
        o.mainloop()
49

    
50
main()