15 #include "parasiteBuffer.h"
29 int x_size,
int y_size,
int flags) :
31 name, host->get_fb_properties(),
33 host->get_gsg(), host, false)
35 #ifdef DO_MEMORY_USAGE
36 MemoryUsage::update_type(
this,
this);
39 if (display_cat.is_debug()) {
41 <<
"Creating new parasite buffer " <<
get_name()
42 <<
" on " << _host->get_name() <<
"\n";
45 _creation_flags = flags;
47 if (flags & GraphicsPipe::BF_size_track_host) {
50 _size.set(x_size, y_size);
54 _overlay_display_region->compute_pixels(_size.get_x(), _size.get_y());
92 if ((_creation_flags & GraphicsPipe::BF_resizeable) == 0) {
93 nassert_raise(
"Cannot resize buffer unless it is created with BF_resizeable flag");
96 set_size_and_recalc(x, y);
104 void ParasiteBuffer::
105 set_size_and_recalc(
int x,
int y) {
106 if (!(_creation_flags & GraphicsPipe::BF_size_track_host)) {
107 if (_creation_flags & GraphicsPipe::BF_size_power_2) {
111 if (_creation_flags & GraphicsPipe::BF_size_square) {
127 nassertr(_host != NULL,
false);
128 return _host->flip_ready();
147 nassertv(_host != NULL);
164 nassertv(_host != NULL);
180 nassertv(_host != NULL);
196 begin_frame_spam(mode);
198 if (!_host->begin_frame(FM_parasite, current_thread)) {
202 if (_creation_flags & GraphicsPipe::BF_size_track_host) {
203 if (_host->get_size() != _size) {
204 set_size_and_recalc(_host->get_x_size(),
205 _host->get_y_size());
210 set_size_and_recalc(min(
get_x_size(), _host->get_x_size()),
215 clear_cube_map_selection();
228 end_frame_spam(mode);
232 _host->end_frame(FM_parasite, current_thread);
234 if (mode == FM_refresh) {
238 if (mode == FM_render) {
239 promote_to_copy_texture();
241 clear_cube_map_selection();
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
bool get_copy_texture_inverted() const
Returns true if this particular GSG has the property that any framebuffer-to-texture copy results in ...
virtual GraphicsOutput * get_host()
This is normally called only from within make_texture_buffer().
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
virtual bool flip_ready() const
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
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 begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame...
void set_inverted(bool inverted)
Changes the current setting of the inverted flag.
virtual void ready_flip()
This function will be called within the draw thread after end_frame() has been called on all windows...
GraphicsStateGuardian * get_gsg() const
Returns the GSG that is associated with this window.
const LVecBase2i & get_size() const
Returns the visible size of the window or buffer, if it is known.
This is a base class for the various different classes that represent the result of a frame of render...
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
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 Gr...
void set_size(int x, int y)
This is called by the GraphicsEngine to request that the buffer resize itself.
A thread; that is, a lightweight process.
Encapsulates all the communication with a particular instance of a given rendering backend...
static int down_to_power_2(int value)
Returns the largest power of 2 less than or equal to value.
virtual bool is_active() const
Returns true if the window is ready to be rendered into, false otherwise.
TypeHandle is the identifier used to differentiate C++ class types.
const string & get_name() const
Returns the name that was passed to the GraphicsOutput constructor.
virtual bool is_active() const
Returns true if the window is ready to be rendered into, false otherwise.