Exemple #1
0
def main():
    sdl.init({"video"})

    window = sdl.Window.create(title="Hello World", center=(True, True), size=SIZE, flags={"opengl", "shown"})

    renderer = sdl.Renderer.create(window=window, index=-1, flags={"accelerated", "targettexture"})

    print(renderer.info())
    print(gl.context_info())

    triangle = gl.VertexArray(postion=POS, color=COLORS)
    program = gl.Program(vertex=vs, fragment=fs)

    running = True
    while running:
        program.draw(triangle, gl.SCREEN)
        for event in sdl.event.pending_events():
            if isinstance(event, sdl.event.Quit):
                print(event.timestamp)
                running = False
                break

    window.destroy()
    renderer.destroy()
    sdl.quit()
Exemple #2
0
"""
This example should show the minimal code required to draw a triangle.
"""

from graphene import sdl
from graphene import gl

from time import sleep

sdl.init({'video'})

window = sdl.Window.create('Hello World', flags={'opengl'})
renderer = sdl.Renderer.create(window, flags={'accelerated'})

while not isinstance(sdl.poll_event(), sdl.event.Quit):
    # Do NOT do this in real life.
    pass

renderer.destroy()
window.destroy()
sdl.quit()