Exemple #1
0
    def draw_one(u):
        c = PCVCache.cache[u]
        # update matrix, every frame for now, it should be done better.. but it works well..
        m = c['object'].matrix_world
        matrix = []
        for v in m.transposed():
            matrix.extend(list(v.to_tuple()))
        matrix_buffer = bgl.Buffer(bgl.GL_FLOAT, len(matrix), matrix)
        c['matrix'] = m
        c['matrix_buffer'] = matrix_buffer

        bgl.glPushMatrix()
        bgl.glMultMatrixf(c['matrix_buffer'])

        bgl.glEnable(bgl.GL_DEPTH_TEST)
        bgl.glEnableClientState(bgl.GL_VERTEX_ARRAY)
        bgl.glVertexPointer(3, bgl.GL_FLOAT, 0, c['vertex_buffer'])
        bgl.glEnableClientState(bgl.GL_COLOR_ARRAY)
        bgl.glColorPointer(3, bgl.GL_FLOAT, 0, c['color_buffer'])

        if (PCVCache.cache[u]['smooth']):
            bgl.glEnable(bgl.GL_POINT_SMOOTH)

        l = int((c['length'] / 100) * c['display_percent'])
        bgl.glDrawArrays(bgl.GL_POINTS, 0, l)

        bgl.glDisableClientState(bgl.GL_VERTEX_ARRAY)
        bgl.glDisableClientState(bgl.GL_COLOR_ARRAY)

        if (c['smooth']):
            bgl.glDisable(bgl.GL_POINT_SMOOTH)
        bgl.glDisable(bgl.GL_DEPTH_TEST)

        bgl.glPopMatrix()
 def draw_one(u):
     c = PCVCache.cache[u]
     # update matrix, every frame for now, it should be done better.. but it works well..
     m = c['object'].matrix_world
     matrix = []
     for v in m.transposed():
         matrix.extend(list(v.to_tuple()))
     matrix_buffer = bgl.Buffer(bgl.GL_FLOAT, len(matrix), matrix)
     c['matrix'] = m
     c['matrix_buffer'] = matrix_buffer
     
     bgl.glPushMatrix()
     bgl.glMultMatrixf(c['matrix_buffer'])
     
     bgl.glEnable(bgl.GL_DEPTH_TEST)
     bgl.glEnableClientState(bgl.GL_VERTEX_ARRAY)
     bgl.glVertexPointer(3, bgl.GL_FLOAT, 0, c['vertex_buffer'])
     bgl.glEnableClientState(bgl.GL_COLOR_ARRAY)
     bgl.glColorPointer(3, bgl.GL_FLOAT, 0, c['color_buffer'])
     
     if(PCVCache.cache[u]['smooth']):
         bgl.glEnable(bgl.GL_POINT_SMOOTH)
     
     l = int((c['length'] / 100) * c['display_percent'])
     bgl.glDrawArrays(bgl.GL_POINTS, 0, l)
     
     bgl.glDisableClientState(bgl.GL_VERTEX_ARRAY)
     bgl.glDisableClientState(bgl.GL_COLOR_ARRAY)
     
     if(c['smooth']):
         bgl.glDisable(bgl.GL_POINT_SMOOTH)
     bgl.glDisable(bgl.GL_DEPTH_TEST)
     
     bgl.glPopMatrix()
Exemple #3
0
def draw_vertex_array(key, mode, dimensions, color):
    if key in VAO and VAO[key] and program:
        vao = VAO[key]

        bgl.glUseProgram(program)
        bgl.glUniform4f(bgl.glGetUniformLocation(program, "color"), *color)

        bgl.glEnableClientState(bgl.GL_VERTEX_ARRAY)
        bgl.glVertexPointer(dimensions, bgl.GL_FLOAT, 0, vao)
        bgl.glDrawArrays(mode, 0, int(len(vao) / dimensions))

        bgl.glDisableClientState(bgl.GL_VERTEX_ARRAY)
        bgl.glUseProgram(0)
def draw_callback_view(verts, faces):

    VERT = 0
    FACES = 1

    buffers = bgl.Buffer(bgl.GL_INT, [2])
    bgl.glGenBuffers(2, buffers)

    bgl.glBindBuffer(bgl.GL_ARRAY_BUFFER, buffers[VERT])
    bgl.glBufferData(bgl.GL_ARRAY_BUFFER, 4 * 3 * len(verts), verts,
                     bgl.GL_STATIC_DRAW)
    bgl.glVertexPointer(3, bgl.GL_FLOAT, 0, verts)
    bgl.glColor3f(1.0, 0, 0)
    bgl.glEnableClientState(bgl.GL_VERTEX_ARRAY)
    bgl.glDrawArrays(bgl.GL_POINTS, 0, len(verts))
    bgl.glDisableClientState(bgl.GL_VERTEX_ARRAY)