Esempio n. 1
0
    height = 600

    window = glfw.create_window(width, height, "No-Mipmap vs Mipmap", None,
                                None)

    if not window:
        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)
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height)

    # now actually attach it
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
                              GL_RENDERBUFFER, rbo)

    # now that we actually created the framebuffer and added all attachments we want to check if it is actually complete now
    if glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE:
        print("ERROR::FRAMEBUFFER:: Framebuffer is not complete!")

    # Binding again the default shape buffer
    glBindFramebuffer(GL_FRAMEBUFFER, 0)

    # Creating shader programs for textures and for colors
    #######################
    textureShaderProgram = es.SimpleTextureTransformShaderProgram()
    colorShaderProgram = es.SimpleModelViewProjectionShaderProgram()

    # Creating shapes on GPU memory
    #######################
    rainbowCube = bs.createRainbowCube()
    gpuRainbowCube = es.GPUShape().initBuffers()
    colorShaderProgram.setupVAO(gpuRainbowCube)
    gpuRainbowCube.fillBuffers(rainbowCube.vertices, rainbowCube.indices,
                               GL_STATIC_DRAW)

    shapeQuad = bs.createTextureQuad(1, 1)
    gpuQuad = es.GPUShape().initBuffers()
    textureShaderProgram.setupVAO(gpuQuad)
    gpuQuad.fillBuffers(shapeQuad.vertices, shapeQuad.indices, GL_STATIC_DRAW)
    gpuQuad.texture = textureColorbuffer  # <--- Here is where the magic happens!