attempting to draw a GL rectangle, not working, but got rid of segfault somehow
This commit is contained in:
parent
bbc8bf611d
commit
177951c395
@ -5,6 +5,8 @@ import os
|
|||||||
from PySFML import sf
|
from PySFML import sf
|
||||||
from wfobj import WFObj
|
from wfobj import WFObj
|
||||||
import getopt
|
import getopt
|
||||||
|
from OpenGL.GL import *
|
||||||
|
from OpenGL.GLU import *
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
options, args = getopt.getopt(argv[1:], '')
|
options, args = getopt.getopt(argv[1:], '')
|
||||||
@ -16,6 +18,15 @@ def main(argv):
|
|||||||
|
|
||||||
window = sf.Window(sf.VideoMode(800, 600, 32),
|
window = sf.Window(sf.VideoMode(800, 600, 32),
|
||||||
'Python Wavefront Object Viewer')
|
'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():
|
while window.IsOpened():
|
||||||
event = sf.Event()
|
event = sf.Event()
|
||||||
@ -23,6 +34,28 @@ def main(argv):
|
|||||||
while window.GetEvent(event):
|
while window.GetEvent(event):
|
||||||
if event.Type == sf.Event.Closed:
|
if event.Type == sf.Event.Closed:
|
||||||
window.Close()
|
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()
|
window.Display()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user