コード例 #1
0
ファイル: test_context.py プロジェクト: kwohlfahrt/GLPy
	def testSampler(self):
		size = (4, 4)
		tex = ImmutableTexture(size, components=1, bits=8, normalized=True)
		data = numpy.zeros(size, dtype='uint8')
		data[1:2, 1:2] = 255;
		tex[:,:] = data
		
		shader_files = { 'vertex': 'texture.vert'
		               , 'fragment': 'texture.frag' }
		shaders = readShaders(**shader_files)

		vertex_attributes = [ Variable('position', 'vec4') ]
		vao = VAO(*vertex_attributes)

		uniform_attributes = [ Variable('tex', 'sampler2D') ]

		program = Program.fromSources(shaders, attributes=vao.attributes, uniforms=uniform_attributes)

		buf = VertexBuffer(Type('vec3'))
		data = numpy.array([[0, 0, 0], [0, 1, 0], [0, 0, 1]], dtype='int16')
		buf[...] = data
		vao[0].data = buf.blocks[0].tracks[0]

		tex.activate(1)
		program.uniforms['tex'].data = 1
コード例 #2
0
ファイル: test_uniform_block.py プロジェクト: kwohlfahrt/GLPy
 def setUp(self):
     super().setUp()
     shaders = {"vertex": "uniform_block.vert", "fragment": "compile.frag"}
     shaders = readShaders(**shaders)
     struct_foo = Struct("Foo", Variable("f", "float"), Variable("v4", "vec4"))
     # This has an incorrect definition to simulate members being optimized out
     struct_foo_optimized = Struct(
         "Foo", Variable("f", "float"), Variable("v4", "vec4"), Variable("optimized_out", "float")
     )
     uniform_blocks = [
         UniformBlock("AnonymousUB", Variable("m4", "mat4"), Variable("b", "bool"), binding=2, layout="std140"),
         UniformBlock(
             "InstancedUB",
             Variable("f", "float"),
             Variable("v4", "vec4"),
             Variable("foo", struct_foo),
             instance_name="ubinstance",
         ),
         # This has an incorrect definition to simulate members being optimized out
         UniformBlock(
             "OptimizedUB",
             Variable("ui", "uint"),
             Variable("i", "int"),
             Variable("optimized_out", "float"),
             Variable("foo", Array(struct_foo_optimized, 2)),
             instance_name="uboptimized",
         ),
     ]
     self.program = Program.fromSources(shaders, uniform_blocks=uniform_blocks)
コード例 #3
0
ファイル: test_context.py プロジェクト: kwohlfahrt/GLPy
	def setUp(self):
		super().setUp()

		shader_files = { 'vertex': 'compile.vert'
		               , 'fragment': 'compile.frag'}
		shaders = readShaders(**shader_files)
		self.program = Program.fromSources(shaders)
コード例 #4
0
ファイル: test_vertex.py プロジェクト: kwohlfahrt/GLPy
    def setUp(self):
        super().setUp()

        shader_files = {"vertex": "vertices.vert", "fragment": "vertices.frag"}
        shaders = readShaders(**shader_files)

        vertex_attribs = [
            VertexAttribute("position", "vec4"),
            VertexAttribute("color", "vec3"),
            VertexAttribute("baz", "vec2"),
            VertexAttribute("foo", "mat2x4"),
            VertexAttribute("bar", Array("mat3", 2)),
        ]
        self.program = Program.fromSources(shaders, vertex_attributes=vertex_attribs)
        self.vao = VAO(*self.program.vertex_attributes.values())