File: __init__.py

package info (click to toggle)
pyopengl 2.0.1.08-5.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,484 kB
  • ctags: 9,036
  • sloc: pascal: 64,950; xml: 28,088; ansic: 20,696; python: 19,761; tcl: 668; makefile: 240; sh: 25
file content (59 lines) | stat: -rw-r--r-- 1,347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# This is statement is required by the build system to query build info
if __name__ == '__build__':
	raise Exception

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import os, os.path, string

def __get_items(basedir, submodule):
	items = {}
	rootdir = apply(os.path.join, [basedir] + submodule)
	for item in os.listdir(rootdir):
		path = os.path.join(rootdir, item)
		name, ext = os.path.splitext(item)
		if os.path.isdir(path):
			subitems = __get_items(basedir, submodule + [item])
			if len(subitems):
				items[item] = subitems
		elif os.path.isfile(path) and name != '__init__' and ext == '.py':
			try:
				items[name] = getattr(__import__(string.join(submodule + [name], '.'), globals(), locals(), ['item']), 'item')
			except:
				pass
	return items		


def get_items():
	return __get_items(os.path.dirname(__file__), [])


class item:

	def __init__(self):
		self.phi = 0
		self.theta = 0


	def __del__(self):
		pass		


	def on_idle(self):
		return 0


	def on_reshape(self, width, height):
		gluPerspective(45.0, float(width)/float(max(1, height)), 0.1, 100.0)
	

	def on_display(self):
		glRotatef(self.phi, 0.0, 1.0, 0.0)
		glRotatef(self.theta, 1.0, 0.0, 0.0)


	def on_motion(self, x, y):
		self.phi = x
		self.theta = y
		glutPostRedisplay()