@paul_craven/

Pyglet example

Pygame

No description

fork
loading
Files
  • main.py
  • nohup.out
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480

import pyglet
from pyglet.gl import *
from pyglet import clock
import time

class MyGame(pyglet.window.Window):

    def __init__(self, width, height):
        config = Config(sample_buffers=1,
                        samples=16,
                        double_buffer=True)

        super().__init__(width, height,
                         config=config)
        glEnable(GL_MULTISAMPLE_ARB)

    def on_draw(self):
        print("Ok")
        # arcade.start_render()

        size = self.height / 4
        # glClear(GL_COLOR_BUFFER_BIT)
        # glEnable(GL_BLEND)
        # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        glLoadIdentity()
        glTranslatef(self.width/2, self.height/2, 0)
        glRotatef(5, 0, 0, 1)

        glColor3f(1, 0, 0)
        glBegin(GL_QUADS)
        glVertex2f(-size, -size)
        glVertex2f(size, -size)
        glVertex2f(size, size)
        glVertex2f(-size, size)
        glEnd()



def main():
    """ Main method """
    window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT)

    # while True:
    #     window.on_draw()
    #     window.flip()
    #     window.dispatch_events()
    pyglet.app.run()


if __name__ == "__main__":
    main()