mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
pgraph uses window's begin_frame() .. end_frame()
This commit is contained in:
parent
79766b015e
commit
df1fd03cac
@ -528,19 +528,8 @@ render_frame() {
|
|||||||
report_errors();
|
report_errors();
|
||||||
_decal_level = 0;
|
_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();
|
_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.
|
// First, clear the entire window.
|
||||||
clear_framebuffer();
|
clear_framebuffer();
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ cull_and_draw_together() {
|
|||||||
Windows::iterator wi;
|
Windows::iterator wi;
|
||||||
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
|
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
|
||||||
GraphicsWindow *win = (*wi);
|
GraphicsWindow *win = (*wi);
|
||||||
win->get_gsg()->reset_frame();
|
win->begin_frame();
|
||||||
win->clear();
|
win->clear();
|
||||||
|
|
||||||
int num_display_regions = win->get_num_display_regions();
|
int num_display_regions = win->get_num_display_regions();
|
||||||
@ -119,7 +119,7 @@ cull_and_draw_together() {
|
|||||||
DisplayRegion *dr = win->get_display_region(i);
|
DisplayRegion *dr = win->get_display_region(i);
|
||||||
cull_and_draw_together(win, dr);
|
cull_and_draw_together(win, dr);
|
||||||
}
|
}
|
||||||
win->flip();
|
win->end_frame();
|
||||||
win->process_events();
|
win->process_events();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ cull_bin_draw() {
|
|||||||
Windows::iterator wi;
|
Windows::iterator wi;
|
||||||
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
|
for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
|
||||||
GraphicsWindow *win = (*wi);
|
GraphicsWindow *win = (*wi);
|
||||||
win->get_gsg()->reset_frame();
|
win->begin_frame();
|
||||||
win->clear();
|
win->clear();
|
||||||
|
|
||||||
int num_display_regions = win->get_num_display_regions();
|
int num_display_regions = win->get_num_display_regions();
|
||||||
@ -168,7 +168,7 @@ cull_bin_draw() {
|
|||||||
DisplayRegion *dr = win->get_display_region(i);
|
DisplayRegion *dr = win->get_display_region(i);
|
||||||
cull_bin_draw(win, dr);
|
cull_bin_draw(win, dr);
|
||||||
}
|
}
|
||||||
win->flip();
|
win->end_frame();
|
||||||
win->process_events();
|
win->process_events();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "colorAttrib.h"
|
#include "colorAttrib.h"
|
||||||
#include "colorScaleAttrib.h"
|
#include "colorScaleAttrib.h"
|
||||||
#include "lightAttrib.h"
|
#include "lightAttrib.h"
|
||||||
|
#include "textureAttrib.h"
|
||||||
#include "renderState.h"
|
#include "renderState.h"
|
||||||
#include "depthWriteAttrib.h"
|
#include "depthWriteAttrib.h"
|
||||||
#include "colorWriteAttrib.h"
|
#include "colorWriteAttrib.h"
|
||||||
@ -852,24 +853,15 @@ prepare_lens() {
|
|||||||
return false;
|
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
|
// Access: Public, Virtual
|
||||||
// Description: Called before each frame is rendered, to allow the
|
// Description: Called before each frame is rendered, to allow the
|
||||||
// GSG a chance to do any internal cleanup before
|
// GSG a chance to do any internal cleanup before
|
||||||
// beginning the frame.
|
// beginning the frame.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void GraphicsStateGuardian::
|
void GraphicsStateGuardian::
|
||||||
reset_frame() {
|
begin_frame() {
|
||||||
// Undo any lighting we had enabled last frame, to force the lights
|
// Undo any lighting we had enabled last frame, to force the lights
|
||||||
// to be reissued, in case their parameters or positions have
|
// to be reissued, in case their parameters or positions have
|
||||||
// changed between frames.
|
// changed between frames.
|
||||||
@ -886,6 +878,29 @@ reset_frame() {
|
|||||||
|
|
||||||
_lighting_enabled_this_frame = false;
|
_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
|
#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::
|
void GraphicsStateGuardian::
|
||||||
traverse_prepared_textures(bool (*pertex_callbackfn)(TextureContext *,void *),void *callback_arg) {
|
traverse_prepared_textures(bool (*pertex_callbackfn)(TextureContext *,void *),void *callback_arg) {
|
||||||
|
@ -132,7 +132,8 @@ public:
|
|||||||
|
|
||||||
INLINE void enable_normals(bool val) { _normals_enabled = val; }
|
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
|
// These functions will be queried by the GeomIssuer to determine if
|
||||||
// it should issue normals, texcoords, and/or colors, based on the
|
// it should issue normals, texcoords, and/or colors, based on the
|
||||||
@ -245,6 +246,9 @@ protected:
|
|||||||
INLINE void count_node(Node *) { }
|
INLINE void count_node(Node *) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static CPT(RenderState) get_unlit_state();
|
||||||
|
static CPT(RenderState) get_untextured_state();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PT(SceneSetup) _scene_setup;
|
PT(SceneSetup) _scene_setup;
|
||||||
|
|
||||||
@ -385,7 +389,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static void read_priorities(void);
|
static void read_priorities(void);
|
||||||
|
|
||||||
static GsgFactory *_factory;
|
static GsgFactory *_factory;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -454,6 +454,18 @@ void GraphicsWindow::
|
|||||||
update() {
|
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
|
// Function: GraphicsWindow::clear
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -467,31 +479,6 @@ clear() {
|
|||||||
_gsg->clear_framebuffer();
|
_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
|
// Function: GraphicsWindow::end_frame
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -501,6 +488,7 @@ begin_frame() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void GraphicsWindow::
|
void GraphicsWindow::
|
||||||
end_frame() {
|
end_frame() {
|
||||||
|
_gsg->end_frame();
|
||||||
_frame_number++;
|
_frame_number++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +200,8 @@ PUBLISHED:
|
|||||||
INLINE void render_and_update();
|
INLINE void render_and_update();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// New-style scene graph rendering (not yet complete).
|
|
||||||
void clear();
|
|
||||||
virtual void flip();
|
|
||||||
|
|
||||||
virtual void begin_frame();
|
virtual void begin_frame();
|
||||||
|
void clear();
|
||||||
virtual void end_frame();
|
virtual void end_frame();
|
||||||
virtual void deactivate_window(void);
|
virtual void deactivate_window(void);
|
||||||
virtual void reactivate_window(void);
|
virtual void reactivate_window(void);
|
||||||
|
@ -527,19 +527,8 @@ render_frame() {
|
|||||||
report_errors();
|
report_errors();
|
||||||
_decal_level = 0;
|
_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();
|
_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.
|
// First, clear the entire window.
|
||||||
clear_framebuffer();
|
clear_framebuffer();
|
||||||
|
|
||||||
|
@ -123,8 +123,6 @@ class LensNode;
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDA GraphicsStateGuardianBase : public TypedReferenceCount {
|
class EXPCL_PANDA GraphicsStateGuardianBase : public TypedReferenceCount {
|
||||||
public:
|
public:
|
||||||
virtual void reset_frame()=0;
|
|
||||||
|
|
||||||
// These functions will be queried by the GeomIssuer to determine if
|
// These functions will be queried by the GeomIssuer to determine if
|
||||||
// it should issue normals, texcoords, and/or colors, based on the
|
// it should issue normals, texcoords, and/or colors, based on the
|
||||||
// GSG's current state.
|
// GSG's current state.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user