def __init__( self ): super( LegacyColourCube, self ).__init__() global vertices self.use_shaders = True # create our shader self.shader = ShaderProgram( VertexShader( self.vertex_shader ), FragmentShader( self.fragment_shader ) ) # create our vertex buffer self.buffer = VertexBuffer( GL.GL_ARRAY_BUFFER, GL.GL_STATIC_DRAW, data = vertices, ) self.buffer_attributes = BufferAttributes() self.buffer_attributes[ 'position' ] = VertexAttribute.from_dtype( self.buffer, vertices.dtype, 'position' )
def __init__( self ): super( LegacyQuad, self ).__init__() global vertices self.use_shaders = True GL.glEnable(GL.GL_TEXTURE_2D) # create our shader self.shader = ShaderProgram( VertexShader( self.vertex_shader ), FragmentShader( self.fragment_shader ) ) # create our vertex buffer self.buffer = VertexBuffer( GL.GL_ARRAY_BUFFER, GL.GL_STATIC_DRAW, data = vertices, ) self.buffer_attributes = BufferAttributes() self.buffer_attributes[ 'position' ] = VertexAttribute.from_dtype( self.buffer, vertices.dtype, 'position' ) self.buffer_attributes[ 'uv' ] = TextureCoordAttribute.from_dtype( self.buffer, vertices.dtype, 'texture_coord' )
def __init__( self ): super( CoreQuad, self ).__init__() global vertices # create our shader self.shader = ShaderProgram( VertexShader( self.vertex_shader ), FragmentShader( self.fragment_shader ) ) # create a vertex buffer # we pass in a list of regions we want to define # we only have 1 region here # for each region, we pass in how many rows, and the dtype self.buffer = VertexBuffer( GL.GL_ARRAY_BUFFER, GL.GL_STATIC_DRAW, data = vertices, ) # pass the shader and region to our VAO # and bind each of the attributes to a VAO index # the shader name is the variable name used in the shader # the buffer name is the name of the property in our vertex dtype self.buffer_attributes = BufferAttributes() self.buffer_attributes[ 'position' ] = GenericAttribute.from_dtype( self.buffer, vertices.dtype, 'position', location = self.shader.attributes[ 'in_position' ] ) self.buffer_attributes[ 'uv' ] = GenericAttribute.from_dtype( self.buffer, vertices.dtype, 'texture_coord', location = self.shader.attributes[ 'in_uv' ] ) # create our vertex array self.vao = VertexArray() self.vao.bind() self.buffer.bind() self.buffer_attributes.set() self.buffer.unbind() self.vao.unbind()