Ejemplo n.º 1
0
    0.0,
    1.0,
    0.0,
    0.5,
    -0.5,
    -0.86,
    0.0,
    0.0,
    1.0,
    0.5,
]

vbo = GL.NewVertexBuffer(struct.pack('18f', *verts))
vao = GL.NewVertexArray(prog, vbo, '2f4f', ['vert', 'vert_color'])

GL.SetUniform(prog['scale'], height / width * 0.75, 0.75)

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    GL.Clear(240, 240, 240)
    GL.EnableOnly(GL.ENABLE_BLEND + GL.ENABLE_MULTISAMPLE)
    GL.SetUniform(prog['rotation'], time.time() - start)
    GL.RenderTriangles(vao, 3, instances=10)

    pygame.display.flip()
    pygame.time.wait(10)
Ejemplo n.º 2
0
 def paintGL(self):
     GL.Clear(240, 240, 240)
     GL.EnableOnly(GL.ENABLE_BLEND + GL.ENABLE_MULTISAMPLE)
     GL.SetUniform(context['rotation'], time.time() - context['start'])
     GL.RenderTriangles(context['vao'], 3, instances=10)
     self.update()
Ejemplo n.º 3
0
def display():
    GL.Clear(240, 240, 240)
    GL.EnableOnly(GL.ENABLE_BLEND + GL.ENABLE_MULTISAMPLE)
    GL.SetUniform(prog['rotation'], time.time() - start)
    GL.RenderTriangles(vao, 3, instances=10)
    glutSwapBuffers()
Ejemplo n.º 4
0
nodes = [GL.NewFramebuffer(256, 256) for i in range(6)]

enables = [
	GL.ENABLE_BLEND,
	GL.ENABLE_CULL_FACE,
	GL.ENABLE_DEPTH_TEST,
	GL.ENABLE_BLEND + GL.ENABLE_DEPTH_TEST,
	GL.ENABLE_CULL_FACE + GL.ENABLE_BLEND,
	GL.ENABLE_BLEND + GL.ENABLE_DEPTH_TEST + GL.ENABLE_CULL_FACE,
]

GL.Viewport(0, 0, 256, 256)
for i, (fbo, color, depth) in enumerate(nodes):
	GL.UseFramebuffer(fbo)
	GL.Clear(*bg[i])
	GL.EnableOnly(enables[i])
	GL.RenderTriangles(vao, 18)

for i, (fbo, color, depth) in enumerate(nodes):
	GL.UpdateTexture(color, i * 8 + 8, 8, 8, 8, b'\x00' * 256)
	GL.UpdateTexture(color, i * 8 + 8, 24, 8, 8, b'\xff' * 256)

for i, (fbo, color, depth) in enumerate(nodes):
	GL.UseFramebuffer(fbo)
	Image.frombytes('RGB', (256, 256), GL.ReadPixels(0, 0, 256, 256, 3)).save('TestResults/c_%d.png' % i)
	pixels = b''.join(struct.pack('B', int(c * 255)) for c in struct.unpack('65536f', GL.ReadDepthPixels(0, 0, 256, 256)))
	Image.frombytes('L', (256, 256), pixels).save('TestResults/d_%d.png' % i)

exit()

GL.DisableBlend()
Ejemplo n.º 5
0
def on_draw():
    GL.Clear(240, 240, 240)
    GL.EnableOnly(GL.ENABLE_BLEND + GL.ENABLE_MULTISAMPLE)
    GL.SetUniform(prog['rotation'], elapsed)
    GL.RenderTriangles(vao, 3, instances=10)