Ejemplo n.º 1
0
def on_draw(dt):
    window.clear()
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glEnable(gl.GL_PROGRAM_POINT_SIZE)
    gl.glLineWidth(30.0)
    pc_program.draw(mode=gl.GL_POINTS)
    line_program.draw(mode=gl.GL_LINES)
def on_draw(_):
    window.clear()
    gl.glLineWidth(2)
    gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    program.draw(gl.GL_TRIANGLES,
                 indices.reshape(-1).astype(np.uint32).view(gloo.IndexBuffer))
Ejemplo n.º 3
0
    def on_draw(dt):
        global phi, theta

        # Phi and Theta are the cube rotation paramters
        window.clear()

        lock.acquire()
        try:
            # Disable depth of OpenGL to update background tecture
            gl.glDisable(gl.GL_DEPTH_TEST)

            quad.draw(gl.GL_TRIANGLE_STRIP)

            # R-enable depth
            gl.glEnable(gl.GL_DEPTH_TEST)

            # Color of path
            path["u_color"] = 0, 1, 1
            # Filled path
            path.draw(gl.GL_TRIANGLE_STRIP)
            # Mask depth
            gl.glDepthMask(gl.GL_FALSE)
            # Color of edge lines of path
            path["u_color"] = 0, 0, 0
            # Width of edge lines
            gl.glLineWidth(10.0)
            # Draw edge lines with index buffer bline_I
            path.draw(gl.GL_LINES, bline_I)
            # Reset line width
            gl.glLineWidth(1.0)
            gl.glDepthMask(gl.GL_TRUE)

            # Define the model matrix with updated rotation
            model = np.eye(4, dtype=np.float32)
            glm.rotate(model, theta, 0, 0, 1)
            glm.rotate(model, phi, 0, 1, 0)

            for obj in bag.values():
                obj["u_color"] = 1, 0, 0

                # Filled cube
                obj.draw(gl.GL_TRIANGLES, I)

                # Another method to disable depth, instead of disabling it, mask it
                gl.glDepthMask(gl.GL_FALSE)
                # Black color for edge lines of cube
                obj["u_color"] = 0, 0, 0
                # Draw the edge lines with the given index buffer
                obj.draw(gl.GL_LINES, O)
                # Unmask OpenGL depth aparamter
                gl.glDepthMask(gl.GL_TRUE)

                # Model matrix is used to define orientation ,in this case, used to rotate cube
                obj["model"] = model

            # Update cube rotations
            theta += 2.0  # degrees
            phi += 2.0  # degrees
        finally:
            lock.release()
Ejemplo n.º 4
0
    def on_draw(dt):
        global phi, theta

        window.clear()

        lock.acquire()
        try:
            gl.glDisable(gl.GL_DEPTH_TEST)

            # try:
            #    quad['texture'] = cam_img_texture
            # except:
            #    quad['texture'] = cv.imread("/home/rahul/Pictures/GitKraken_001.png")[..., ::-1]
            quad.draw(gl.GL_TRIANGLE_STRIP)

            gl.glEnable(gl.GL_DEPTH_TEST)
            # Filled cube

            path["u_color"] = 0, 1, 1
            path.draw(gl.GL_TRIANGLE_STRIP)
            gl.glDepthMask(gl.GL_FALSE)
            path["u_color"] = 0, 0, 0
            gl.glLineWidth(7.5)
            path.draw(gl.GL_LINES, bline_I)
            gl.glLineWidth(1.0)
            gl.glDepthMask(gl.GL_TRUE)

            model = np.eye(4, dtype=np.float32)
            glm.rotate(model, theta, 0, 0, 1)
            glm.rotate(model, phi, 0, 1, 0)

            for obj in bag.values():
                obj["u_color"] = 1, 0, 0
                obj.draw(gl.GL_TRIANGLES, I)

                gl.glDepthMask(gl.GL_FALSE)
                obj["u_color"] = 0, 0, 0
                obj.draw(gl.GL_LINES, O)
                gl.glDepthMask(gl.GL_TRUE)

                obj["model"] = model

            # cube.draw(gl.GL_TRIANGLES, I)

            # Make cube rotate
            theta += 2.0  # degrees
            phi += 2.0  # degrees
        finally:
            lock.release()
Ejemplo n.º 5
0
def on_draw(dt):
    window.clear()

    polygon["color"] = 0.95, 0.95, 0.95, 1.00
    gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL)
    polygon.draw(gl.GL_TRIANGLES, I)

    gl.glLineWidth(1.0)
    polygon["color"] = 0.50, 0.50, 0.50, 1.00
    gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
    polygon.draw(gl.GL_TRIANGLES, I)

    gl.glLineWidth(3.0)
    polygon["color"] = 0.00, 0.00, 0.00, 1.00
    polygon.draw(gl.GL_LINE_LOOP, O)
