mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
better implementation of set_one_shot()
This commit is contained in:
parent
7609fc777f
commit
e91fb0d53e
@ -299,45 +299,6 @@ is_valid() const {
|
|||||||
return _is_valid;
|
return _is_valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GraphicsOutput::set_one_shot
|
|
||||||
// Access: Published
|
|
||||||
// Description: Changes the current setting of the one-shot flag.
|
|
||||||
// When this is true, the GraphicsOutput will render one
|
|
||||||
// frame and then automatically set itself inactive.
|
|
||||||
// This is particularly useful for buffers that are
|
|
||||||
// created for the purposes of render-to-texture, for
|
|
||||||
// static textures that don't need to be continually
|
|
||||||
// re-rendered once they have been rendered the first
|
|
||||||
// time.
|
|
||||||
//
|
|
||||||
// Setting the buffer inactive is not the same thing as
|
|
||||||
// destroying it. You are still responsible for passing
|
|
||||||
// this buffer to GraphicsEngine::remove_window() when
|
|
||||||
// you no longer need the texture, in order to clean up
|
|
||||||
// fully. (However, you should not call remove_window()
|
|
||||||
// on this buffer while the texture is still needed,
|
|
||||||
// because depending on the render-to-texture mechanism
|
|
||||||
// in use, this may invalidate the texture contents.)
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void GraphicsOutput::
|
|
||||||
set_one_shot(bool one_shot) {
|
|
||||||
_one_shot = one_shot;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GraphicsOutput::get_one_shot
|
|
||||||
// Access: Published
|
|
||||||
// Description: Returns the current setting of the one-shot flag.
|
|
||||||
// When this is true, the GraphicsOutput will
|
|
||||||
// automatically set itself inactive after the next
|
|
||||||
// frame.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool GraphicsOutput::
|
|
||||||
get_one_shot() const {
|
|
||||||
return _one_shot;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::get_inverted
|
// Function: GraphicsOutput::get_inverted
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -104,7 +104,6 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
_child_sort = 0;
|
_child_sort = 0;
|
||||||
_got_child_sort = false;
|
_got_child_sort = false;
|
||||||
_internal_sort_index = 0;
|
_internal_sort_index = 0;
|
||||||
_one_shot = false;
|
|
||||||
_inverted = window_inverted;
|
_inverted = window_inverted;
|
||||||
_red_blue_stereo = false;
|
_red_blue_stereo = false;
|
||||||
_left_eye_color_mask = 0x0f;
|
_left_eye_color_mask = 0x0f;
|
||||||
@ -447,9 +446,61 @@ is_active() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CDReader cdata(_cycler);
|
CDReader cdata(_cycler);
|
||||||
|
if (cdata->_one_shot_frame != -1) {
|
||||||
|
// If one_shot is in effect, then we are active only for the one
|
||||||
|
// indicated frame.
|
||||||
|
if (cdata->_one_shot_frame != ClockObject::get_global_clock()->get_frame_count()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return cdata->_active;
|
return cdata->_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsOutput::set_one_shot
|
||||||
|
// Access: Published
|
||||||
|
// Description: Changes the current setting of the one-shot flag.
|
||||||
|
// When this is true, the GraphicsOutput will render the
|
||||||
|
// current frame and then automatically set itself
|
||||||
|
// inactive. This is particularly useful for buffers
|
||||||
|
// that are created for the purposes of
|
||||||
|
// render-to-texture, for static textures that don't
|
||||||
|
// need to be continually re-rendered once they have
|
||||||
|
// been rendered the first time.
|
||||||
|
//
|
||||||
|
// Setting the buffer inactive is not the same thing as
|
||||||
|
// destroying it. You are still responsible for passing
|
||||||
|
// this buffer to GraphicsEngine::remove_window() when
|
||||||
|
// you no longer need the texture, in order to clean up
|
||||||
|
// fully. (However, you should not call remove_window()
|
||||||
|
// on this buffer while the texture is still needed,
|
||||||
|
// because depending on the render-to-texture mechanism
|
||||||
|
// in use, this may invalidate the texture contents.)
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void GraphicsOutput::
|
||||||
|
set_one_shot(bool one_shot) {
|
||||||
|
CDWriter cdata(_cycler, true);
|
||||||
|
if (one_shot) {
|
||||||
|
cdata->_one_shot_frame = ClockObject::get_global_clock()->get_frame_count();
|
||||||
|
} else {
|
||||||
|
cdata->_one_shot_frame = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsOutput::get_one_shot
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the current setting of the one-shot flag.
|
||||||
|
// When this is true, the GraphicsOutput will
|
||||||
|
// automatically set itself inactive after the next
|
||||||
|
// frame.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool GraphicsOutput::
|
||||||
|
get_one_shot() const {
|
||||||
|
CDReader cdata(_cycler);
|
||||||
|
return (cdata->_one_shot_frame == ClockObject::get_global_clock()->get_frame_count());
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsOutput::set_inverted
|
// Function: GraphicsOutput::set_inverted
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -1669,6 +1720,7 @@ CData() {
|
|||||||
// initially populated with inactive outputs. Pipeline stage 0 is
|
// initially populated with inactive outputs. Pipeline stage 0 is
|
||||||
// set to active in the constructor.
|
// set to active in the constructor.
|
||||||
_active = false;
|
_active = false;
|
||||||
|
_one_shot_frame = -1;
|
||||||
_active_display_regions_stale = false;
|
_active_display_regions_stale = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1681,6 +1733,7 @@ GraphicsOutput::CData::
|
|||||||
CData(const GraphicsOutput::CData ©) :
|
CData(const GraphicsOutput::CData ©) :
|
||||||
_textures(copy._textures),
|
_textures(copy._textures),
|
||||||
_active(copy._active),
|
_active(copy._active),
|
||||||
|
_one_shot_frame(copy._one_shot_frame),
|
||||||
_active_display_regions(copy._active_display_regions),
|
_active_display_regions(copy._active_display_regions),
|
||||||
_active_display_regions_stale(copy._active_display_regions_stale)
|
_active_display_regions_stale(copy._active_display_regions_stale)
|
||||||
{
|
{
|
||||||
|
@ -127,8 +127,8 @@ PUBLISHED:
|
|||||||
void set_active(bool active);
|
void set_active(bool active);
|
||||||
virtual bool is_active() const;
|
virtual bool is_active() const;
|
||||||
|
|
||||||
INLINE void set_one_shot(bool one_shot);
|
void set_one_shot(bool one_shot);
|
||||||
INLINE bool get_one_shot() const;
|
bool get_one_shot() const;
|
||||||
|
|
||||||
void set_inverted(bool inverted);
|
void set_inverted(bool inverted);
|
||||||
INLINE bool get_inverted() const;
|
INLINE bool get_inverted() const;
|
||||||
@ -303,7 +303,6 @@ private:
|
|||||||
unsigned int _internal_sort_index;
|
unsigned int _internal_sort_index;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _one_shot;
|
|
||||||
bool _inverted;
|
bool _inverted;
|
||||||
bool _red_blue_stereo;
|
bool _red_blue_stereo;
|
||||||
unsigned int _left_eye_color_mask;
|
unsigned int _left_eye_color_mask;
|
||||||
@ -342,6 +341,7 @@ protected:
|
|||||||
|
|
||||||
RenderTextures _textures;
|
RenderTextures _textures;
|
||||||
bool _active;
|
bool _active;
|
||||||
|
int _one_shot_frame;
|
||||||
ActiveDisplayRegions _active_display_regions;
|
ActiveDisplayRegions _active_display_regions;
|
||||||
bool _active_display_regions_stale;
|
bool _active_display_regions_stale;
|
||||||
};
|
};
|
||||||
|
@ -188,9 +188,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
promote_to_copy_texture();
|
promote_to_copy_texture();
|
||||||
copy_to_textures();
|
copy_to_textures();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,9 +150,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
restore_bitplanes();
|
restore_bitplanes();
|
||||||
}
|
}
|
||||||
|
@ -123,9 +123,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,9 +172,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
restore_bitplanes();
|
restore_bitplanes();
|
||||||
}
|
}
|
||||||
|
@ -141,9 +141,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,9 +130,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,9 +207,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -924,9 +924,6 @@ void CLP(GraphicsBuffer)::end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
|
@ -125,9 +125,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,9 +128,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,11 @@ flatten(GraphicsOutput *window) {
|
|||||||
|
|
||||||
GraphicsOutput *buffer = window->make_texture_buffer
|
GraphicsOutput *buffer = window->make_texture_buffer
|
||||||
(multitex_name_strm.str(), x_size, y_size, NULL, false);
|
(multitex_name_strm.str(), x_size, y_size, NULL, false);
|
||||||
|
|
||||||
|
// TODO: this no longer automatically deletes the buffer. We need
|
||||||
|
// to take care of this explicitly now.
|
||||||
buffer->set_one_shot(true);
|
buffer->set_one_shot(true);
|
||||||
|
|
||||||
Texture *tex = buffer->get_texture();
|
Texture *tex = buffer->get_texture();
|
||||||
tex->set_anisotropic_degree(aniso_degree);
|
tex->set_anisotropic_degree(aniso_degree);
|
||||||
tex->set_minfilter(minfilter);
|
tex->set_minfilter(minfilter);
|
||||||
|
@ -102,9 +102,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,9 +673,6 @@ void TinyOsxGraphicsWindow::end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
copy_to_textures();
|
copy_to_textures();
|
||||||
|
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,9 +107,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,9 +135,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,9 +130,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,9 +226,6 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
|
|
||||||
if (mode == FM_render) {
|
if (mode == FM_render) {
|
||||||
trigger_flip();
|
trigger_flip();
|
||||||
if (_one_shot) {
|
|
||||||
prepare_for_deletion();
|
|
||||||
}
|
|
||||||
clear_cube_map_selection();
|
clear_cube_map_selection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user