Exemple #1
0
    def draw(self, pipeline, stage):
        # Drawing Structure model with a given pipeline
        # The textures depends on the stage given
        background = sg.findNode(self.model, "background")

        if stage == 0:
            background.childs = [self.texture_0]
        elif stage == 1:
            background.childs = [self.texture_2]
        elif stage == 2:
            background.childs = [self.texture_2]
        elif stage == 3:
            background.childs = [self.texture_3]
        elif stage == 4:
            background.childs = [self.texture_4]
        elif stage == 5:
            background.childs = [self.texture_5]
        elif stage == 6:
            background.childs = [self.texture_6]
        elif stage == 7:
            background.childs = [self.texture_7]
        elif stage == 8:
            background.childs = [self.texture_8]
        elif stage == 9:
            background.childs = [self.texture_9]
        elif stage == 10:
            background.childs = [self.texture_10]

        glUseProgram(pipeline.shaderProgram)
        sg.drawSceneGraphNode(self.model, pipeline, "transform")
Exemple #2
0
 def draw(self, pipeline1, pipeline2, snake: 'Snake'):
     self.choca_esquina(snake)
     if snake.die:
         glUseProgram(pipeline2.shaderProgram)
         sg.drawSceneGraphNode(self.model, pipeline2, 'transform')
     else:
         glUseProgram(pipeline1.shaderProgram)
         sg.drawSceneGraphNode(self.model, pipeline1, 'transform')
Exemple #3
0
 def drawBackground(self, time):
     #Draw the moving background
     # time - current clock time in seconds
     # Telling OpenGL to use our shader program for textures
     glUseProgram(self.pipelineTexture.shaderProgram)
     self.background.transform = tr.translate(0, (-time / 4) % 2, 0)
     sg.drawSceneGraphNode(self.background, self.pipelineTexture,
                           "transform")
Exemple #4
0
 def drawEndScreen(self, time, endScreen):
     # End screen handling
     # endScreen - end creen SceneGraphNode
     # time - current clock time in seconds
     if self.endTray is None:
         self.endTray = gu.LinearTrayectory(time, 2, 0.0, 2.0, 0.0, 0.0)
     # Telling OpenGL to use our shader program for textures
     glUseProgram(self.pipelineTexture.shaderProgram)
     goX, goY = self.endTray.get_pos(time)
     endScreen.transform = tr.translate(goX, goY, 0.0)
     sg.drawSceneGraphNode(endScreen, self.pipelineTexture, "transform")
Exemple #5
0
 def draw(self, pipeline):
     if self.last_direction == "D":
         self.face_orientation = "D"
         new_gpu_snake = es.toGPUShape(bs.createTextureQuad("boo_r.png"),
                                       GL_CLAMP, GL_NEAREST)
         sg.findNode(self.model, "snake_head").childs = [new_gpu_snake]
     elif self.last_direction == "A":
         self.face_orientation = "A"
         new_gpu_snake = es.toGPUShape(bs.createTextureQuad("boo_l.png"),
                                       GL_CLAMP, GL_NEAREST)
         sg.findNode(self.model, "snake_head").childs = [new_gpu_snake]
     sg.drawSceneGraphNode(self.model, pipeline, "transform")
Exemple #6
0
def drawExplosions(time):

    global logic

    for explosion in logic.explosions:
        shape = explosion.shape
        spawnTime = explosion.spawnTime

        position = tr.translate(explosion.xPos, explosion.yPos, 0)
        scale = tr.uniformScale(0.2 * (spawnTime + 1 - time))

        shape.transform = tr.matmul([position, scale])
        sg.drawSceneGraphNode(shape, pipeline, "transform")
