SHARE
TWEET

Untitled

a guest Jun 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pyglet
  2. from pyglet.gl import *
  3. import pyshaders as ps
  4.  
  5. t = pyglet.window.Window()
  6.  
  7. v = """
  8. #version 330 core
  9. layout (location = 0) in vec3 aPos;
  10.  
  11. out vec4 vertexColor;
  12.  
  13. void main()
  14. {
  15.     gl_Position = vec4(aPos, 1.0);
  16.     vertexColor = vec4(0.5, 0.0, 0.0, 1.0);
  17. }
  18. """
  19.  
  20. f = """
  21. #version 330 core
  22. out vec4 FragColor;
  23.  
  24. in vec4 vertexColor;
  25.  
  26. void main()
  27. {
  28.     FragColor = vertexColor;
  29. }
  30. """
  31.  
  32. shader = ps.from_string(v,f)
  33.  
  34. @t.event
  35. def on_draw():
  36.     glClearColor(1,0,0,1)
  37.     glClear(GL_COLOR_BUFFER_BIT)
  38.     shader.use()
  39.     glBegin(GL_POLYGON)
  40.     glColor3f(1,1,1)
  41.     glVertex2f(10,10)
  42.     glVertex2f(10,50)
  43.     glVertex2f(60,70)
  44.     glEnd()
  45.  
  46. def SRO(dt):
  47.     on_draw()
  48.  
  49. pyglet.clock.schedule_interval(SRO, 1/60)
  50.  
  51. pyglet.app.run()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top