Skip to content

Commit

Permalink
Add more VideoRenderer APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaquraish committed Nov 13, 2023
1 parent cccaf4e commit 43aa0d0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions std/video_renderer/mod.oc
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def VideoRenderer::finish(&this) {
}
}

def VideoRenderer::wait_and_finish(&this) {
match .type {
SDL => .u.sdl.wait_for_quit()
FFMPEG => {}
}
.finish()
}

19 changes: 19 additions & 0 deletions std/video_renderer/sdl.oc
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,23 @@ def SDLContext::send_frame(&this, img: &Image) {
.renderer.copy(.buffer, null, null)
.renderer.present()
.last_frame = sdl::get_ticks()
}

def SDLContext::wait_for_quit(&this) {
let quit = false
while not quit {
let e: sdl::Event
while sdl::poll_event(&e) {
match e.type {
Quit => quit = true
KeyDown => {
match e.key.keysym.scancode {
Q | Escape => quit = true
else => {}
}
}
else => {}
}
}
}
}

0 comments on commit 43aa0d0

Please sign in to comment.