-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (33 loc) · 846 Bytes
/
Copy pathmain.py
File metadata and controls
41 lines (33 loc) · 846 Bytes
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
# /// script
# dependencies = [
# "zengl",
# "pygame-ce",
# ]
# ///
import asyncio
from zengl_imgui import PygameBackend
import imgui_demo_frame
import pygame
import zengl
screen_size = (800, 600)
pygame.display.set_mode(screen_size, pygame.OPENGL)
ctx = zengl.context()
impl = PygameBackend()
image = ctx.image(screen_size, 'rgba8unorm')
image.clear_value = (0.5, 0.0, 0.0, 1.0)
async def main():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
raise SystemExit
impl.process_event(event)
impl.process_inputs()
ctx.new_frame()
image.clear()
image.blit()
imgui_demo_frame.run()
impl.render()
ctx.end_frame()
pygame.display.flip()
await asyncio.sleep(0)
asyncio.run(main())