pgraph uses window's begin_frame() .. end_frame()

This commit is contained in:
David Rose 2002-03-29 20:18:38 +00:00
parent 79766b015e
commit df1fd03cac
8 changed files with 76 additions and 70 deletions

View File

@ -528,19 +528,8 @@ render_frame() {
report_errors();
_decal_level = 0;
#ifdef DO_PSTATS
// For Pstats to track our current texture memory usage, we have to
// reset the set of current textures each frame.
init_frame_pstats();
_vertices_display_list_pcollector.clear_level();
// But since we don't get sent a new issue_texture() unless our
// texture state has changed, we have to be sure to clear the
// current texture state now. A bit unfortunate, but probably not
// measurably expensive.
clear_attribute(TextureTransition::get_class_type());
#endif
// First, clear the entire window.
clear_framebuffer();

View File

@ -111,7 +111,7 @@ cull_and_draw_together() {
Windows::iterator wi;
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
GraphicsWindow *win = (*wi);
win->get_gsg()->reset_frame();
win->begin_frame();
win->clear();
int num_display_regions = win->get_num_display_regions();
@ -119,7 +119,7 @@ cull_and_draw_together() {
DisplayRegion *dr = win->get_display_region(i);
cull_and_draw_together(win, dr);
}
win->flip();
win->end_frame();
win->process_events();
}
}
@ -160,7 +160,7 @@ cull_bin_draw() {
Windows::iterator wi;
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
GraphicsWindow *win = (*wi);
win->get_gsg()->reset_frame();
win->begin_frame();
win->clear();
int num_display_regions = win->get_num_display_regions();
@ -168,7 +168,7 @@ cull_bin_draw() {
DisplayRegion *dr = win->get_display_region(i);
cull_bin_draw(win, dr);
}
win->flip();
win->end_frame();
win->process_events();
}
}

View File

@ -24,6 +24,7 @@
#include "colorAttrib.h"
#include "colorScaleAttrib.h"
#include "lightAttrib.h"
#include "textureAttrib.h"
#include "renderState.h"
#include "depthWriteAttrib.h"
#include "colorWriteAttrib.h"
@ -852,24 +853,15 @@ prepare_lens() {
return false;
}
static CPT(RenderState)
get_unlit_state() {
static CPT(RenderState) state = NULL;
if (state == (const RenderState *)NULL) {
state = RenderState::make(LightAttrib::make_all_off());
}
return state;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::reset_frame
// Function: GraphicsStateGuardian::begin_frame
// Access: Public, Virtual
// Description: Called before each frame is rendered, to allow the
// GSG a chance to do any internal cleanup before
// beginning the frame.
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
reset_frame() {
begin_frame() {
// Undo any lighting we had enabled last frame, to force the lights
// to be reissued, in case their parameters or positions have
// changed between frames.
@ -886,6 +878,29 @@ reset_frame() {
_lighting_enabled_this_frame = false;
}
#ifdef DO_PSTATS
// For Pstats to track our current texture memory usage, we have to
// reset the set of current textures each frame.
init_frame_pstats();
// But since we don't get sent a new issue_texture() unless our
// texture state has changed, we have to be sure to clear the
// current texture state now. A bit unfortunate, but probably not
// measurably expensive.
modify_state(get_untextured_state());
#endif
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::end_frame
// Access: Public, Virtual
// Description: Called after each frame is rendered, to allow the
// GSG a chance to do any internal cleanup after
// rendering the frame, and before the window flips.
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
end_frame() {
}
////////////////////////////////////////////////////////////////////
@ -1701,6 +1716,33 @@ record_state_change(TypeHandle type) {
}
#endif // DO_PSTATS
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::get_unlit_state
// Access: Protected, Static
// Description:
////////////////////////////////////////////////////////////////////
CPT(RenderState) GraphicsStateGuardian::
get_unlit_state() {
static CPT(RenderState) state = NULL;
if (state == (const RenderState *)NULL) {
state = RenderState::make(LightAttrib::make_all_off());
}
return state;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::get_untextured_state
// Access: Protected, Static
// Description:
////////////////////////////////////////////////////////////////////
CPT(RenderState) GraphicsStateGuardian::
get_untextured_state() {
static CPT(RenderState) state = NULL;
if (state == (const RenderState *)NULL) {
state = RenderState::make(TextureAttrib::make_off());
}
return state;
}
void GraphicsStateGuardian::
traverse_prepared_textures(bool (*pertex_callbackfn)(TextureContext *,void *),void *callback_arg) {

View File

@ -132,7 +132,8 @@ public:
INLINE void enable_normals(bool val) { _normals_enabled = val; }
virtual void reset_frame();
virtual void begin_frame();
virtual void end_frame();
// These functions will be queried by the GeomIssuer to determine if
// it should issue normals, texcoords, and/or colors, based on the
@ -245,6 +246,9 @@ protected:
INLINE void count_node(Node *) { }
#endif
static CPT(RenderState) get_unlit_state();
static CPT(RenderState) get_untextured_state();
protected:
PT(SceneSetup) _scene_setup;
@ -385,7 +389,6 @@ public:
private:
static void read_priorities(void);
static GsgFactory *_factory;
public:

View File

@ -454,6 +454,18 @@ void GraphicsWindow::
update() {
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::begin_frame
// Access: Public, Virtual
// Description: This function will be called by the GSG before
// beginning processing for a given frame. It should do
// whatever setup is required.
////////////////////////////////////////////////////////////////////
void GraphicsWindow::
begin_frame() {
_gsg->begin_frame();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::clear
// Access: Public
@ -467,31 +479,6 @@ clear() {
_gsg->clear_framebuffer();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::flip
// Access: Public, Virtual
// Description: Flips the back buffer and front buffer, or does
// whatever other processing is appropriate, after the
// frame has been completely drawn. Normally this is
// only called by the draw process between frames, in
// sync with all the other windows.
////////////////////////////////////////////////////////////////////
void GraphicsWindow::
flip() {
end_frame();
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::begin_frame
// Access: Public, Virtual
// Description: This function will be called by the GSG before
// beginning processing for a given frame. It should do
// whatever setup is required.
////////////////////////////////////////////////////////////////////
void GraphicsWindow::
begin_frame() {
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsWindow::end_frame
// Access: Public, Virtual
@ -501,6 +488,7 @@ begin_frame() {
////////////////////////////////////////////////////////////////////
void GraphicsWindow::
end_frame() {
_gsg->end_frame();
_frame_number++;
}

View File

@ -200,11 +200,8 @@ PUBLISHED:
INLINE void render_and_update();
public:
// New-style scene graph rendering (not yet complete).
void clear();
virtual void flip();
virtual void begin_frame();
void clear();
virtual void end_frame();
virtual void deactivate_window(void);
virtual void reactivate_window(void);

View File

@ -527,19 +527,8 @@ render_frame() {
report_errors();
_decal_level = 0;
#ifdef DO_PSTATS
// For Pstats to track our current texture memory usage, we have to
// reset the set of current textures each frame.
init_frame_pstats();
_vertices_display_list_pcollector.clear_level();
// But since we don't get sent a new issue_texture() unless our
// texture state has changed, we have to be sure to clear the
// current texture state now. A bit unfortunate, but probably not
// measurably expensive.
clear_attribute(TextureTransition::get_class_type());
#endif
// First, clear the entire window.
clear_framebuffer();

View File

@ -123,8 +123,6 @@ class LensNode;
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA GraphicsStateGuardianBase : public TypedReferenceCount {
public:
virtual void reset_frame()=0;
// These functions will be queried by the GeomIssuer to determine if
// it should issue normals, texcoords, and/or colors, based on the
// GSG's current state.