Advertisement
BalerCoder

Untitled

Jun 24th, 2024
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | Source Code | 0 0
  1. from OpenGL.GL import *
  2. from OpenGL.GLUT import *
  3. from OpenGL.GLU import *
  4.  
  5.  
  6. def draw_points(x, y):
  7.     glPointSize(5) #pixel size. by default 1 thake
  8.     glBegin(GL_POINTS)
  9.     glVertex2f(x,y) #jekhane show korbe pixel
  10.     glEnd()
  11. def draw_triangle(x1,y1,x2,y2,x3,y3):
  12.     glPointSize(5)
  13.     glBegin(GL_TRIANGLES)
  14.     glVertex2f(x1,y1)
  15.     glVertex2f(x2,y2)
  16.     glVertex2f(x3,y3)
  17.     glEnd()
  18. def draw_lines(x1,y1,x2,y2):
  19.     glPointSize(5)
  20.     glBegin(GL_LINES)
  21.     glVertex2f(x1,y1)
  22.     glVertex2f(x2,y2)
  23.     glEnd()
  24.  
  25. def iterate():
  26.     glViewport(0, 0, 500, 500)
  27.     glMatrixMode(GL_PROJECTION)
  28.     glLoadIdentity()
  29.     glOrtho(0.0, 15000, 0.0, 15000, 0.0, 1.0)
  30.     glMatrixMode (GL_MODELVIEW)
  31.     glLoadIdentity()
  32.  
  33. def showScreen():
  34.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  35.     glLoadIdentity()
  36.     iterate()
  37.     glColor3f(0.25, 0.3, 0.0) #konokichur color set (RGB)
  38.     #call the draw methods here
  39.     glColor3f(0.25,0.3,0.0)
  40.     draw_triangle(5000,6000,13000,6000,9000,8000)
  41.     glColor3f(0.25,0.3,0.0)
  42.     draw_lines(5000,6000,5000,2000)
  43.     draw_lines(13000,6000,13000,2000)
  44.     draw_lines(5000,2000,13000,2000)
  45.     #window---------
  46.     draw_lines(6000,4000,7000,4000)
  47.     draw_lines(6000,5000,7000,5000)
  48.     draw_lines(6000,5000,6000,4000)
  49.     draw_lines(7000,5000,7000,4000)
  50.     draw_lines(6500,4000,6500,5000)
  51.     draw_lines(6000,4500,7000,4500)
  52.     #door ------
  53.     draw_lines(11000,2000,11000,5000)
  54.     draw_lines(12500,2000,12500,5000)
  55.     draw_lines(11000,2000,12500,2000)
  56.     draw_lines(11000,5000,12500,5000)
  57.     draw_points(12000,4000)
  58.     glutSwapBuffers()
  59.  
  60.  
  61.  
  62. glutInit()
  63. glutInitDisplayMode(GLUT_RGBA)
  64. glutInitWindowSize(7000,7000) #window size
  65. glutInitWindowPosition(0, 0)
  66. wind = glutCreateWindow(b"OpenGL Coding Practice") #window name
  67. glutDisplayFunc(showScreen)
  68.  
  69. glutMainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement