Example #1
0
 def paintGL(self):
     context['mx'] += context['dmx']
     context['my'] += context['dmy']
     context['s'] += context['ds']
     GL.Clear(240, 240, 240)
     GL.SetUniform(context['center'], context['mx'], context['my'])
     GL.SetUniform(context['scale'], 0.5**context['s'])
     GL.RenderTriangleStrip(context['vao'], 4)
     self.update()
Example #2
0
    def paintGL(self):
        z = 0.5**context['s']
        context['mx'] += context['dmx'] * z
        context['my'] += context['dmy'] * z
        context['s'] += context['ds']
        GL.Clear(240, 240, 240)

        GL.SetUniform(context['pos'], context['mx'] / z, context['my'] / z)
        GL.SetUniform(context['zoom'], z)
        GL.RenderTriangleStrip(context['vao'], 4)
        self.update()
Example #3
0
	def paintGL(self):
		GL.Clear(240, 240, 240)
		GL.RenderTriangleStrip(context['vao'], 4)
Example #4
0
def display():
    GL.Clear(240, 240, 240)
    GL.RenderTriangles(vao, 3)
    glutSwapBuffers()
Example #5
0
vao = GL.NewVertexArray(grass_prog, vbo, '3f3f3f1f1f',
                        ['vert', 'direction', 'color', 'thickness', 'power'],
                        ibo)

ssao_vbo = GL.NewVertexBuffer(
    struct.pack('8f', 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0))
ssao_vao = GL.NewVertexArray(ssao_prog, ssao_vbo, '2f', ['vert'])

ubo = GL.NewUniformBuffer(b''.join(struct.pack('2f', x, y) for x, y in kernel))

fbo, color, depth = GL.NewFramebuffer()

GL.SetUniform(grass_prog['mat'], struct.pack('16f', *camera))
GL.SetUniform(ssao_prog['texture'], 0)
GL.SetUniform(ssao_prog['depth'], 1)

GL.UseUniformBuffer(ubo, ssao_prog['Kernel'])

while WND.Update():
    GL.UseFramebuffer(fbo)
    GL.EnableDepthTest()
    GL.Clear(0, 0, 0)

    GL.RenderTriangleStrip(vao, 1000 * 8)

    GL.UseFramebuffer(GL.SCREEN)
    GL.DisableDepthTest()
    GL.UseTexture(color, 0)
    GL.UseTexture(depth, 1)
    GL.RenderTriangleStrip(ssao_vao, 4)
def on_draw():
	GL.Clear(240, 240, 240)
	GL.SetUniform(prog['rotation'], elapsed)
	GL.RenderTriangles(vao, 3)
Example #7
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()
Example #8
0
	def paintGL(self):
		GL.Clear(240, 240, 240)
		if 'vao' in context:
			GL.RenderTriangles(context['vao'], 3)
 def paintGL(self):
     GL.Clear(240, 240, 240)
     GL.SetUniform(context['rotation'], time.time() - context['start'])
     GL.RenderTriangles(context['vao'], 3)
     self.update()
Example #10
0
def on_draw():
    GL.Clear(240, 240, 240)
    GL.RenderTriangles(vao, 3)
Example #11
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()
Example #12
0
def on_draw():
    GL.Clear(240, 240, 240)
    GL.SetUniform(prog['rotation'], time.time() - start)
    GL.RenderTriangles(vao, 3)
Example #13
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()
Example #14
0
 def draw(self, *args):
     GL.Clear(240, 240, 240)
     GL.RenderTriangles(self.vao, 3)
Example #15
0
def display():
	GL.Clear(240, 240, 240)
	GL.SetUniform(prog['rotation'], time.time() - start)
	GL.RenderTriangles(vao, 3)
	glutSwapBuffers()
Example #16
0
triangle = [
	0.0, 0.8,     # A
	-0.6, -0.8,   # B
	0.6, -0.8     # C
]

# We have to pack the floats
packed_triangle = struct.pack('6f', *triangle)

# Now lets create a vertex buffer "containing" our triangle
vbo = GL.NewVertexBuffer(packed_triangle)

# Now we will create a VertexArray and specify what vertex attributes will be used during the rendering
# The first parameter is a program object used for rendering
# The second parameter is a VertexBuffer holding information about the triangle
# The third parameter is the format of a single vertex
#     Now we only define the position as 2 float x and y coordinate
#     Later we can define color normals or any other data used in the vertex shader.

# The fourth parameter must be a list containing a vertex attribute name in the vertex shader
vao = GL.NewVertexArray(prog, vbo, '2f', ['vert'])

while WND.Update():
	GL.Clear(240, 240, 240)

	# Render a triangle using 3 vertices (remember we have 6 floats 3 * 2f)
	# RenderTriangles will use the program assigned to vao
	# By default the specified attribues are enabled (for now we have a single "vert" attribute)
	GL.RenderTriangles(vao, 3)
Example #17
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)