Exemplo n.º 1
0
 def draw(self, bind_display_shader, fbo, texture):
     GL.glDisable(GL.GL_DEPTH_TEST)
     GL.glDisable(GL.GL_CULL_FACE)
     bind_display_shader()
     GL.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbo[0])
     GL.glActiveTexture(GL.GL_TEXTURE0)
     texture.bind()
     GL.glBindVertexArray(self.vertex_array[0])
     GL.glDrawArrays(GL.GL_TRIANGLE_FAN, 0, 4)
     GL.glBindVertexArray(0)
     GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
Exemplo n.º 2
0
    def __init__(self, bind_display_shader, resolution):
        # Generate dummy float image buffer
        self.resolution = resolution
        width, height = resolution

        bind_display_shader()
        shader_program = GL.gl_buffer(GL.GL_INT, 1)
        GL.glGetIntegerv(GL.GL_CURRENT_PROGRAM, shader_program)

        self.vertex_array = GL.gl_buffer(GL.GL_INT, 1)
        GL.glGenVertexArrays(1, self.vertex_array)
        GL.glBindVertexArray(self.vertex_array[0])

        texturecoord_location = GL.glGetAttribLocation(shader_program[0],
                                                       "texCoord")
        position_location = GL.glGetAttribLocation(shader_program[0], "pos")

        GL.glEnableVertexAttribArray(texturecoord_location)
        GL.glEnableVertexAttribArray(position_location)

        position = [0.0, 0.0, width, 0.0, width, height, 0.0, height]
        position = GL.gl_buffer(GL.GL_FLOAT, len(position), position)
        texcoord = [0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0]
        texcoord = GL.gl_buffer(GL.GL_FLOAT, len(texcoord), texcoord)

        self.vertex_buffer = GL.gl_buffer(GL.GL_INT, 2)

        GL.glGenBuffers(2, self.vertex_buffer)
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.vertex_buffer[0])
        GL.glBufferData(GL.GL_ARRAY_BUFFER, 32, position, GL.GL_STATIC_DRAW)
        GL.glVertexAttribPointer(position_location, 2, GL.GL_FLOAT,
                                 GL.GL_FALSE, 0, None)

        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.vertex_buffer[1])
        GL.glBufferData(GL.GL_ARRAY_BUFFER, 32, texcoord, GL.GL_STATIC_DRAW)
        GL.glVertexAttribPointer(texturecoord_location, 2, GL.GL_FLOAT,
                                 GL.GL_FALSE, 0, None)

        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, 0)
        GL.glBindVertexArray(0)