Exemple #7
0
def drawTree(tree, pipeline):

    # Object is barely visible at only ambient and brighter for the diffuse component.
    glUniform3f(glGetUniformLocation(pipeline.shaderProgram, "Ka"), 0.3, 0.3,
                0.3)
    glUniform3f(glGetUniformLocation(pipeline.shaderProgram, "Kd"), 0.5, 0.5,
                0.5)
    glUniform3f(glGetUniformLocation(pipeline.shaderProgram, "Ks"), 0.1, 0.1,
                0.1)

    # In my humble opinion, natural wood and leaves aren't shiny at all
    glUniform1ui(glGetUniformLocation(pipeline.shaderProgram, "shininess"), 1)

    # Drawing the shapes
    sg.drawSceneGraphNode(tree, pipeline, "model")
Exemple #8
0
def drawMap(map, pipeline):

    # Object is barely visible at only ambient and brighter for the diffuse component.
    glUniform3f(glGetUniformLocation(pipeline.shaderProgram, "Ka"), 0.3, 0.3,
                0.3)
    glUniform3f(glGetUniformLocation(pipeline.shaderProgram, "Kd"), 0.5, 0.5,
                0.5)
    glUniform3f(glGetUniformLocation(pipeline.shaderProgram, "Ks"), 0.1, 0.1,
                0.1)

    # The map shouldn't be that shiny
    glUniform1ui(glGetUniformLocation(pipeline.shaderProgram, "shininess"), 1)

    # Drawing the shapes
    sg.drawSceneGraphNode(map, pipeline, "model")
Exemple #9
0
    def draw(self, pipeline_texture):
        # Draws the monkey model with a given pipeline texture
        # The state depends on the state of the monkey

        monkey_body = sg.findNode(self.model, "body")

        if self.is_jumping or self.is_falling:
            monkey_body.childs = [self.gpu_texture_jumping]
        elif self.position_x > self.aiming_x:
            monkey_body.childs = [self.gpu_texture_left]
        elif self.position_x < self.aiming_x:
            monkey_body.childs = [self.gpu_texture_right]
        else:
            monkey_body.childs = [self.gpu_texture_monkey]

        glUseProgram(pipeline_texture.shaderProgram)
        sg.drawSceneGraphNode(self.model, pipeline_texture, 'transform')
Exemple #10
0
    def draw(self, pipeline_texture, t):
        # Drawing Structure model with a given pipeline
        # The texture depends on the given time variable

        scene = sg.findNode(self.model, "scene")

        if t < 0.2:
            scene.childs = [self.texture_1]
        elif 0.4 >= t >= 0.2:
            scene.childs = [self.texture_2]
        elif 0.6 >= t >= 0.4:
            scene.childs = [self.texture_3]
        elif 0.8 >= t >= 0.6:
            scene.childs = [self.texture_4]
        else:
            scene.childs = [self.texture_5]

        glUseProgram(pipeline_texture.shaderProgram)
        sg.drawSceneGraphNode(self.model, pipeline_texture, 'transform')
Exemple #11
0
def drawScreen(pipeline, time, background, player):

    global controller
    global logic

    # Local position of the animated flames
    flameLoop = 0.2 * np.sin(12 * time)

    # Drawing the animated background.
    backTime = time % 5
    background.transform = tr.translate(0, -backTime * 0.4, 0)
    sg.drawSceneGraphNode(background, pipeline, "transform")

    # Drawing the explosions of defeated ships
    drawExplosions(time)

    # Drawing the enemies
    for enemy in logic.enemies:
        ship = enemy.ship
        ship.transform = tr.translate(enemy.xPos, enemy.yPos, 0)

        animatedFlame = sg.findNode(ship, "animatedFlame")
        animatedFlame.transform = tr.translate(0, flameLoop, 0)

        sg.drawSceneGraphNode(ship, pipeline, "transform")

    # Drawing the bullets
    for bullet in logic.bullets:
        shape = bullet.shape
        shape.transform = tr.translate(bullet.xPos, bullet.yPos, 0)
        sg.drawSceneGraphNode(shape, pipeline, "transform")

    # Drawing the player
    player.transform = tr.translate(controller.xPos, controller.yPos, 0)

    animatedFlame = sg.findNode(player, "animatedFlame")
    animatedFlame.transform = tr.translate(0, flameLoop, 0)

    sg.drawSceneGraphNode(player, pipeline, "transform")

    # Drawing the lifebar of the player, with the corresponding colors
    drawLifeBar(pipeline, logic.hp)