Ejemplo n.º 6
0
def on_draw(dt):
    global lines
    gl.glLineWidth(10)
    window.clear()
    for program in programs:
        program['theta'] = theta
        program['scale'] = scale
        program['dx'] = dx
        program['dy'] = dy
        #program.draw(gl.LINE_STRIP)

    #circle3.draw(gl.GL_TRIANGLE_STRIP)
    circle1.draw(gl.GL_TRIANGLE_STRIP)
    star.draw(gl.GL_TRIANGLE_STRIP)
    triangles.draw(gl.GL_TRIANGLE_STRIP)
    circle2.draw(gl.GL_TRIANGLE_STRIP)
    things.draw(gl.GL_TRIANGLE_STRIP)
    for line in lines:
        line.draw(gl.GL_LINE_STRIP)
Ejemplo n.º 7
0
def on_draw(dt):
    global phi, theta, time

    window.clear()
    time += dt
    # fill cube
    gl.glLineWidth(2)
    cube['u_color'] = 1, 1, 1, 1
    cube.draw(gl.GL_TRIANGLES, indices)
    cube['u_color'] = 0, 0, 0, 1
    cube.draw(gl.GL_LINES, outlines)
    # rotation animation
    theta += 0.25  # deg
    phi += 0.25  # deg

    model = np.eye(4, dtype=np.float32)
    glm.rotate(model, theta, 0, 0, 1)
    glm.rotate(model, phi, 0, 1, 0)
    cube["u_model"] = model
Ejemplo n.º 8
0
    def _draw_circles(self, centers):
        gl.glEnable(gl.GL_BLEND)
        gl.glEnable(gl.GL_LINE_SMOOTH)
        gl.glDisable(gl.GL_DEPTH_TEST)

        gl.glLineWidth(3)

        for i in range(len(centers)):
            center = centers[i]
            radius = self.__harmonics[i].radius
            model = np.eye(4, dtype=np.float32)
            glm.scale(model, radius / 2, radius / 2, 1)
            glm.translate(model, center[0] / 2, center[1] / 2, 0)

            self.__circles_program[self.u_model] = model
            self.__circles_program[self.u_color] = self.__circle_color
            self.__circles_program.draw(gl.GL_TRIANGLE_FAN, self.__circle_i)

            self.__circles_program[self.u_color] = self.__ocircle_color
            self.__circles_program.draw(gl.GL_LINE_LOOP, self.__ocircle_i)
Ejemplo n.º 9
0
    phi += 0.5 # degrees
    model = np.eye(4, dtype=np.float32)
    glm.rotate(model, theta, 0, 0, 1)
    glm.rotate(model, phi, 0, 1, 0)
    cube['model'] = model


# Build cube data
V, I, O = colorcube()
vertices = V.view(gloo.VertexBuffer)
faces    = I.view(gloo.IndexBuffer)
outline  = O.view(gloo.IndexBuffer)

cube = gloo.Program(vertex, fragment)
cube.bind(vertices)
transform = PVMProjection(Position3D("position"))
cube['transform'] = transform
window.attach(transform)

phi, theta = 0, 0

# OpenGL initalization
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glPolygonOffset(1, 1)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glLineWidth(0.75)

# Run
app.run()
Ejemplo n.º 10
0
    phi += 0.5  # degrees
    model = np.eye(4, dtype=np.float32)
    glm.rotate(model, theta, 0, 0, 1)
    glm.rotate(model, phi, 0, 1, 0)
    transform['model'] = model


# Build cube data
V, I, O = colorcube()
vertices = V.view(gloo.VertexBuffer)
faces = I.view(gloo.IndexBuffer)
outline = O.view(gloo.IndexBuffer)

cube = gloo.Program(vertex, fragment)
cube.bind(vertices)
transform = PVMProjection(Position("position"))
cube['transform'] = transform
window.attach(transform)

phi, theta = 0, 0

# OpenGL initalization
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glPolygonOffset(1, 1)
gl.glEnable(gl.GL_LINE_SMOOTH)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glLineWidth(0.75)

# Run
app.run()
Ejemplo n.º 11
0
def on_init():
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(0.75)
Ejemplo n.º 12
0
 def _draw_radiuses(self, radiuses):
     gl.glLineWidth(3)
     self.__radiuses_program[self.a_pos] = radiuses
     self.__radiuses_program.draw(gl.GL_LINE_STRIP)
Ejemplo n.º 13
0
def on_init():
    gl.glLineWidth(2.0)
Ejemplo n.º 14
0
def on_draw(_):
    window.clear()
    gl.glLineWidth(2)
    gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    program.draw(gl.GL_TRIANGLES, indices.reshape(-1).astype(np.uint32).view(gloo.IndexBuffer))
Ejemplo n.º 15
0
def on_init():
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(2.5)
Ejemplo n.º 16
0
def on_init():
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glLineWidth(4.0)
    gl.glDisable(gl.GL_CULL_FACE)
Ejemplo n.º 17
0
def on_init():
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(2.5)
Ejemplo n.º 18
0
def on_init():
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(0.75)