Drawing Points Using Pyglet and OpenGL
suggest changeimport pyglet
from pyglet.gl import *
win = pyglet.window.Window()
glClear(GL_COLOR_BUFFER_BIT)
@win.event
def on_draw():
glBegin(GL_POINTS)
glVertex2f(x, y) #x is desired distance from left side of window, y is desired distance from bottom of window
#make as many vertices as you want
glEnd
To connect the points, replace GL_POINTS with GL_LINE_LOOP.
x and y are not defined. glEnd is not called, and glClear runs once before the handler, not inside on_draw. The script never calls pyglet.app.run(), so the window does not stay open.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents