Exemplo n.º 1
0
def createHumanModel(tex_pipeline):
    # Se crea un cuadrado con textura de humano en gpu
    quadShape = bs.createTextureQuad(1, 1)

    gpuQuad = createTextureGPUShape(quadShape, tex_pipeline,
                                    getAssetPath("human_sprite.png"))

    return gpuQuad
Exemplo n.º 2
0
def createZombieModel(tex_pipeline):
    # Se crea un cuadrado con textura de zombie en gpu
    quadShape = bs.createTextureQuad(1, 1)

    gpuQuad = createTextureGPUShape(quadShape, tex_pipeline,
                                    getAssetPath("zombie_sprite.png"))

    return gpuQuad
Exemplo n.º 3
0
def createPlayerModel(tex_pipeline):
    # Se crea el nodo del modelo del jugador
    quadShape = bs.createTextureQuad(1, 1)

    gpuQuad = createTextureGPUShape(quadShape, tex_pipeline,
                                    getAssetPath("hinata_cut_transparent.png"))

    playerNode = csg.CustomSceneGraphNode("player")
    playerNode.childs = [gpuQuad]

    return playerNode
Exemplo n.º 4
0
def createText(tex_pipeline):
    # Se crean los textos de victoria y game over como texturas en un grafo de escena
    quadShape = bs.createTextureQuad(1, 1)

    gpuGameOver = createTextureGPUShape(
        quadShape, tex_pipeline, getAssetPath("game_over_transparent.png"))
    gpuVictory = createTextureGPUShape(quadShape, tex_pipeline,
                                       getAssetPath("win_transparent.png"))

    gameOverNode = sg.SceneGraphNode("gameOver")
    gameOverNode.childs = [gpuGameOver]

    victoryNode = sg.SceneGraphNode("victory")
    victoryNode.childs = [gpuVictory]

    finalNode = sg.SceneGraphNode("final")
    finalNode.childs = [gameOverNode, victoryNode]

    return finalNode
Exemplo n.º 5
0
        glfw.terminate()
        glfw.set_window_should_close(window, True)

    glfw.make_context_current(window)

    # Connecting the callback function 'on_key' to handle keyboard events
    glfw.set_key_callback(window, on_key)

    # Creating shader program
    pipeline = es.SimpleTextureTransformShaderProgram()

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

    # Shape on CPU memory
    shapeTextureQuad = bs.createTextureQuad(1, 1)

    # Shapes on GPU memory
    gpuShapeWithoutMipmap = es.GPUShape().initBuffers()
    pipeline.setupVAO(gpuShapeWithoutMipmap)
    gpuShapeWithoutMipmap.fillBuffers(shapeTextureQuad.vertices,
                                      shapeTextureQuad.indices, GL_STATIC_DRAW)
    gpuShapeWithoutMipmap.texture = es.textureSimpleSetup(
        getAssetPath("red_woodpecker.jpg"), GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
        GL_LINEAR, GL_LINEAR)

    # Since we want to draw the same shape, but with mipmaps in its texture, there is no need to duplicate
    # the information in the GPU, we can just use the same buffers...
    gpuShapeWithMipmap = es.GPUShape()
    gpuShapeWithMipmap.vao = gpuShapeWithoutMipmap.vao
    gpuShapeWithMipmap.vbo = gpuShapeWithoutMipmap.vbo
Exemplo n.º 6
0
    # Enabling transparencies
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

    # Creating shapes on GPU memory
    cpuAxis = bs.createAxis(7)
    gpuAxis = es.GPUShape().initBuffers()
    mvpPipeline.setupVAO(gpuAxis)
    gpuAxis.fillBuffers(cpuAxis.vertices, cpuAxis.indices, GL_STATIC_DRAW)

    rainbowCube = bs.createRainbowCube()
    gpuRainbowCube = es.GPUShape().initBuffers()
    mvpPipeline.setupVAO(gpuRainbowCube)
    gpuRainbowCube.fillBuffers(rainbowCube.vertices, rainbowCube.indices, GL_STATIC_DRAW)

    shapeBoo = bs.createTextureQuad(1,1)
    gpuBoo = es.GPUShape().initBuffers()
    texture2dPipeline.setupVAO(gpuBoo)
    gpuBoo.fillBuffers(shapeBoo.vertices, shapeBoo.indices, GL_STATIC_DRAW)
    gpuBoo.texture = es.textureSimpleSetup(
        getAssetPath("boo.png"), GL_REPEAT, GL_REPEAT, GL_NEAREST, GL_NEAREST)

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

        # 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)
Exemplo n.º 7
0
    # A simple shader program with position and texture coordinates as inputs.
    pipeline = es.SimpleTextureTransformShaderProgram()

    # Telling OpenGL to use our shader program
    glUseProgram(pipeline.shaderProgram)

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

    # Enabling transparencies
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

    # Creating shapes on GPU memory
    shapeBoo = bs.createTextureQuad(1, 1)
    gpuBoo = GPUShape().initBuffers()
    pipeline.setupVAO(gpuBoo)
    gpuBoo.fillBuffers(shapeBoo.vertices, shapeBoo.indices, GL_STATIC_DRAW)
    gpuBoo.texture = es.textureSimpleSetup(getAssetPath("boo.png"),
                                           GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
                                           GL_NEAREST, GL_NEAREST)

    shapeQuestionBoxes = bs.createTextureQuad(10, 1)
    gpuQuestionBoxes = GPUShape().initBuffers()
    pipeline.setupVAO(gpuQuestionBoxes)
    gpuQuestionBoxes.fillBuffers(shapeQuestionBoxes.vertices,
                                 shapeQuestionBoxes.indices, GL_STATIC_DRAW)
    gpuQuestionBoxes.texture = es.textureSimpleSetup(
        getAssetPath("cg_box.png"), GL_REPEAT, GL_REPEAT, GL_NEAREST,
        GL_NEAREST)
Exemplo n.º 8
0
    # Binding artificial vertex array object for validation
    VAO = glGenVertexArrays(1)
    glBindVertexArray(VAO)

    # A simple shader program with position and texture coordinates as inputs.
    pipeline = es.SimpleTextureTransformShaderProgram()

    # Telling OpenGL to use our shader program
    glUseProgram(pipeline.shaderProgram)

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

    # Creating shapes on GPU memory
    shape = bs.createTextureQuad(2, 2)
    gpuShape = es.GPUShape().initBuffers()
    pipeline.setupVAO(gpuShape)
    gpuShape.fillBuffers(shape.vertices, shape.indices, GL_STATIC_DRAW)
    gpuShape.texture = es.textureSimpleSetup(getAssetPath("bricks.jpg"),
                                             GL_CLAMP_TO_EDGE,
                                             GL_CLAMP_TO_EDGE, GL_LINEAR,
                                             GL_LINEAR)

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

        if (controller.fillPolygon):
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
        else:
Exemplo n.º 9
0
    # Enabling transparencies
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

    # Creating texture with all characters
    textBitsTexture = tx.generateTextBitsTexture()
    # Moving texture to GPU memory
    gpuText3DTexture = tx.toOpenGLTexture(textBitsTexture)

    # Testing text 3D texture. Check the terminal!
    for char in "hi!":
        print(textBitsTexture[:, :, ord(char)].transpose() * 255)
        print()

    # Creating shapes on GPU memory
    backgroundShape = bs.createTextureQuad(1, 1)
    bs.scaleVertices(backgroundShape, 5, [2, 2, 1])
    gpuBackground = es.GPUShape().initBuffers()
    texturePipeline.setupVAO(gpuBackground)
    gpuBackground.fillBuffers(backgroundShape.vertices,
                              backgroundShape.indices, GL_STATIC_DRAW)
    gpuBackground.texture = es.textureSimpleSetup(
        getAssetPath("torres-del-paine-sq.jpg"), GL_CLAMP_TO_EDGE,
        GL_CLAMP_TO_EDGE, GL_LINEAR, GL_LINEAR)

    headerText = "Torres del Paine"
    headerCharSize = 0.1
    headerCenterX = headerCharSize * len(headerText) / 2
    headerShape = tx.textToShape(headerText, headerCharSize, headerCharSize)
    gpuHeader = es.GPUShape().initBuffers()
    textPipeline.setupVAO(gpuHeader)