Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from OpenGL.GL import *
- from OpenGL.GLUT import *
- from OpenGL.GLU import *
- def draw_points(x, y):
- glPointSize(5) #pixel size. by default 1 thake
- glBegin(GL_POINTS)
- glVertex2f(x,y) #jekhane show korbe pixel
- glEnd()
- def draw_triangle(x1,y1,x2,y2,x3,y3):
- glPointSize(5)
- glBegin(GL_TRIANGLES)
- glVertex2f(x1,y1)
- glVertex2f(x2,y2)
- glVertex2f(x3,y3)
- glEnd()
- def draw_lines(x1,y1,x2,y2):
- glPointSize(5)
- glBegin(GL_LINES)
- glVertex2f(x1,y1)
- glVertex2f(x2,y2)
- glEnd()
- def iterate():
- glViewport(0, 0, 500, 500)
- glMatrixMode(GL_PROJECTION)
- glLoadIdentity()
- glOrtho(0.0, 15000, 0.0, 15000, 0.0, 1.0)
- glMatrixMode (GL_MODELVIEW)
- glLoadIdentity()
- def showScreen():
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
- glLoadIdentity()
- iterate()
- glColor3f(0.25, 0.3, 0.0) #konokichur color set (RGB)
- #call the draw methods here
- glColor3f(0.25,0.3,0.0)
- draw_triangle(5000,6000,13000,6000,9000,8000)
- glColor3f(0.25,0.3,0.0)
- draw_lines(5000,6000,5000,2000)
- draw_lines(13000,6000,13000,2000)
- draw_lines(5000,2000,13000,2000)
- #window---------
- draw_lines(6000,4000,7000,4000)
- draw_lines(6000,5000,7000,5000)
- draw_lines(6000,5000,6000,4000)
- draw_lines(7000,5000,7000,4000)
- draw_lines(6500,4000,6500,5000)
- draw_lines(6000,4500,7000,4500)
- #door ------
- draw_lines(11000,2000,11000,5000)
- draw_lines(12500,2000,12500,5000)
- draw_lines(11000,2000,12500,2000)
- draw_lines(11000,5000,12500,5000)
- draw_points(12000,4000)
- glutSwapBuffers()
- glutInit()
- glutInitDisplayMode(GLUT_RGBA)
- glutInitWindowSize(7000,7000) #window size
- glutInitWindowPosition(0, 0)
- wind = glutCreateWindow(b"OpenGL Coding Practice") #window name
- glutDisplayFunc(showScreen)
- glutMainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement