more multi-window support

This commit is contained in:
David Rose 2002-01-13 20:31:26 +00:00
parent 6c36d79dd0
commit e3d04fd248
4 changed files with 22 additions and 39 deletions

View File

@ -77,7 +77,7 @@ class DirectWaitBar(DirectFrame):
def update(self, value): def update(self, value):
self['value'] = value self['value'] = value
# finally update the window # finally update the window
base.win.update() base.win.renderAndUpdate()
def finish(self): def finish(self):
# Fill the bar in N frames # Fill the bar in N frames

View File

@ -75,6 +75,8 @@ class ShowBase:
# stores a CollisionTraverser pointer here, we'll traverse it # stores a CollisionTraverser pointer here, we'll traverse it
# in the igloop task. # in the igloop task.
self.cTrav = 0 self.cTrav = 0
# Ditto for an AppTraverser.
self.appTrav = 0
# base.win is the main, or only window; base.winList is a list of # base.win is the main, or only window; base.winList is a list of
# *all* windows. Similarly with base.pipeList and base.camList. # *all* windows. Similarly with base.pipeList and base.camList.
@ -513,10 +515,19 @@ class ShowBase:
# CollisionTraverser set. # CollisionTraverser set.
if self.cTrav: if self.cTrav:
self.cTrav.traverse(self.render) self.cTrav.traverse(self.render)
if self.appTrav:
self.appTrav.traverse(self.render.getTopNode())
# Finally, render the frame. # Finally, render the frame.
for win in self.winList: for win in self.winList:
win.update() win.renderAndUpdate()
# The clock needs to be ticked once per frame.
globalClock.tick() globalClock.tick()
# Lerp stuff needs this event, and it must be generated in
# C++, not in Python.
throwNewFrame()
return Task.cont return Task.cont
def restart(self): def restart(self):

View File

@ -60,38 +60,6 @@ get_particle_path() {
std::string chan_config = "single"; std::string chan_config = "single";
std::string window_title = "Panda3D"; std::string window_title = "Panda3D";
void render_frame(GraphicsPipe *pipe) {
int num_windows = pipe->get_num_windows();
for (int w = 0; w < num_windows; w++) {
GraphicsWindow *win = pipe->get_window(w);
win->get_gsg()->render_frame();
}
// clock tick moved to igloop in ShowBase.py because
// clock must tick while app is iconified and draw
// callback is not being called by panda gsg
// ClockObject::get_global_clock()->tick();
throw_event("NewFrame");
}
class WindowCallback : public GraphicsWindow::Callback {
public:
WindowCallback(GraphicsPipe *pipe, Node *render_top) :
_pipe(pipe),
_render_top(render_top),
_app_traverser(RenderRelation::get_class_type()) { }
virtual ~WindowCallback() { }
virtual void draw(bool) {
_app_traverser.traverse(_render_top);
render_frame(_pipe);
}
PT(GraphicsPipe) _pipe;
PT(Node) _render_top;
AppTraverser _app_traverser;
};
PT(GraphicsPipe) make_graphics_pipe() { PT(GraphicsPipe) make_graphics_pipe() {
PT(GraphicsPipe) main_pipe; PT(GraphicsPipe) main_pipe;
@ -142,14 +110,17 @@ ChanConfig make_graphics_window(GraphicsPipe *pipe, NodeRelation *render_arc) {
main_win = chan_config.get_win(); main_win = chan_config.get_win();
assert(main_win != (GraphicsWindow*)0L); assert(main_win != (GraphicsWindow*)0L);
WindowCallback *wcb = new WindowCallback(pipe, render_top);
// Set draw callback. Currently there is no reason to use the idle callback.
main_win->set_draw_callback(wcb);
return chan_config; return chan_config;
} }
// Throw the "NewFrame" event in the C++ world. Some of the lerp code
// depends on receiving this.
void
throw_new_frame() {
throw_event("NewFrame");
}
// Create a scene graph, associated with the indicated window, that // Create a scene graph, associated with the indicated window, that
// can contain 2-d geometry and will be rendered on top of the // can contain 2-d geometry and will be rendered on top of the
// existing 3-d window. Returns the top node of the scene graph. // existing 3-d window. Returns the top node of the scene graph.

View File

@ -47,6 +47,7 @@ EXPCL_DIRECT ChanConfig
make_graphics_window(GraphicsPipe *pipe, make_graphics_window(GraphicsPipe *pipe,
NodeRelation *render_arc); NodeRelation *render_arc);
EXPCL_DIRECT void throw_new_frame();
EXPCL_DIRECT NodePath setup_panda_2d(GraphicsWindow *win, const string &name); EXPCL_DIRECT NodePath setup_panda_2d(GraphicsWindow *win, const string &name);
EXPCL_DIRECT void add_render_layer(GraphicsWindow *win, Node *render_top, EXPCL_DIRECT void add_render_layer(GraphicsWindow *win, Node *render_top,
Camera *camera); Camera *camera);