Hello, Here is an example of rotating a line using OpenGL calls. Hopefully it will work for you, and give you some keywords to look up.
On Sat, Aug 2, 2014 at 7:35 PM, BigD <denisg...@gmail.com> wrote: > Hey ew, > > As far as I know, if you want to draw a true line (ie. not a > sprite.Sprite object) you will have to implement your own math routines to > do the necessary transformations. You could use the euclid.py math module > to make it easier (it was written by the same guys who wrote pyglet, google > it). You could create a line primitive that has a .rotate and .translate > method. Look at the sprite.Sprite class for how groups and batches work > together and how an object position can be set/ rotated (._update_position) > for a 2d sprite and extrapolate it needed. > > Denis > > -- > You received this message because you are subscribed to the Google Groups > "pyglet-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pyglet-users+unsubscr...@googlegroups.com. > To post to this group, send email to pyglet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/pyglet-users. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscr...@googlegroups.com. To post to this group, send email to pyglet-users@googlegroups.com. Visit this group at http://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
import time import pyglet from pyglet import gl window = pyglet.window.Window() # To update the screen, there needs to be something scheduled on the Clock. def update(dt): pass pyglet.clock.schedule_interval(update, 0.03) @window.event def on_draw(): # Clear the screen gl.glClear(gl.GL_COLOR_BUFFER_BIT) # Load the identity matrix (the "no-op" transformation) gl.glLoadIdentity() # Move the view so that the center of the screen becomes the # origin point (0, 0) gl.glTranslatef(window.width//2, window.height//2, 0) # Rotate the view around the origin # the first argument is the angle, # the other three are the axis to rotate around (Z in our case) gl.glRotatef((time.time() * 10) % 360, 0, 0, 1) # Move the view back (0, 0) gl.glTranslatef(-window.width//2, -window.height//2, 0) # Draw a diagonal line gl.glBegin(gl.GL_LINES) gl.glVertex2f(0, 0) gl.glVertex2f(window.width, window.height) gl.glEnd(gl.GL_LINES) pyglet.app.run()