Panda3D
|
This is a special GraphicsOutput type that acts a lot like a GraphicsBuffer, effectively allowing rendering to an offscreen buffer, except it does not create any framebuffer space for itself. More...
#include "parasiteBuffer.h"
Public Member Functions | |
ParasiteBuffer (GraphicsOutput *host, const string &name, int x_size, int y_size, int flags) | |
Normally, the ParasiteBuffer constructor is not called directly; these are created instead via the GraphicsEngine::make_parasite() function. | |
virtual void | begin_flip () |
This function will be called within the draw thread after end_frame() has been called on all windows, to initiate the exchange of the front and back buffers. | |
virtual bool | begin_frame (FrameMode mode, Thread *current_thread) |
This function will be called within the draw thread before beginning rendering for a given frame. | |
virtual void | end_flip () |
This function will be called within the draw thread after begin_flip() has been called on all windows, to finish the exchange of the front and back buffers. | |
virtual void | end_frame (FrameMode mode, Thread *current_thread) |
This function will be called within the draw thread after rendering is completed for a given frame. | |
virtual bool | flip_ready () const |
Returns true if a frame has been rendered and needs to be flipped, false otherwise. | |
virtual TypeHandle | force_init_type () |
virtual GraphicsOutput * | get_host () |
This is normally called only from within make_texture_buffer(). | |
virtual TypeHandle | get_type () const |
virtual bool | is_active () const |
Returns true if the window is ready to be rendered into, false otherwise. | |
virtual void | ready_flip () |
This function will be called within the draw thread after end_frame() has been called on all windows, to initiate the exchange of the front and back buffers. | |
void | set_size (int x, int y) |
This is called by the GraphicsEngine to request that the buffer resize itself. | |
void | set_size_and_recalc (int x, int y) |
Changes the x_size and y_size, then recalculates structures that depend on size. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This is a special GraphicsOutput type that acts a lot like a GraphicsBuffer, effectively allowing rendering to an offscreen buffer, except it does not create any framebuffer space for itself.
Instead, it renders into the framebuffer owned by some other GraphicsOutput.
The x_size and y_size must therefore fit within the bounds of the source GraphicsOutput.
Since the framebuffer will be subsequently cleared when the actual owner draws in it later, this only makes sense if we are going to copy the contents of the framebuffer to a texture immediately after we draw it. Thus, has_texture() is implicitly true for a ParasiteBuffer.
This class is useful to render offscreen to a texture while preventing the waste of framebuffer memory for API's that are unable to render directly into a texture (and must render into a separate framebuffer first and then copy to texture). It is also the only way to render to a texture on API's that do not support offscreen rendering.
Definition at line 51 of file parasiteBuffer.h.
ParasiteBuffer::ParasiteBuffer | ( | GraphicsOutput * | host, |
const string & | name, | ||
int | x_size, | ||
int | y_size, | ||
int | flags | ||
) |
Normally, the ParasiteBuffer constructor is not called directly; these are created instead via the GraphicsEngine::make_parasite() function.
Definition at line 28 of file parasiteBuffer.cxx.
References GraphicsStateGuardian::get_copy_texture_inverted(), GraphicsOutput::get_gsg(), GraphicsOutput::get_name(), GraphicsOutput::get_x_size(), GraphicsOutput::get_y_size(), and GraphicsOutput::set_inverted().
void ParasiteBuffer::begin_flip | ( | ) | [virtual] |
This function will be called within the draw thread after end_frame() has been called on all windows, to initiate the exchange of the front and back buffers.
This should instruct the window to prepare for the flip at the next video sync, but it should not wait.
We have the two separate functions, begin_flip() and end_flip(), to make it easier to flip all of the windows at the same time.
Reimplemented from GraphicsOutput.
Definition at line 147 of file parasiteBuffer.cxx.
bool ParasiteBuffer::begin_frame | ( | FrameMode | mode, |
Thread * | current_thread | ||
) | [virtual] |
This function will be called within the draw thread before beginning rendering for a given frame.
It should do whatever setup is required, and return true if the frame should be rendered, or false if it should be skipped.
Reimplemented from GraphicsOutput.
Definition at line 196 of file parasiteBuffer.cxx.
References GraphicsOutput::begin_frame_spam(), GraphicsOutput::clear_cube_map_selection(), and set_size_and_recalc().
void ParasiteBuffer::end_flip | ( | ) | [virtual] |
This function will be called within the draw thread after begin_flip() has been called on all windows, to finish the exchange of the front and back buffers.
This should cause the window to wait for the flip, if necessary.
Reimplemented from GraphicsOutput.
Definition at line 180 of file parasiteBuffer.cxx.
void ParasiteBuffer::end_frame | ( | FrameMode | mode, |
Thread * | current_thread | ||
) | [virtual] |
This function will be called within the draw thread after rendering is completed for a given frame.
It should do whatever finalization is required.
Reimplemented from GraphicsOutput.
Definition at line 229 of file parasiteBuffer.cxx.
References GraphicsOutput::clear_cube_map_selection(), GraphicsOutput::copy_to_textures(), GraphicsOutput::end_frame_spam(), and GraphicsOutput::promote_to_copy_texture().
bool ParasiteBuffer::flip_ready | ( | ) | const [virtual] |
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
Reimplemented from GraphicsOutput.
Definition at line 127 of file parasiteBuffer.cxx.
GraphicsOutput * ParasiteBuffer::get_host | ( | ) | [virtual] |
This is normally called only from within make_texture_buffer().
When called on a ParasiteBuffer, it returns the host of that buffer; but when called on some other buffer, it returns the buffer itself.
Reimplemented from GraphicsOutput.
Definition at line 257 of file parasiteBuffer.cxx.
bool ParasiteBuffer::is_active | ( | ) | const [virtual] |
Returns true if the window is ready to be rendered into, false otherwise.
Reimplemented from GraphicsOutput.
Definition at line 78 of file parasiteBuffer.cxx.
void ParasiteBuffer::ready_flip | ( | ) | [virtual] |
This function will be called within the draw thread after end_frame() has been called on all windows, to initiate the exchange of the front and back buffers.
This should instruct the window to prepare for the flip when it is command but not actually flip
Reimplemented from GraphicsOutput.
Definition at line 164 of file parasiteBuffer.cxx.
void ParasiteBuffer::set_size | ( | int | x, |
int | y | ||
) |
This is called by the GraphicsEngine to request that the buffer resize itself.
Although calls to get the size will return the new value, much of the actual resizing work doesn't take place until the next begin_frame. Not all buffers are resizeable.
Definition at line 92 of file parasiteBuffer.cxx.
References set_size_and_recalc().
void ParasiteBuffer::set_size_and_recalc | ( | int | x, |
int | y | ||
) |
Changes the x_size and y_size, then recalculates structures that depend on size.
The recalculation currently includes:
Reimplemented from GraphicsOutput.
Definition at line 106 of file parasiteBuffer.cxx.
References Texture::down_to_power_2().
Referenced by begin_frame(), and set_size().