#!/usr/bin/env python import sys import os from PySFML import sf from wfobj import WFObj import getopt from OpenGL.GL import * from OpenGL.GLU import * def main(argv): options, args = getopt.getopt(argv[1:], '') if len(args) == 0: sys.stderr.write('Specify object file to load\n') return 2 obj = WFObj(args[0]) window = sf.Window(sf.VideoMode(800, 600, 32), 'Python Wavefront Object Viewer') window.UseVerticalSync(True) window.SetActive(True) glClearDepth(1) glClearColor(0, 0, 0, 0) glEnable(GL_LIGHTING) glEnable(GL_LIGHT0) glEnable(GL_COLOR_MATERIAL) glColor3f(1, 0.6, 0) while window.IsOpened(): event = sf.Event() while window.GetEvent(event): if event.Type == sf.Event.Closed: window.Close() elif event.Type == sf.Event.Resized: glViewport(0, 0, event.Size.Width, event.Size.Height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60.0, float(event.Size.Width) / float(event.Size.Height), 1.0, 1000.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glTranslatef(0, 0, -200) glBegin(GL_QUADS) glNormal3f(0, 0, 1) glVertex3f(50, 50, 0) glVertex3f(-50, 50, 0) glVertex3f(-50, -50, 0) glVertex3f(50, -50, 0) glEnd() window.Display() return 0 sys.exit(main(sys.argv))