Primitives and Transformations in CG using Pyglet

This is a program to demonstrate the use of Python OpenGL library Pyglet for performing 2D and 3D Transformations on polygons in euclidean space.


#Study of GeometricTransformations using Pyglet

import pyglet
import numpy as np

# import all of opengl functions
from pyglet.gl import *

win = pyglet.window.Window(width=800, height=600)

#function to draw polygon shape
def polygon(vertices):
    glBegin(GL_POLYGON)

    for v in vertices:
        glVertex2f(v[0],v[1])
    glEnd()


#transformation function
def transform(tmat,vertices):


@win.event
def on_draw():
    vertex_arr=np.array([[100.0,100.0],[200.0,100.0],[200.0,500.0],[100.0,500.0]]) #array of vertices
    polygon(vertex_arr)

    vertex_arr=vertex_arr+120.0
    polygon(vertex_arr)

pyglet.app.run()



Leave a Reply

Your email address will not be published. Required fields are marked *