Exemple #12
0
def drawLifeBar(pipeline, hp):

    bar0 = ve.createLifeBar(hp > 0)
    bar0.transform = tr.translate(-0.92, -0.95, 0)

    bar1 = ve.createLifeBar(hp > 1)
    bar1.transform = tr.translate(-0.81, -0.95, 0)

    bar2 = ve.createLifeBar(hp > 2)
    bar2.transform = tr.translate(-0.70, -0.95, 0)

    sg.drawSceneGraphNode(bar0, pipeline, "transform")
    sg.drawSceneGraphNode(bar1, pipeline, "transform")
    sg.drawSceneGraphNode(bar2, pipeline, "transform")
Exemple #13
0
                else:
                    sg.findNode(main_scene_translate, "Monkey Texture").childs = \
                        [monkey_texture_left2]
        elif controller.leftKeyOn is False and monkey_left is True:
            monkey_left = False
            sg.findNode(main_scene_translate, "Monkey Texture").childs = \
                [monkey_texture]

        if controller.rightKeyOn:
            if monkey_right is False:
                monkey_right = True
            else:
                if math.ceil(math.sin(theta * 30)) == 1:
                    sg.findNode(main_scene_translate, "Monkey Texture").childs = \
                        [monkey_texture_right1]
                else:
                    sg.findNode(main_scene_translate, "Monkey Texture").childs = \
                        [monkey_texture_right2]
        elif controller.rightKeyOn is False and monkey_right is True:
            monkey_right = False
            sg.findNode(main_scene_translate, "Monkey Texture").childs = \
                [monkey_texture]

        # Drawing
        sg.drawSceneGraphNode(main_scene, pipeline, "transform")

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    glfw.terminate()
			nodoReqDe = sg.findNode(malla, requisitoDe)
			nodoReqDe.transform = tr.scale(1,1,1.5)





		# Filling or not the shapes depending on the controller state
		if (controller.fillPolygon):
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
		else:
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

		#if controller.showAxis:
		#   glUniformMatrix4fv(glGetUniformLocation(embisi.shaderProgram, "model"), 1, GL_TRUE, tr.identity())
		#   embisi.drawShape(gpuAxis, GL_LINES)

		enzo(mvcPipeline)
		# Drawing the Car
		sg.drawSceneGraphNode(fondo, mvcPipeline, "model")
		sg.drawSceneGraphNode(malla, mvcPipeline, "model")
		glFlush()

		cursoAnterior = cursoActual

		# Once the render is done, buffers are swapped, showing only the complete scene.
		glfw.swap_buffers(window)

	
	glfw.terminate()
Exemple #15
0
        glUniformMatrix4fv(
            glGetUniformLocation(mvpPipeline.shaderProgram, "projection"), 1,
            GL_TRUE, projection)
        glUniformMatrix4fv(
            glGetUniformLocation(mvpPipeline.shaderProgram, "view"), 1,
            GL_TRUE, view)
        glUniformMatrix4fv(
            glGetUniformLocation(mvpPipeline.shaderProgram, "model"), 1,
            GL_TRUE, tr.identity())
        mvpPipeline.drawShape(gpuAq, GL_LINES)
        if controller.showAxis:
            mvpPipeline.drawShape(gpuAxis, GL_LINES)
        # Draw fish
        for f in fish:
            f.update(time)
        sg.drawSceneGraphNode(fish_scene, mvpPipeline, "model")

        # Draw aquarium
        glUseProgram(phongPipeline.shaderProgram)

        # White light in all components: ambient, diffuse and specular.
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "La"),
                    1.0, 1.0, 1.0)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ld"),
                    1.0, 1.0, 1.0)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ls"),
                    1.0, 1.0, 1.0)

        # Object is barely visible at only ambient. Diffuse behavior is slightly red. Sparkles are white
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ka"),
                    0.3, 0.3, 0.3)
