shift-W in pview opens new window on same gsg

This commit is contained in:
David Rose 2003-07-17 18:17:24 +00:00
parent 138af95d58
commit e51dfb192f
7 changed files with 49 additions and 15 deletions

View File

@ -44,6 +44,11 @@ GraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) {
_pipe = pipe;
_gsg = gsg;
if (display_cat.is_debug()) {
display_cat.debug()
<< "Creating new window using GSG " << (void *)gsg << "\n";
}
// Some default properties for windows unless specified otherwise.
// Other properties (size, title, etc.) must be explicitly
// specified.

View File

@ -166,13 +166,13 @@ get_default_window_props(WindowProperties &props) {
// NULL if not.
////////////////////////////////////////////////////////////////////
WindowFramework *PandaFramework::
open_window(GraphicsPipe *pipe) {
open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) {
nassertr(_is_open, NULL);
WindowProperties props;
get_default_window_props(props);
return open_window(props, pipe);
return open_window(props, pipe, gsg);
}
////////////////////////////////////////////////////////////////////
@ -186,7 +186,8 @@ open_window(GraphicsPipe *pipe) {
// NULL if not.
////////////////////////////////////////////////////////////////////
WindowFramework *PandaFramework::
open_window(const WindowProperties &props, GraphicsPipe *pipe) {
open_window(const WindowProperties &props, GraphicsPipe *pipe,
GraphicsStateGuardian *gsg) {
if (pipe == (GraphicsPipe *)NULL) {
pipe = get_default_pipe();
if (pipe == (GraphicsPipe *)NULL) {
@ -203,7 +204,7 @@ open_window(const WindowProperties &props, GraphicsPipe *pipe) {
wf->set_lighting(get_lighting());
wf->set_background_type(get_background_type());
GraphicsWindow *win = wf->open_window(props, &_engine, pipe);
GraphicsWindow *win = wf->open_window(props, &_engine, pipe, gsg);
if (win == (GraphicsWindow *)NULL) {
// Oops, couldn't make an actual window.
delete wf;

View File

@ -54,9 +54,11 @@ public:
INLINE void set_window_title(const string &title);
virtual void get_default_window_props(WindowProperties &props);
WindowFramework *open_window(GraphicsPipe *pipe = NULL);
WindowFramework *open_window(GraphicsPipe *pipe = NULL,
GraphicsStateGuardian *gsg = NULL);
WindowFramework *open_window(const WindowProperties &props,
GraphicsPipe *pipe = NULL);
GraphicsPipe *pipe = NULL,
GraphicsStateGuardian *gsg = NULL);
INLINE int get_num_windows() const;
INLINE WindowFramework *get_window(int n) const;

View File

@ -94,17 +94,23 @@ WindowFramework::
////////////////////////////////////////////////////////////////////
GraphicsWindow *WindowFramework::
open_window(const WindowProperties &props, GraphicsEngine *engine,
GraphicsPipe *pipe) {
GraphicsPipe *pipe, GraphicsStateGuardian *gsg) {
nassertr(_window == (GraphicsWindow *)NULL, _window);
PT(GraphicsStateGuardian) gsg = engine->make_gsg(pipe);
if (gsg == (GraphicsStateGuardian *)NULL) {
// No GSG, no window.
framework_cat.fatal() << "open_window: failed to create gsg object!\n";
return NULL;
PT(GraphicsStateGuardian) ptgsg = gsg;
// If we were not given a gsg in the arguments, create a new one
// just for this window.
if (ptgsg == (GraphicsStateGuardian *)NULL) {
ptgsg = engine->make_gsg(pipe);
if (ptgsg == (GraphicsStateGuardian *)NULL) {
// No GSG, no window.
framework_cat.fatal() << "open_window: failed to create gsg object!\n";
return NULL;
}
}
_window = engine->make_window(pipe, gsg);
_window = engine->make_window(pipe, ptgsg);
if (_window != (GraphicsWindow *)NULL) {
_window->request_properties(props);
set_background_type(_background_type);

View File

@ -49,7 +49,8 @@ public:
protected:
GraphicsWindow *open_window(const WindowProperties &props,
GraphicsEngine *engine, GraphicsPipe *pipe);
GraphicsEngine *engine, GraphicsPipe *pipe,
GraphicsStateGuardian *gsg = NULL);
void close_window();
public:

View File

@ -1066,6 +1066,13 @@ stash_child(int child_index) {
void PandaNode::
unstash_child(int stashed_index) {
nassertv(stashed_index >= 0 && stashed_index < get_num_stashed());
// Save a reference count for ourselves. I don't think this should
// be necessary, but there are occasional crashes in stash() during
// furniture moving mode. Perhaps this will eliminate those
// crashes.
PT(PandaNode) self = this;
PT(PandaNode) child_node = get_stashed(stashed_index);
int sort = get_stashed_sort(stashed_index);

View File

@ -23,7 +23,19 @@ PandaFramework framework;
void
event_W(CPT_Event, void *) {
// shift-W: open a new window on the same scene.
WindowFramework *window = framework.open_window();
// If we already have a window, use the same GSG.
GraphicsPipe *pipe = (GraphicsPipe *)NULL;
GraphicsStateGuardian *gsg = (GraphicsStateGuardian *)NULL;
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();
}
WindowFramework *window = framework.open_window(pipe, gsg);
if (window != (WindowFramework *)NULL) {
window->enable_keyboard();
window->setup_trackball();