From 51fa0c2ca3d52dae08f4fbbb938a53126fd5539c Mon Sep 17 00:00:00 2001 From: "Asad M. Zaman" Date: Tue, 25 May 2004 21:07:15 +0000 Subject: [PATCH] added a new switch to pview to toggle between window/fullscreen --- panda/src/testbed/pview.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 8047c977a7..6758b15aa8 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -52,6 +52,36 @@ event_W(CPT_Event, void *) { } } +void +event_Enter(CPT_Event, void *) { + // alt-enter: toggle between window/fullscreen in the same scene. + + // If we already have a window, use the same GSG. + GraphicsPipe *pipe = (GraphicsPipe *)NULL; + GraphicsStateGuardian *gsg = (GraphicsStateGuardian *)NULL; + + WindowProperties props; + + if (framework.get_num_windows() > 0) { + WindowFramework *old_window = framework.get_window(0); + GraphicsWindow *win = old_window->get_graphics_window(); + pipe = win->get_pipe(); + gsg = win->get_gsg(); + props = win->get_properties(); + framework.close_window(old_window); + } + + // set the toggle + props.set_fullscreen(!props.get_fullscreen()); + + WindowFramework *window = framework.open_window(props, pipe, gsg); + if (window != (WindowFramework *)NULL) { + window->enable_keyboard(); + window->setup_trackball(); + framework.get_models().instance_to(window->get_render()); + } +} + void event_2(CPT_Event event, void *) { // 2: split the window into two display regions. @@ -178,6 +208,7 @@ main(int argc, char *argv[]) { framework.enable_default_keys(); framework.define_key("shift-w", "open a new window", event_W, NULL); + framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, NULL); framework.define_key("2", "split the window", event_2, NULL); framework.main_loop(); framework.report_frame_rate(nout);