Exemple #16
0
        # Using GLFW to check for input events
        glfw.poll_events()

        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT)

        # Drawing the scene for the planets and the stars
        for redPlanet in redPlanets:
            redPlanet.transform = tr.translate(0, redPlanet.pos_y, 0)
            if redPlanet.pos_y > -3:
                redPlanet.pos_y -= dt
            else:
                redPlanet.pos_y = 2
                redPlanet.pos_y -= dt
            sg.drawSceneGraphNode(redPlanet, pipeline, "transform")

        for greenPlanet in greenPlanets:
            greenPlanet.transform = tr.translate(0, greenPlanet.pos_y, 0)
            if greenPlanet.pos_y > -3:
                greenPlanet.pos_y -= dt
            else:
                greenPlanet.pos_y = 2
                greenPlanet.pos_y -= dt
            sg.drawSceneGraphNode(greenPlanet, pipeline, "transform")

        for bluePlanet in bluePlanets:
            bluePlanet.transform = tr.translate(0, bluePlanet.pos_y, 0)
            if bluePlanet.pos_y > -3:
                bluePlanet.pos_y -= dt
            else:
Exemple #17
0
        glClear(GL_COLOR_BUFFER_BIT)

        # If the game is over, the loop is reduced to
        # showing a victory or defeat texture
        if logic.hp <= 0 or logic.score >= N:

            logic.bullets.clear()
            logic.enemies.clear()

            glUseProgram(texturePipeline.shaderProgram)
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

            image = victory if logic.score >= N else gameOver

            image.transform = tr.uniformScale(1 + 0.1 * np.sin(5 * time))
            sg.drawSceneGraphNode(image, texturePipeline, "transform")

            # If just defeated, draws a single explosion
            if logic.hp == 0:
                logic.explosions.clear()
                Explosion(controller.xPos, -0.8 + controller.yPos, time)
                logic.hp -= 1

            if len(logic.explosions) > 0:
                glUseProgram(pipeline.shaderProgram)
                explosionLogic(time)
                drawExplosions(time)

            glfw.swap_buffers(window)
            continue
Exemple #18
0
 def draw_game_over(self, pipeline, dt):
     sg.findNode(self.g_over, "game_over_banner_TR").transform = tr.matmul([
         sg.findTransform(self.g_over, "game_over_banner_TR"),
         tr.rotationZ(dt)
     ])
     sg.drawSceneGraphNode(self.g_over, pipeline, "transform")
Exemple #19
0
    def draw(self, pipeline):

        sg.drawSceneGraphNode(self.model, pipeline, 'transform')
Exemple #20
0
        # Draw Tree
        glUseProgram(phongPipeline.shaderProgram)

        # White light in all components: ambient, diffuse and specular.
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "La"), 1.0, 1.0, 1.0)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ld"), 1.0, 1.0, 1.0)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ls"), 1.0, 1.0, 1.0)

        # Object is barely visible at only ambient. Diffuse behavior is slightly red. Sparkles are white
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ka"), 0.3, 0.3, 0.3)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Kd"), 0.9, 0.5, 0.5)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "Ks"), 0.4, 0.4, 0.4)

        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "lightPosition"), -5, -5, 5)
        glUniform3f(glGetUniformLocation(phongPipeline.shaderProgram, "viewPosition"), viewPos[0], viewPos[1], viewPos[2])
        glUniform1ui(glGetUniformLocation(phongPipeline.shaderProgram, "shininess"), 100)
        
        glUniform1f(glGetUniformLocation(phongPipeline.shaderProgram, "constantAttenuation"), 0.0001)
        glUniform1f(glGetUniformLocation(phongPipeline.shaderProgram, "linearAttenuation"), 0.03)
        glUniform1f(glGetUniformLocation(phongPipeline.shaderProgram, "quadraticAttenuation"), 0.01)

        glUniformMatrix4fv(glGetUniformLocation(phongPipeline.shaderProgram, "projection"), 1, GL_TRUE, projection)
        glUniformMatrix4fv(glGetUniformLocation(phongPipeline.shaderProgram, "view"), 1, GL_TRUE, view)
        

        sg.drawSceneGraphNode(tree_node, phongPipeline, "model")
        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    
    glfw.terminate()
        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Filling or not the shapes depending on the controller state
        if (controller.fillPolygon):
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        else:
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

        if controller.showAxis:
            glUniformMatrix4fv(glGetUniformLocation(mvcPipeline.shaderProgram, "model"), 1, GL_TRUE, tr.identity())
            mvcPipeline.drawShape(gpuAxis, GL_LINES)

        # Moving the red car and rotating its wheels
        redCarNode.transform = tr.translate(3 * np.sin( glfw.get_time() ),0,0.5)
        redWheelRotationNode = sg.findNode(redCarNode, "wheelRotation")
        redWheelRotationNode.transform = tr.rotationY(-10 * glfw.get_time())

        # Uncomment to print the red car position on every iteration
        #print(sg.findPosition(redCarNode, "car"))

        # Drawing the Car
        sg.drawSceneGraphNode(redCarNode, mvcPipeline, "model")
        sg.drawSceneGraphNode(blueCarNode, mvcPipeline, "model")

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    
    glfw.terminate()
