Exemplo n.º 1
0
    def __init__(self):
        program = pxng.ShaderProgram('FractalShader')
        program.add_shader(resource('fractal.vert'), pxng.ShaderType.Vertex)
        program.add_shader(resource('fractal.frag'), pxng.ShaderType.Fragment)
        program.compile_and_link()

        program.add_uniform('projection_view', glm.mat4x4)
        program.add_uniform('model', glm.mat4x4)
        program.add_uniform('iterations', glm.ivec1)
        program.add_uniform('fractal_space', glm.dvec4)
        self._program = program

        self._vao = pxng.VertexArrayObject(GL_TRIANGLES)
        self._vao.attach_buffer(
            pxng.BufferObject(data_type=glm.vec3))  # vertex buffer
        self._vao.attach_buffer(
            pxng.BufferObject(data_type=glm.vec2))  # texture buffer

        self._vao.add_quad(
            glm.vec3(0, 0, 0),
            glm.vec3(0, 1, 0),
            glm.vec3(1, 1, 0),
            glm.vec3(1, 0, 0),
        )

        self._vao.set_texture(glm.vec2(0, 1), glm.vec2(0, 0), glm.vec2(1, 0),
                              glm.vec2(1, 1))
Exemplo n.º 2
0
    def __init__(self, width, height):
        program = pxng.ShaderProgram('GridShader')
        program.add_shader(pxng.resource('shaders/line.vert'),
                           pxng.ShaderType.Vertex)
        program.add_shader(pxng.resource('shaders/line.frag'),
                           pxng.ShaderType.Fragment)
        program.compile_and_link()

        program.add_uniform('projection_view', glm.mat4x4)
        program.add_uniform('model', glm.mat4x4)
        program.add_uniform('color', glm.vec4)
        program.add_uniform('resolution', glm.vec2)
        program.add_uniform('dash_size', glm.vec1)
        program.add_uniform('gap_size', glm.vec1)

        self._shader_program = program

        self._vao = pxng.VertexArrayObject(GL_LINES)
        self._vao.attach_buffer(
            pxng.BufferObject(data_type=glm.vec3))  # vertex buffer

        x = 1
        y = 1
        while x < width:
            self._vao.add_line(glm.vec3(x, 0, 0), glm.vec3(x, height, 0))
            x += 1

        while y < height:
            self._vao.add_line(glm.vec3(0, y, 0), glm.vec3(width, y, 0))
            y += 1
Exemplo n.º 3
0
    def __init__(self):
        program = pxng.ShaderProgram('QuadShader')
        program.add_shader(resource('shaders/quad.vert'),
                           pxng.ShaderType.Vertex)
        program.add_shader(resource('shaders/quad.frag'),
                           pxng.ShaderType.Fragment)
        program.compile_and_link()

        program.add_uniform('projection_view', glm.mat4x4)

        self._shader_program = program

        self._vao = pxng.VertexArrayObject(GL_TRIANGLES)
        self._vao.attach_buffer(
            pxng.BufferObject(data_type=glm.vec3))  # vertex buffer
        self._vao.attach_buffer(
            pxng.BufferObject(data_type=glm.vec4))  # color buffer

        self._started = False
Exemplo n.º 4
0
    def __init__(self):
        self._vao = glGenVertexArrays(1)
        self._points = pxng.BufferObject(data_type=glm.vec3,
                                         array_type=GL_ARRAY_BUFFER)
        self._chars = pxng.BufferObject(data_type=glm.uvec1,
                                        array_type=GL_ARRAY_BUFFER)

        program = pxng.ShaderProgram('FontShader')
        program.add_shader(pxng.resource('shaders/font.vert'),
                           pxng.ShaderType.Vertex)
        program.add_shader(pxng.resource('shaders/font.geom'),
                           pxng.ShaderType.Geometry)
        program.add_shader(pxng.resource('shaders/font.frag'),
                           pxng.ShaderType.Fragment)
        program.compile_and_link()

        program.add_uniform('projection_view', glm.mat4x4)
        program.add_uniform('model', glm.mat4x4)
        program.add_uniform('color', glm.vec4)
        program.add_uniform('size', glm.uvec1)
        program.add_uniform('sprite_texture', glm.ivec1)
        self._program = program
Exemplo n.º 5
0
 def __init__(self, primitive):
     self._primitive = primitive
     self._buffers: List[pxng.BufferObject] = []
     self._indices = pxng.BufferObject(data_type=self.index_data_type,
                                       array_type=gl.GL_ELEMENT_ARRAY_BUFFER)
     self._vao = gl.glGenVertexArrays(1)