Beispiel #1
0
	(-400, -200, 100),
	(-250, -350, 100),
	(0, -300, 100),
	(250, -350, 100),
	(400, -200, 100),
]

circles_ubo = GL.NewUniformBuffer(struct.pack('i4x', len(circles)) + b''.join(struct.pack('2f1f4x', *c) for c in circles))
GL.UseUniformBuffer(circles_ubo, circles_prog['Circles'])

particles_prog = GL.NewProgram([particles_vert, particles_frag])

GL.SetUniform(particles_prog['scale'], 0.002 * height / width, 0.002)

particle_vbo = GL.NewVertexBuffer(b''.join(struct.pack('2f', cos(i * 2 * pi / 16), sin(i * 2 * pi / 16)) for i in range(16)))
particle_vao = GL.NewVertexArray(particles_prog, particle_vbo, '2f', ['vert'])

sbo = GL.NewStorageBuffer(b''.join(struct.pack('ffffff', -10000, 0, -10000, 0, 0, 0) for i in range(10240)))
GL.UseUniformBuffer(circles_ubo, circles_prog['Circles'])
GL.UseStorageBuffer(sbo)

k = 0
while WND.Update():
	k = (k + 32) % 10240
	GL.UpdateStorageBuffer(sbo, k * 24, b''.join(struct.pack('ffffff', -400, 200, -400 + uniform(3, 5), 200 + uniform(2, 5), 0, -0.1) for i in range(32)))
	GL.Clear(240, 240, 240)
	GL.RunComputeShader(physics, 40)
	GL.RenderTriangleFan(circle_vao, 128, instances = len(circles))
	GL.RenderTriangleFan(particle_vao, 16, instances = 10240)

Beispiel #2
0
GL.NewVertexBuffer()
GL.NewVertexShader()

GL.ReadPixel()
GL.ReadPixels()

GL.ReadDepthPixel()
GL.ReadDepthPixels()

GL.ReadStorageBuffer()

GL.RenderLineLoop()
GL.RenderLineStrip()
GL.RenderLines()
GL.RenderPoints()
GL.RenderTriangleFan()
GL.RenderTriangleStrip()
GL.RenderTriangles()

GL.RenderLinesAdjacency()
GL.RenderLineStripAdjacency()
GL.RenderTrianglesAdjacency()
GL.RenderTriangleStripAdjacency()

GL.SetTextureFiltered()
GL.SetTextureMipmapped()
GL.SetTexturePixelated()
GL.SetUniform()
GL.SetUniformMatrix()

# GL.UpdateIndexBuffer()