camcontrol: add cleanup
This is mostly to fix an annoying assertion failure that pops up when quitting the game or restarting the stage.
This commit is contained in:
parent
d3786e7cf7
commit
0055de4245
2 changed files with 11 additions and 2 deletions
|
@ -89,9 +89,19 @@ static void predraw(EntityInterface *ent, void *a) {
|
|||
}
|
||||
}
|
||||
|
||||
TASK(cleanup) {
|
||||
ent_unhook_pre_draw(predraw);
|
||||
events_unregister_handler(mouse_event);
|
||||
events_unregister_handler(wheel_event);
|
||||
events_unregister_handler(focus_gained_event);
|
||||
events_unregister_handler(focus_lost_event);
|
||||
}
|
||||
|
||||
TASK(camera_control, { Camera3D *cam; }) {
|
||||
Camera3D *cam = ARGS.cam;
|
||||
|
||||
INVOKE_TASK_AFTER(&TASK_EVENTS(THIS_TASK)->finished, cleanup);
|
||||
|
||||
SDL_Window *w = NOT_NULL(video_get_window());
|
||||
SDL_SetWindowGrab(w, true);
|
||||
SDL_CaptureMouse(true);
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
/*
|
||||
* NOTE: This is a stage background debugging facility that provides FPS-like keyboard-and-mouse
|
||||
* fly-mode camera control. This code is not linked into non-developer builds, and usually is not
|
||||
* referenced anywhere — it is expected to be used transiently while working on backgrounds. Which
|
||||
* is why it doesn't bother with cleaning up after itself, by the way.
|
||||
* referenced anywhere — it is expected to be used transiently while working on backgrounds.
|
||||
*
|
||||
* To use it, simply call `camcontrol_init` in your background animation setup code instead of
|
||||
* invoking normal animation code. For best results, disable anything that can alter the camera
|
||||
|
|
Loading…
Reference in a new issue