Here's the code:
# Example 2-7 : Marking Polygon Boundary Edges
from pyglet.gl import *
from pyglet import window
# The OpenGL context is created only when you create a window. Any calls
# to OpenGL before a window is created will fail.
win = window.Window()
def display():
# vertices undefined in example
# adding a Z value of 1.0 (simply to remain in sync with the example,
# where glVertex3fv is called,
# i.e. 3 variables are required by the function
v0 = [0.0, 0.0, 1.0]
v1 = [100.0, 100.0, 1.0]
v2 = [150.0, 50.0, 1.0]
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
glBegin(GL_POLYGON)
glEdgeFlag(GL_TRUE)
glVertex3fv((GLfloat * len(v0))(*v0))
glEdgeFlag(GL_FALSE)
glVertex2fv((GLfloat * len(v1))(*v1))
glEdgeFlag(GL_TRUE)
glVertex2fv((GLfloat * len(v2))(*v2))
glEnd()
def init():
glClearColor (0.0, 0.0, 0.0, 0.0)
glShadeModel (GL_FLAT)
while not win.has_exit:
win.dispatch_events()
win.clear()
display()
win.flip()
One thing to note perhaps is that instead of passing the values directly, we have used a pointer to an array this time.
No comments:
Post a Comment