Exemple #22
0
    # Telling OpenGL to use our shader program
    glUseProgram(shaderProgram)

    # Setting up the clear screen color
    glClearColor(0.85, 0.85, 0.85, 1.0)

    # Creating shapes on GPU memory
    car = createCar()

    # Our shapes here are always fully painted
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

    while not glfw.window_should_close(window):
        # Using GLFW to check for input events
        glfw.poll_events()

        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT)

        # Modifying only a specific node in the scene graph
        wheelRotationNode = sg.findNode(car, "wheelRotation")
        theta = -10 * glfw.get_time()
        wheelRotationNode.transform = tr.rotationZ(theta)

        # Drawing the Car
        sg.drawSceneGraphNode(car, shaderProgram, tr.identity())

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    glfw.terminate()
Exemple #23
0
 def draw(self, pipeline):
     model = self.get_model()
     sg.drawSceneGraphNode(model, pipeline, 'transform')
Exemple #24
0
        dty = np.sin(5 * t0)
        if dty > 0:
            rotation += dt
            if dty > 0.99:  # This is for preventing errors
                rotation = 0
        else:
            rotation -= dt

        # Drawing fishes
        glUseProgram(pipeline.shaderProgram)
        glUniformMatrix4fv(glGetUniformLocation(pipeline.shaderProgram, 'projection'), 1, GL_TRUE, projection)
        glUniformMatrix4fv(glGetUniformLocation(pipeline.shaderProgram, 'view'), 1, GL_TRUE, view)
        glUniformMatrix4fv(glGetUniformLocation(pipeline.shaderProgram, 'model'), 1, GL_TRUE, model)

        for fishA in fishesA:
            sg.drawSceneGraphNode(fishA, pipeline, 'model')
        for fishB in fishesB:
            sg.drawSceneGraphNode(fishB, pipeline, 'model')
        for fishC in fishesC:
            sg.drawSceneGraphNode(fishC, pipeline, 'model')
        sg.drawSceneGraphNode(scaledBorder, pipeline, 'model')

        # Drawing voxels
        glUseProgram(voxelsPipeline.shaderProgram)
        glUniformMatrix4fv(glGetUniformLocation(voxelsPipeline.shaderProgram, 'projection'), 1, GL_TRUE, projection)
        glUniformMatrix4fv(glGetUniformLocation(voxelsPipeline.shaderProgram, 'view'), 1, GL_TRUE, view)
        glUniformMatrix4fv(glGetUniformLocation(voxelsPipeline.shaderProgram, 'model'), 1, GL_TRUE, model)

        if controller.a:
            sg.drawSceneGraphNode(scaledSurfaceA, voxelsPipeline, 'model')
        elif controller.b:
    while not glfw.window_should_close(window):
        # Using GLFW to check for input events
        glfw.poll_events()

        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        # Filling or not the shapes depending on the controller state
        if (controller.fillPolygon):
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        else:
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)



        # Moving the red car and rotating its wheels

        # Uncomment to print the red car position on every iteration
        #print(sg.findPosition(redCarNode, "car"))

        # Drawing the Car
        sg.drawSceneGraphNode(cuboM, mvcPipeline, "model")
        sg.drawSceneGraphNode(cuboC, mvcPipeline, "model")
        sg.drawSceneGraphNode(cuboT, mvcPipeline, "model")
        sg.drawSceneGraphNode(cuboN, mvcPipeline, "model")

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    
    glfw.terminate()


        pos_f1 = vel_f % f
        pos_f2 = (-vel_f + f) % f

        if(shift_f): 
            fondo1.transform = tr.translate(pos_f2,0,0)
            fondo2.transform = tr.translate(-pos_f1,0,0)
        else:
            fondo1.transform = tr.translate(-pos_f1,0,0)
            fondo2.transform = tr.translate(pos_f2,0,0)





        sg.drawSceneGraphNode(fondo1, pipeline, "transform")
        sg.drawSceneGraphNode(fondo2, pipeline, "transform")




        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)

    
    glfw.terminate()


Exemple #27
0
 def draw(self, pipeline):
     for i in range(len(self.serpiente)):
         glUseProgram(pipeline.shaderProgram)
         self.serpiente[i].transform = tr.translate(self.pos[i][0],
                                                    self.pos[i][1], 0)
         sg.drawSceneGraphNode(self.serpiente[i], pipeline, "transform")
Exemple #28
0
        # Drawing the birds
        if t0 > 3:
            if i < N * c - 2:
                # Calculating the derivative for the rotation of the bird
                x1 = C[i][0]
                y1 = C[i][1]
                z1 = C[i][2]
                derivative1 = (C[i + 2][1] - y1) / (C[i + 2][0] - x1)
                angle1 = np.arctan(derivative1)
                # Transformation of the bird
                birdNode1.transform = tr.matmul([
                    tr.translate(x1, y1, z1),
                    tr.rotationZ(angle1),
                    tr.uniformScale(0.2)
                ])
                sg.drawSceneGraphNode(birdNode1, phongPipeline, "model")
                i += 1
            elif i == N * c - 2:
                i = 0

        if t0 > 4:
            if j < N * c - 2:
                # Calculating the derivative for the rotation of the bird
                x2 = C[j][0]
                y2 = C[j][1]
                z2 = C[j][2]
                derivative2 = (C[j + 2][1] - y2) / (C[j + 2][0] - x2)
                angle2 = np.arctan(derivative2)
                # Transformation of the bird
                birdNode2.transform = tr.matmul([
                    tr.translate(x2, y2, z2),
Exemple #29
0
 def draw(self, pipeline):  
     self.model.transform = tr.translate(self.pos_x, self.pos_y, 0)
     sg.drawSceneGraphNode(self.model, pipeline, "transform")
Exemple #30
0
    # Telling OpenGL to use our shader program
    glUseProgram(shaderProgram)

    # Setting up the clear screen color
    glClearColor(0.35, 0.35, 0.35, 1.0)

    # Our shapes here are always fully painted
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)

    BARRA = barra()
    TAPA = tapa()

    while not glfw.window_should_close(window):

        # Using GLFW to check for input events
        glfw.poll_events()

        # Clearing the screen in both, color and depth
        glClear(GL_COLOR_BUFFER_BIT)

        # Drawing the arbol
        sg.drawSceneGraphNode(BARRA, shaderProgram, tr.identity())
        sg.drawSceneGraphNode(TAPA, shaderProgram,
                              tr.translate(0, obj.val + 0.5, 0))
        sg.drawSceneGraphNode(circulo(obj.grab), shaderProgram, tr.identity())

        # Once the render is done, buffers are swapped, showing only the complete scene.
        glfw.swap_buffers(window)
    glfw.terminate()