Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GraphicsOutput Class Reference

This is a base class for the various different classes that represent the result of a frame of rendering. More...

Inheritance diagram for GraphicsOutput:
GraphicsOutputBase DrawableRegion TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject GraphicsBuffer GraphicsWindow ParasiteBuffer CallbackGraphicsWindow

Public Types

enum  FrameMode { FM_render = 0, FM_parasite = 1, FM_refresh = 2 }
 
enum  RenderTextureMode {
  RTM_none = 0, RTM_bind_or_copy = 1, RTM_copy_texture = 2, RTM_copy_ram = 3,
  RTM_triggered_copy_texture = 4, RTM_triggered_copy_ram = 5, RTM_bind_layered = 6
}
 
- Public Types inherited from DrawableRegion
enum  RenderTexturePlane {
  RTP_stencil = 0, RTP_depth_stencil = 1, RTP_color = 2, RTP_aux_rgba_0 = 3,
  RTP_aux_rgba_1 = 4, RTP_aux_rgba_2 = 5, RTP_aux_rgba_3 = 6, RTP_aux_hrgba_0 = 7,
  RTP_aux_hrgba_1 = 8, RTP_aux_hrgba_2 = 9, RTP_aux_hrgba_3 = 10, RTP_aux_float_0 = 11,
  RTP_aux_float_1 = 12, RTP_aux_float_2 = 13, RTP_aux_float_3 = 14, RTP_depth = 15,
  RTP_COUNT = 16
}
 

Public Member Functions

 addRenderTexture (Texture tex, GraphicsOutput::RenderTextureMode mode, DrawableRegion::RenderTexturePlane bitplane)
 Creates a new Texture object, suitable for rendering the contents of this buffer into, and appends it to the list of render textures. More...
 
 clearChildSort ()
 Resets the sort value of future offscreen buffers created by make_texture_sort() to the default value. More...
 
 clearDeleteFlag ()
 Resets the delete flag, so the GraphicsOutput will not be automatically deleted before the beginning of the next frame. More...
 
 clearRenderTextures ()
 If the GraphicsOutput is currently rendering to a texture, then all textures are dissociated from the GraphicsOuput. More...
 
int countTextures ()
 If the GraphicsOutput is set to render into a texture, returns the number of textures that are being rendered into. More...
 
bool flipReady ()
 
DisplayRegion getActiveDisplayRegion (int n)
 Returns the nth active DisplayRegion of those that have been created within the window. More...
 
list getActiveDisplayRegions ()
 
int getChildSort ()
 Returns the sort value of future offscreen buffers created by make_texture_sort(). More...
 
bool getDeleteFlag ()
 Returns the current setting of the delete flag. More...
 
DisplayRegion getDisplayRegion (int n)
 Returns the nth DisplayRegion of those that have been created within the window. More...
 
list getDisplayRegions ()
 
GraphicsEngine getEngine ()
 Returns the graphics engine that created this output. More...
 
const FrameBufferProperties getFbProperties ()
 Returns the framebuffer properties of the window. More...
 
LVecBase2i getFbSize ()
 Returns the internal size of the window or buffer. More...
 
int getFbXSize ()
 Returns the internal width of the window or buffer. More...
 
int getFbYSize ()
 Returns the internal height of the window or buffer. More...
 
GraphicsStateGuardian getGsg ()
 Returns the GSG that is associated with this window. More...
 
GraphicsOutput getHost ()
 This is normally called only from within make_texture_buffer(). More...
 
bool getInverted ()
 Returns the current setting of the inverted flag. More...
 
unsigned int getLeftEyeColorMask ()
 Returns the color mask in effect when rendering a left-eye view in red_blue stereo mode. More...
 
str getName ()
 Returns the name that was passed to the GraphicsOutput constructor. More...
 
int getNumActiveDisplayRegions ()
 Returns the number of active DisplayRegions that have been created within the window. More...
 
int getNumDisplayRegions ()
 Returns the number of DisplayRegions that have been created within the window, active or otherwise. More...
 
bool getOneShot ()
 Returns the current setting of the one-shot flag. More...
 
DisplayRegion getOverlayDisplayRegion ()
 Returns the special "overlay" DisplayRegion that is created for each window or buffer. More...
 
GraphicsPipe getPipe ()
 Returns the GraphicsPipe that this window is associated with. More...
 
bool getRedBlueStereo ()
 Returns whether red-blue stereo mode is in effect for this particular window. More...
 
unsigned int getRightEyeColorMask ()
 Returns the color mask in effect when rendering a right-eye view in red_blue stereo mode. More...
 
GraphicsOutput::RenderTextureMode getRtmMode (int i)
 Returns the RenderTextureMode associated with the nth render-texture. More...
 
const LVecBase4 getSbsLeftDimensions ()
 Returns the effective sub-region of the window for displaying the left channel, if side-by-side stereo mode is in effect for the window. More...
 
LVecBase2i getSbsLeftSize ()
 If side-by-side stereo is enabled, this returns the pixel size of the left eye, based on scaling get_size() by get_sbs_left_dimensions(). More...
 
int getSbsLeftXSize ()
 If side-by-side stereo is enabled, this returns the pixel width of the left eye, based on scaling get_x_size() by get_sbs_left_dimensions(). More...
 
int getSbsLeftYSize ()
 If side-by-side stereo is enabled, this returns the pixel height of the left eye, based on scaling get_y_size() by get_sbs_left_dimensions(). More...
 
const LVecBase4 getSbsRightDimensions ()
 Returns the effective sub-region of the window for displaying the right channel, if side-by-side stereo mode is in effect for the window. More...
 
LVecBase2i getSbsRightSize ()
 If side-by-side stereo is enabled, this returns the pixel size of the right eye, based on scaling get_size() by get_sbs_right_dimensions(). More...
 
int getSbsRightXSize ()
 If side-by-side stereo is enabled, this returns the pixel width of the right eye, based on scaling get_x_size() by get_sbs_right_dimensions(). More...
 
int getSbsRightYSize ()
 If side-by-side stereo is enabled, this returns the pixel height of the right eye, based on scaling get_y_size() by get_sbs_right_dimensions(). More...
 
Texture getScreenshot ()
 Captures the most-recently rendered image from the framebuffer and returns it as Texture, or NULL on failure. More...
 
bool getScreenshot (PNMImage image)
 Captures the most-recently rendered image from the framebuffer into the indicated PNMImage. More...
 
bool getSideBySideStereo ()
 Returns whether side-by-side stereo mode is in effect for this particular window. More...
 
const LVecBase2i getSize ()
 Returns the visible size of the window or buffer, if it is known. More...
 
int getSort ()
 Returns the sorting order of this particular GraphicsOutput. More...
 
bool getSupportsRenderTexture ()
 Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect. More...
 
bool getSwapEyes ()
 Returns the current setting of the "swap eyes" flag. More...
 
Texture getTexture (int i)
 Returns the nth texture into which the GraphicsOutput renders. More...
 
NodePath getTextureCard ()
 Returns a PandaNode containing a square polygon. More...
 
DrawableRegion::RenderTexturePlane getTexturePlane (int i)
 Returns the RenderTexturePlane associated with the nth render-texture. More...
 
int getXSize ()
 Returns the visible width of the window or buffer, if it is known. More...
 
int getYSize ()
 Returns the visible height of the window or buffer, if it is known. More...
 
bool hasSize ()
 Returns true if the size of the window/frame buffer is known, false otherwise. More...
 
bool hasTexture ()
 Returns true if the GraphicsOutput is rendering into any textures at all. More...
 
bool isActive ()
 Returns true if the window is ready to be rendered into, false otherwise. More...
 
bool isNonzeroSize ()
 Returns true if the output has a nonzero size in both X and Y, or false if it is zero (and therefore invalid). More...
 
bool isStereo ()
 Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo (see set_red_blue_stereo()) or through true hardware stereo rendering. More...
 
bool isValid ()
 Returns true if the output is fully created and ready for rendering, false otherwise. More...
 
GraphicsOutput makeCubeMap (str name, int size, NodePath camera_rig, DrawMask camera_mask, bool to_ram, FrameBufferProperties fbp)
 This is similar to make_texture_buffer() in that it allocates a separate buffer suitable for rendering to a texture that can be assigned to geometry in this window, but in this case, the buffer is set up to render the six faces of a cube map. More...
 
DisplayRegion makeDisplayRegion ()
 Creates a new DisplayRegion that covers the entire window. More...
 
DisplayRegion makeDisplayRegion (const LVecBase4 dimensions)
 Creates a new DisplayRegion that covers the indicated sub-rectangle within the window. More...
 
DisplayRegion makeDisplayRegion (float l, float r, float b, float t)
 Creates a new DisplayRegion that covers the indicated sub-rectangle within the window. More...
 
DisplayRegion makeMonoDisplayRegion ()
 Creates a new DisplayRegion that covers the entire window. More...
 
DisplayRegion makeMonoDisplayRegion (const LVecBase4 dimensions)
 Creates a new DisplayRegion that covers the indicated sub-rectangle within the window. More...
 
DisplayRegion makeMonoDisplayRegion (float l, float r, float b, float t)
 Creates a new DisplayRegion that covers the entire window. More...
 
StereoDisplayRegion makeStereoDisplayRegion ()
 Creates a new DisplayRegion that covers the entire window. More...
 
StereoDisplayRegion makeStereoDisplayRegion (const LVecBase4 dimensions)
 Creates a new DisplayRegion that covers the indicated sub-rectangle within the window. More...
 
StereoDisplayRegion makeStereoDisplayRegion (float l, float r, float b, float t)
 Creates a new DisplayRegion that covers the entire window. More...
 
GraphicsOutput makeTextureBuffer (str name, int x_size, int y_size, Texture tex, bool to_ram, FrameBufferProperties fbp)
 Creates and returns an offscreen buffer for rendering into, the result of which will be a texture suitable for applying to geometry within the scene rendered into this window. More...
 
 removeAllDisplayRegions ()
 Removes all display regions from the window, except the default one that is created with the window. More...
 
bool removeDisplayRegion (DisplayRegion display_region)
 Removes the indicated DisplayRegion from the window, and destructs it if there are no other references. More...
 
bool saveScreenshot (const Filename filename, str image_comment)
 Saves a screenshot of the region to the indicated filename. More...
 
Filename saveScreenshotDefault (str prefix)
 Saves a screenshot of the region to a default filename, and returns the filename, or empty string if the screenshot failed. More...
 
 setActive (bool active)
 Sets the active flag associated with the GraphicsOutput. More...
 
 setChildSort (int child_sort)
 Specifies the sort value of future offscreen buffers created by make_texture_sort(). More...
 
 setInverted (bool inverted)
 Changes the current setting of the inverted flag. More...
 
 setOneShot (bool one_shot)
 Changes the current setting of the one-shot flag. More...
 
 setOverlayDisplayRegion (DisplayRegion display_region)
 Replaces the special "overlay" DisplayRegion that is created for each window or buffer. More...
 
 setRedBlueStereo (bool red_blue_stereo, unsigned int left_eye_color_mask, unsigned int right_eye_color_mask)
 Enables red-blue stereo mode on this particular window. More...
 
 setSideBySideStereo (bool side_by_side_stereo)
 Enables side-by-side stereo mode on this particular window. More...
 
 setSideBySideStereo (bool side_by_side_stereo, const LVecBase4 sbs_left_dimensions, const LVecBase4 sbs_right_dimensions)
 Enables side-by-side stereo mode on this particular window. More...
 
 setSort (int sort)
 Adjusts the sorting order of this particular GraphicsOutput, relative to other GraphicsOutputs. More...
 
 setSwapEyes (bool swap_eyes)
 Changes the "swap eyes" flag. More...
 
 setupRenderTexture (Texture tex, bool allow_bind, bool to_ram)
 This is a deprecated interface that made sense back when GraphicsOutputs could only render into one texture at a time. More...
 
bool shareDepthBuffer (GraphicsOutput graphics_output)
 Will attempt to use the depth buffer of the input graphics_output. More...
 
AsyncFuture triggerCopy ()
 When the GraphicsOutput is in triggered copy mode, this function triggers the copy (at the end of the next frame). More...
 
 unshareDepthBuffer ()
 Discontinue sharing the depth buffer. More...
 
- Public Member Functions inherited from GraphicsOutputBase
Texture getTexture (int i)
 
 setSort (int sort)
 
- Public Member Functions inherited from TypedWritable
object __reduce__ ()
 
object __reduce_persist__ (object pickler)
 
VectorUchar encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encodeToBamStream (VectorUchar data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
 fillin (DatagramIterator scan, BamReader manager)
 This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object. More...
 
UpdateSeq getBamModified ()
 Returns the current bam_modified counter. More...
 
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 
- Public Member Functions inherited from DrawableRegion
 disableClears ()
 Disables both the color and depth clear. More...
 
bool getClearActive (int n)
 Gets the clear-active flag for any bitplane. More...
 
const LColor getClearColor ()
 Returns the current clear color value. More...
 
bool getClearColorActive ()
 Returns the current setting of the flag that indicates whether the color buffer should be cleared every frame. More...
 
float getClearDepth ()
 Returns the current clear depth value. More...
 
bool getClearDepthActive ()
 Returns the current setting of the flag that indicates whether the depth buffer should be cleared every frame. More...
 
unsigned int getClearStencil ()
 Returns the current clear stencil value. More...
 
bool getClearStencilActive ()
 Returns the current setting of the flag that indicates whether the color buffer should be cleared every frame. More...
 
const LColor getClearValue (int n)
 Returns the clear value for any bitplane. More...
 
float getPixelFactor ()
 Returns the amount by which the height and width of the region will be scaled internally, based on the zoom factor set by set_pixel_zoom(). More...
 
float getPixelZoom ()
 Returns the value set by set_pixel_zoom(), regardless of whether it is being respected or not. More...
 
bool isAnyClearActive ()
 Returns true if any of the clear types (so far there are just color or depth) have been set active, or false if none of them are active and there is no need to clear. More...
 
 setClearActive (int n, bool clear_aux_active)
 Sets the clear-active flag for any bitplane. More...
 
 setClearColor (const LColor color)
 Sets the clear color to the indicated value. More...
 
 setClearColorActive (bool clear_color_active)
 Toggles the flag that indicates whether the color buffer should be cleared every frame. More...
 
 setClearDepth (float depth)
 Sets the clear depth to the indicated value. More...
 
 setClearDepthActive (bool clear_depth_active)
 Toggles the flag that indicates whether the depth buffer should be cleared every frame. More...
 
 setClearStencil (unsigned int stencil)
 
 setClearStencilActive (bool clear_stencil_active)
 Toggles the flag that indicates whether the stencil buffer should be cleared every frame. More...
 
 setClearValue (int n, const LColor clear_value)
 Sets the clear value for any bitplane. More...
 
 setPixelZoom (float pixel_zoom)
 Sets the amount by which the pixels of the region are scaled internally when filling the image interally. More...
 
bool supportsPixelZoom ()
 Returns true if a call to set_pixel_zoom() will be respected, false if it will be ignored. More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static Filename makeScreenshotFilename (str prefix)
 Saves a screenshot of the region to a default filename, and returns the filename, or empty string if the screenshot failed. More...
 
- Static Public Member Functions inherited from GraphicsOutputBase
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypedWritableReferenceCount decodeFromBamStream (VectorUchar data, BamReader reader)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on those bytes. More...
 
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritable
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from DrawableRegion
static int getRenderbufferType (int plane)
 Returns the RenderBuffer::Type that corresponds to a RenderTexturePlane. More...
 

Public Attributes

bool active
 Returns true if the window is ready to be rendered into, false otherwise. More...
 
PointerToDisplayRegion active_display_regions []
 
int child_sort
 Returns the sort value of future offscreen buffers created by make_texture_sort(). More...
 
PointerToDisplayRegion display_regions []
 
GraphicsEngine engine
 Returns the graphics engine that created this output. More...
 
LVecBase2i fb_size
 Returns the internal size of the window or buffer. More...
 
GraphicsStateGuardian gsg
 Returns the GSG that is associated with this window. More...
 
bool inverted
 Returns the current setting of the inverted flag. More...
 
const String name
 Returns the name that was passed to the GraphicsOutput constructor. More...
 
bool one_shot
 Returns the current setting of the one-shot flag. More...
 
GraphicsPipe pipe
 Returns the GraphicsPipe that this window is associated with. More...
 
LVecBase2i sbs_left_size
 If side-by-side stereo is enabled, this returns the pixel size of the left eye, based on scaling get_size() by get_sbs_left_dimensions(). More...
 
LVecBase2i sbs_right_size
 If side-by-side stereo is enabled, this returns the pixel size of the right eye, based on scaling get_size() by get_sbs_right_dimensions(). More...
 
const LVecBase2i size
 Returns the visible size of the window or buffer, if it is known. More...
 
int sort
 Returns the sorting order of this particular GraphicsOutput. More...
 
bool supports_render_texture
 Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect. More...
 
bool swap_eyes
 Returns the current setting of the "swap eyes" flag. More...
 
- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 
- Public Attributes inherited from DrawableRegion
const LColor clear_color
 Returns the current clear color value. More...
 
float clear_depth
 Returns the current clear depth value. More...
 
unsigned int clear_stencil
 Returns the current clear stencil value. More...
 
float pixel_factor
 Returns the amount by which the height and width of the region will be scaled internally, based on the zoom factor set by set_pixel_zoom(). More...
 
float pixel_zoom
 Returns the value set by set_pixel_zoom(), regardless of whether it is being respected or not. More...
 

Detailed Description

This is a base class for the various different classes that represent the result of a frame of rendering.

The most common kind of GraphicsOutput is a GraphicsWindow, which is a real-time window on the desktop, but another example is GraphicsBuffer, which is an offscreen buffer.

The actual rendering, and anything associated with the graphics context itself, is managed by the associated GraphicsStateGuardian (which might output to multiple GraphicsOutput objects).

GraphicsOutputs are not actually writable to bam files, of course, but they may be passed as event parameters, so they inherit from TypedWritableReferenceCount instead of TypedReferenceCount for that convenience.

Member Enumeration Documentation

◆ FrameMode

enum FrameMode
Enumerator
FM_render 

We are rendering a frame.

FM_parasite 

We are rendering a frame of a parasite.

FM_refresh 

We are just refreshing the display or exposing the window.

◆ RenderTextureMode

Enumerator
RTM_none 
RTM_bind_or_copy 

Try to render to the texture directly, but if that is not possible, fall back to RTM_copy_texture.

RTM_copy_texture 

Copy the image from the buffer to the texture every frame.

RTM_copy_ram 

Copy the image from the buffer to system RAM every frame.

RTM_triggered_copy_texture 

Copy the image from the buffer to the texture after a call to trigger_copy().

RTM_triggered_copy_ram 

Copy the image from the buffer to system RAM after a call to trigger_copy().

RTM_bind_layered 

Render directly to a layered texture, such as a cube map, 3D texture or 2D texture array. The layer that is being rendered to is selected by a geometry shader.

Member Function Documentation

◆ addRenderTexture()

addRenderTexture ( Texture  tex,
GraphicsOutput::RenderTextureMode  mode,
DrawableRegion::RenderTexturePlane  bitplane 
)

Creates a new Texture object, suitable for rendering the contents of this buffer into, and appends it to the list of render textures.

If tex is not NULL, it is the texture that will be set up for rendering into; otherwise, a new Texture object will be created, in which case you may call get_texture() to retrieve the new texture pointer.

You can specify a bitplane to attach the texture to. the legal choices are:

  • RTP_depth
  • RTP_depth_stencil
  • RTP_color
  • RTP_aux_rgba_0
  • RTP_aux_rgba_1
  • RTP_aux_rgba_2
  • RTP_aux_rgba_3

If you do not specify a bitplane to attach the texture to, this routine will use a default based on the texture's format:

  • F_depth_component attaches to RTP_depth
  • F_depth_stencil attaches to RTP_depth_stencil
  • all other formats attach to RTP_color.

The texture's format will be changed to match the format of the bitplane to which it is attached. For example, if you pass in an F_rgba texture and order that it be attached to RTP_depth_stencil, it will turn into an F_depth_stencil texture.

Also see make_texture_buffer(), which is a higher-level interface for preparing render-to-a-texture mode.

◆ clearChildSort()

clearChildSort ( )

Resets the sort value of future offscreen buffers created by make_texture_sort() to the default value.

See set_child_sort().

◆ clearDeleteFlag()

clearDeleteFlag ( )

Resets the delete flag, so the GraphicsOutput will not be automatically deleted before the beginning of the next frame.

◆ clearRenderTextures()

clearRenderTextures ( )

If the GraphicsOutput is currently rendering to a texture, then all textures are dissociated from the GraphicsOuput.

◆ countTextures()

int countTextures ( )

If the GraphicsOutput is set to render into a texture, returns the number of textures that are being rendered into.

Normally, the textures would be associated with different buffers - a color texture, a depth texture, and a stencil texture.

◆ flipReady()

bool flipReady ( )

◆ getActiveDisplayRegion()

DisplayRegion getActiveDisplayRegion ( int  n)

Returns the nth active DisplayRegion of those that have been created within the window.

This may return NULL if n is out of bounds; particularly likely if the number of display regions has changed since the last call to get_num_active_display_regions().

◆ getActiveDisplayRegions()

list getActiveDisplayRegions ( )

◆ getChildSort()

int getChildSort ( )

Returns the sort value of future offscreen buffers created by make_texture_sort().

See set_child_sort().

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getDeleteFlag()

bool getDeleteFlag ( )

Returns the current setting of the delete flag.

When this is true, the GraphicsOutput will automatically be removed before the beginning of the next frame by the GraphicsEngine.

◆ getDisplayRegion()

DisplayRegion getDisplayRegion ( int  n)

Returns the nth DisplayRegion of those that have been created within the window.

This may return NULL if n is out of bounds; particularly likely if the number of display regions has changed since the last call to get_num_display_regions().

◆ getDisplayRegions()

list getDisplayRegions ( )

◆ getEngine()

GraphicsEngine getEngine ( )

Returns the graphics engine that created this output.

Since there is normally only one GraphicsEngine object in an application, this is usually the same as the global GraphicsEngine.

◆ getFbProperties()

const FrameBufferProperties getFbProperties ( )

Returns the framebuffer properties of the window.

◆ getFbSize()

LVecBase2i getFbSize ( )

Returns the internal size of the window or buffer.

This is almost always the same as get_size(), except when a pixel_zoom is in effect–see set_pixel_zoom().

◆ getFbXSize()

int getFbXSize ( )

Returns the internal width of the window or buffer.

This is almost always the same as get_x_size(), except when a pixel_zoom is in effect–see set_pixel_zoom().

◆ getFbYSize()

int getFbYSize ( )

Returns the internal height of the window or buffer.

This is almost always the same as get_y_size(), except when a pixel_zoom is in effect–see set_pixel_zoom().

◆ getGsg()

Returns the GSG that is associated with this window.

There is a one-to-one association between windows and GSG's.

This may return NULL if the graphics context has not yet been created for the window, e.g. before the first frame has rendered; or after the window has been closed.

◆ getHost()

GraphicsOutput getHost ( )

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.

◆ getInverted()

bool getInverted ( )

Returns the current setting of the inverted flag.

When this is true, the scene is rendered into the window upside-down, flipped like a mirror along the X axis. See set_inverted().

◆ getLeftEyeColorMask()

unsigned int getLeftEyeColorMask ( )

Returns the color mask in effect when rendering a left-eye view in red_blue stereo mode.

This is one or more bits defined in ColorWriteAttrib::Channels. See set_red_blue_stereo().

◆ getName()

str getName ( )

Returns the name that was passed to the GraphicsOutput constructor.

◆ getNumActiveDisplayRegions()

int getNumActiveDisplayRegions ( )

Returns the number of active DisplayRegions that have been created within the window.

◆ getNumDisplayRegions()

int getNumDisplayRegions ( )

Returns the number of DisplayRegions that have been created within the window, active or otherwise.

◆ getOneShot()

bool getOneShot ( )

Returns the current setting of the one-shot flag.

When this is true, the GraphicsOutput will automatically set itself inactive after the next frame.

◆ getOverlayDisplayRegion()

DisplayRegion getOverlayDisplayRegion ( )

Returns the special "overlay" DisplayRegion that is created for each window or buffer.

This DisplayRegion covers the entire window, but cannot be used for rendering. It is a placeholder only, to indicate the dimensions of the window, and is usually used internally for purposes such as clearing the window, or grabbing a screenshot of the window.

There are very few applications that require access to this DisplayRegion. Normally, you should create your own DisplayRegion that covers the window, if you want to render to the window.

◆ getPipe()

GraphicsPipe getPipe ( )

Returns the GraphicsPipe that this window is associated with.

It is possible that the GraphicsPipe might have been deleted while an outstanding PT(GraphicsOutput) prevented all of its children windows from also being deleted; in this unlikely case, get_pipe() may return NULL.

◆ getRedBlueStereo()

bool getRedBlueStereo ( )

Returns whether red-blue stereo mode is in effect for this particular window.

See set_red_blue_stereo().

◆ getRightEyeColorMask()

unsigned int getRightEyeColorMask ( )

Returns the color mask in effect when rendering a right-eye view in red_blue stereo mode.

This is one or more bits defined in ColorWriteAttrib::Channels. See set_red_blue_stereo().

◆ getRtmMode()

GraphicsOutput::RenderTextureMode getRtmMode ( int  i)

Returns the RenderTextureMode associated with the nth render-texture.

Returns RTM_none if there is no such texture.

◆ getSbsLeftDimensions()

const LVecBase4 getSbsLeftDimensions ( )

Returns the effective sub-region of the window for displaying the left channel, if side-by-side stereo mode is in effect for the window.

See set_side_by_side_stereo().

◆ getSbsLeftSize()

LVecBase2i getSbsLeftSize ( )

If side-by-side stereo is enabled, this returns the pixel size of the left eye, based on scaling get_size() by get_sbs_left_dimensions().

If side-by- side stereo is not enabled, this returns the same as get_size().

◆ getSbsLeftXSize()

int getSbsLeftXSize ( )

If side-by-side stereo is enabled, this returns the pixel width of the left eye, based on scaling get_x_size() by get_sbs_left_dimensions().

If side- by-side stereo is not enabled, this returns the same as get_x_size().

◆ getSbsLeftYSize()

int getSbsLeftYSize ( )

If side-by-side stereo is enabled, this returns the pixel height of the left eye, based on scaling get_y_size() by get_sbs_left_dimensions().

If side-by-side stereo is not enabled, this returns the same as get_y_size().

◆ getSbsRightDimensions()

const LVecBase4 getSbsRightDimensions ( )

Returns the effective sub-region of the window for displaying the right channel, if side-by-side stereo mode is in effect for the window.

See set_side_by_side_stereo().

◆ getSbsRightSize()

LVecBase2i getSbsRightSize ( )

If side-by-side stereo is enabled, this returns the pixel size of the right eye, based on scaling get_size() by get_sbs_right_dimensions().

If side- by-side stereo is not enabled, this returns the same as get_size().

◆ getSbsRightXSize()

int getSbsRightXSize ( )

If side-by-side stereo is enabled, this returns the pixel width of the right eye, based on scaling get_x_size() by get_sbs_right_dimensions().

If side-by-side stereo is not enabled, this returns the same as get_x_size().

◆ getSbsRightYSize()

int getSbsRightYSize ( )

If side-by-side stereo is enabled, this returns the pixel height of the right eye, based on scaling get_y_size() by get_sbs_right_dimensions().

If side-by-side stereo is not enabled, this returns the same as get_y_size().

◆ getScreenshot() [1/2]

Texture getScreenshot ( )

Captures the most-recently rendered image from the framebuffer and returns it as Texture, or NULL on failure.

◆ getScreenshot() [2/2]

bool getScreenshot ( PNMImage  image)

Captures the most-recently rendered image from the framebuffer into the indicated PNMImage.

Returns true on success, false on failure.

◆ getSideBySideStereo()

bool getSideBySideStereo ( )

Returns whether side-by-side stereo mode is in effect for this particular window.

See set_side_by_side_stereo().

◆ getSize()

const LVecBase2i getSize ( )

Returns the visible size of the window or buffer, if it is known.

In certain cases (e.g. fullscreen windows), the size may not be known until after the object has been fully created. Check has_size() first.

Certain objects (like windows) may change size spontaneously; this method is not thread-safe. To get the size of a window in a thread-safe manner, query get_properties().

◆ getSort()

int getSort ( )

Returns the sorting order of this particular GraphicsOutput.

The various GraphicsOutputs within a particular thread will be rendered in the indicated order.

◆ getSupportsRenderTexture()

bool getSupportsRenderTexture ( )

Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.

◆ getSwapEyes()

bool getSwapEyes ( )

Returns the current setting of the "swap eyes" flag.

See set_swap_eyes().

◆ getTexture()

Texture getTexture ( int  i)

Returns the nth texture into which the GraphicsOutput renders.

Returns NULL if there is no such texture.

If the texture is non-NULL, it may be applied to geometry to be rendered for any other windows or outputs that share the same GSG as this GraphicsOutput. The effect is undefined for windows that share a different GSG; usually in these cases the texture will be invalid.

◆ getTextureCard()

NodePath getTextureCard ( )

Returns a PandaNode containing a square polygon.

The dimensions are (-1,0,-1) to (1,0,1). The texture coordinates are such that the texture of this GraphicsOutput is aligned properly to the polygon. The GraphicsOutput promises to surgically update the Geom inside the PandaNode if necessary to maintain this invariant.

Each invocation of this function returns a freshly- allocated PandaNode. You can therefore safely modify the RenderAttribs of the PandaNode. The PandaNode is initially textured with the texture of this GraphicOutput.

◆ getTexturePlane()

DrawableRegion::RenderTexturePlane getTexturePlane ( int  i)

Returns the RenderTexturePlane associated with the nth render-texture.

Returns 0 if there is no such texture.

◆ getXSize()

int getXSize ( )

Returns the visible width of the window or buffer, if it is known.

In certain cases (e.g. fullscreen windows), the size may not be known until after the object has been fully created. Check has_size() first.

Certain objects (like windows) may change size spontaneously; this method is not thread-safe. To get the size of a window in a thread-safe manner, query get_properties().

◆ getYSize()

int getYSize ( )

Returns the visible height of the window or buffer, if it is known.

In certain cases (e.g. fullscreen windows), the size may not be known until after the object has been fully created. Check has_size() first.

Certain objects (like windows) may change size spontaneously; this method is not thread-safe. To get the size of a window in a thread-safe manner, query get_properties().

◆ hasSize()

bool hasSize ( )

Returns true if the size of the window/frame buffer is known, false otherwise.

In certain cases the size may not be known until after the object has been fully created. Also, certain objects (like windows) may change size spontaneously.

◆ hasTexture()

bool hasTexture ( )

Returns true if the GraphicsOutput is rendering into any textures at all.

◆ isActive()

bool isActive ( )

Returns true if the window is ready to be rendered into, false otherwise.

◆ isNonzeroSize()

bool isNonzeroSize ( )

Returns true if the output has a nonzero size in both X and Y, or false if it is zero (and therefore invalid).

◆ isStereo()

bool isStereo ( )

Returns Returns true if this window can render stereo DisplayRegions, either through red-blue stereo (see set_red_blue_stereo()) or through true hardware stereo rendering.

◆ isValid()

bool isValid ( )

Returns true if the output is fully created and ready for rendering, false otherwise.

◆ makeCubeMap()

GraphicsOutput makeCubeMap ( str  name,
int  size,
NodePath  camera_rig,
DrawMask  camera_mask,
bool  to_ram,
FrameBufferProperties  fbp 
)

This is similar to make_texture_buffer() in that it allocates a separate buffer suitable for rendering to a texture that can be assigned to geometry in this window, but in this case, the buffer is set up to render the six faces of a cube map.

The buffer is automatically set up with six display regions and six cameras, each of which are assigned the indicated draw_mask and parented to the given camera_rig node (which you should then put in your scene to render the cube map from the appropriate point of view).

You may take the texture associated with the buffer and apply it to geometry, particularly with TexGenAttrib::M_world_cube_map also in effect, to apply a reflection of everything seen by the camera rig.

◆ makeDisplayRegion() [1/3]

DisplayRegion makeDisplayRegion ( )

Creates a new DisplayRegion that covers the entire window.

If is_stereo() is true for this window, and default-stereo-camera is configured true, this actually makes a StereoDisplayRegion. Call make_mono_display_region() or make_stereo_display_region() if you want to insist on one or the other.

◆ makeDisplayRegion() [2/3]

DisplayRegion makeDisplayRegion ( const LVecBase4  dimensions)

Creates a new DisplayRegion that covers the indicated sub-rectangle within the window.

The range on all parameters is 0..1.

If is_stereo() is true for this window, and default-stereo-camera is configured true, this actually makes a StereoDisplayRegion. Call make_mono_display_region() or make_stereo_display_region() if you want to insist on one or the other.

◆ makeDisplayRegion() [3/3]

DisplayRegion makeDisplayRegion ( float  l,
float  r,
float  b,
float  t 
)

Creates a new DisplayRegion that covers the indicated sub-rectangle within the window.

The range on all parameters is 0..1.

If is_stereo() is true for this window, and default-stereo-camera is configured true, this actually makes a StereoDisplayRegion. Call make_mono_display_region() or make_stereo_display_region() if you want to insist on one or the other.

◆ makeMonoDisplayRegion() [1/3]

DisplayRegion makeMonoDisplayRegion ( )

Creates a new DisplayRegion that covers the entire window.

This generally returns a mono DisplayRegion, even if is_stereo() is true. However, if side-by-side stereo is enabled, this will return a StereoDisplayRegion whose two eyes are both set to SC_mono. (This is necessary because in side-by-side stereo mode, it is necessary to draw even mono DisplayRegions twice).

◆ makeMonoDisplayRegion() [2/3]

DisplayRegion makeMonoDisplayRegion ( const LVecBase4  dimensions)

Creates a new DisplayRegion that covers the indicated sub-rectangle within the window.

The range on all parameters is 0..1.

This generally returns a mono DisplayRegion, even if is_stereo() is true. However, if side-by-side stereo is enabled, this will return a StereoDisplayRegion whose two eyes are both set to SC_mono. (This is necessary because in side-by-side stereo mode, it is necessary to draw even mono DisplayRegions twice).

◆ makeMonoDisplayRegion() [3/3]

DisplayRegion makeMonoDisplayRegion ( float  l,
float  r,
float  b,
float  t 
)

Creates a new DisplayRegion that covers the entire window.

This generally returns a mono DisplayRegion, even if is_stereo() is true. However, if side-by-side stereo is enabled, this will return a StereoDisplayRegion whose two eyes are both set to SC_mono. (This is necessary because in side-by-side stereo mode, it is necessary to draw even mono DisplayRegions twice).

◆ makeScreenshotFilename()

static Filename makeScreenshotFilename ( str  prefix)
static

Saves a screenshot of the region to a default filename, and returns the filename, or empty string if the screenshot failed.

The default filename is generated from the supplied prefix and from the Config variable screenshot-filename, which contains the following strings:

%~p - the supplied prefix %~f - the frame count %~e - the value of screenshot-extension All other % strings in strftime().

◆ makeStereoDisplayRegion() [1/3]

StereoDisplayRegion makeStereoDisplayRegion ( )

Creates a new DisplayRegion that covers the entire window.

This always returns a stereo DisplayRegion, even if is_stereo() is false.

◆ makeStereoDisplayRegion() [2/3]

StereoDisplayRegion makeStereoDisplayRegion ( const LVecBase4  dimensions)

Creates a new DisplayRegion that covers the indicated sub-rectangle within the window.

The range on all parameters is 0..1.

This always returns a stereo DisplayRegion, even if is_stereo() is false.

◆ makeStereoDisplayRegion() [3/3]

StereoDisplayRegion makeStereoDisplayRegion ( float  l,
float  r,
float  b,
float  t 
)

Creates a new DisplayRegion that covers the entire window.

This always returns a stereo DisplayRegion, even if is_stereo() is false.

◆ makeTextureBuffer()

GraphicsOutput makeTextureBuffer ( str  name,
int  x_size,
int  y_size,
Texture  tex,
bool  to_ram,
FrameBufferProperties  fbp 
)

Creates and returns an offscreen buffer for rendering into, the result of which will be a texture suitable for applying to geometry within the scene rendered into this window.

If tex is not NULL, it is the texture that will be set up for rendering into; otherwise, a new Texture object will be created. In either case, the target texture can be retrieved from the return value with buffer->get_texture() (assuming the return value is not NULL).

If to_ram is true, the buffer will be set up to download its contents to the system RAM memory associated with the Texture object, instead of keeping it strictly within texture memory; this is much slower, but it allows using the texture with any GSG.

This will attempt to be smart about maximizing render performance while minimizing framebuffer waste. It might return a GraphicsBuffer set to render directly into a texture, if possible; or it might return a ParasiteBuffer that renders into this window. The return value is NULL if the buffer could not be created for some reason.

When you are done using the buffer, you should remove it with a call to GraphicsEngine::remove_window().

◆ removeAllDisplayRegions()

removeAllDisplayRegions ( )

Removes all display regions from the window, except the default one that is created with the window.

◆ removeDisplayRegion()

bool removeDisplayRegion ( DisplayRegion  display_region)

Removes the indicated DisplayRegion from the window, and destructs it if there are no other references.

Returns true if the DisplayRegion is found and removed, false if it was not a part of the window.

◆ saveScreenshot()

bool saveScreenshot ( const Filename  filename,
str  image_comment 
)

Saves a screenshot of the region to the indicated filename.

The image comment is an optional user readable string that will be saved with the header of the image (if the file format supports embedded data; for example jpg allows comments). Returns true on success, false on failure.

◆ saveScreenshotDefault()

Filename saveScreenshotDefault ( str  prefix)

Saves a screenshot of the region to a default filename, and returns the filename, or empty string if the screenshot failed.

The filename is generated by make_screenshot_filename().

◆ setActive()

setActive ( bool  active)

Sets the active flag associated with the GraphicsOutput.

If the GraphicsOutput is marked inactive, nothing is rendered.

◆ setChildSort()

setChildSort ( int  child_sort)

Specifies the sort value of future offscreen buffers created by make_texture_sort().

The purpose of this method is to allow the user to limit the sort value chosen for a buffer created via make_texture_buffer(). Normally, this buffer will be assigned a value of get_sort() - 1, so that it will be rendered before this window is rendered; but sometimes this isn't sufficiently early, especially if other buffers also have a view into the same scene.

If you specify a value here, then new buffers created via make_texture_buffer() will be given that sort value instead of get_sort() - 1.

◆ setInverted()

setInverted ( bool  inverted)

Changes the current setting of the inverted flag.

When this is true, the scene is rendered into the window upside-down and backwards, that is, inverted as if viewed through a mirror placed on the floor.

This is primarily intended to support DirectX (and a few buggy OpenGL graphics drivers) that perform a framebuffer-to-texture copy upside-down from the usual OpenGL (and Panda) convention. Panda will automatically set this flag for offscreen buffers on hardware that is known to do this, to compensate when rendering offscreen into a texture.

◆ setOneShot()

setOneShot ( bool  one_shot)

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.)

◆ setOverlayDisplayRegion()

setOverlayDisplayRegion ( DisplayRegion  display_region)

Replaces the special "overlay" DisplayRegion that is created for each window or buffer.

See get_overlay_display_region(). This must be a new DisplayRegion that has already been created for this window, for instance via a call to make_mono_display_region(). You are responsible for ensuring that the new DisplayRegion covers the entire window. The previous overlay display region is not automatically removed; you must explicitly call remove_display_region() on it after replacing it with this method, if you wish it to be removed.

Normally, there is no reason to change the overlay DisplayRegion, so this method should be used only in very unusual circumstances.

◆ setRedBlueStereo()

setRedBlueStereo ( bool  red_blue_stereo,
unsigned int  left_eye_color_mask,
unsigned int  right_eye_color_mask 
)

Enables red-blue stereo mode on this particular window.

When red-blue stereo mode is in effect, DisplayRegions that have the "left" channel set will render in the red (or specified) channel only, while DisplayRegions that have the "right" channel set will render in the blue (or specified) channel only.

The remaining two parameters specify the particular color channel(s) to associate with each eye. Use the bits defined in ColorWriteAttrib::Channels.

This can be used to achieve a cheesy stereo mode in the absence of hardware-supported stereo.

◆ setSideBySideStereo() [1/2]

setSideBySideStereo ( bool  side_by_side_stereo)

Enables side-by-side stereo mode on this particular window.

When side-by- side stereo mode is in effect, DisplayRegions that have the "left" channel set will render on the part of the window specified by sbs_left_dimensions (typically the left half: (0, 0.5, 0, 1)), while DisplayRegions that have the "right" channel set will render on the part of the window specified by sbs_right_dimensions (typically the right half: (0.5, 1, 0, 1)).

This is commonly used in a dual-monitor mode, where a window is opened that spans two monitors, and each monitor represents a different eye.

◆ setSideBySideStereo() [2/2]

setSideBySideStereo ( bool  side_by_side_stereo,
const LVecBase4  sbs_left_dimensions,
const LVecBase4  sbs_right_dimensions 
)

Enables side-by-side stereo mode on this particular window.

When side-by- side stereo mode is in effect, DisplayRegions that have the "left" channel set will render on the part of the window specified by sbs_left_dimensions (typically the left half: (0, 0.5, 0, 1)), while DisplayRegions that have the "right" channel set will render on the part of the window specified by sbs_right_dimensions (typically the right half: (0.5, 1, 0, 1)).

This is commonly used in a dual-monitor mode, where a window is opened that spans two monitors, and each monitor represents a different eye.

◆ setSort()

setSort ( int  sort)

Adjusts the sorting order of this particular GraphicsOutput, relative to other GraphicsOutputs.

◆ setSwapEyes()

setSwapEyes ( bool  swap_eyes)

Changes the "swap eyes" flag.

This flag is normally false. When it is true, the left and right channels of a stereo DisplayRegion are sent to the opposite channels in the rendering backend. This is meant to work around hardware that inadvertently swaps the output channels, or hardware for which it cannot be determined which channel is which until runtime.

◆ setupRenderTexture()

setupRenderTexture ( Texture  tex,
bool  allow_bind,
bool  to_ram 
)

This is a deprecated interface that made sense back when GraphicsOutputs could only render into one texture at a time.

From now on, use clear_render_textures and add_render_texture instead.

◆ shareDepthBuffer()

bool shareDepthBuffer ( GraphicsOutput  graphics_output)

Will attempt to use the depth buffer of the input graphics_output.

The buffer sizes must be exactly the same.

◆ triggerCopy()

AsyncFuture triggerCopy ( )

When the GraphicsOutput is in triggered copy mode, this function triggers the copy (at the end of the next frame).

Returns
a future that can be awaited.

◆ unshareDepthBuffer()

unshareDepthBuffer ( )

Discontinue sharing the depth buffer.

Member Data Documentation

◆ active

bool active

Returns true if the window is ready to be rendered into, false otherwise.

◆ active_display_regions

PointerToDisplayRegion active_display_regions[]

◆ child_sort

int child_sort

Returns the sort value of future offscreen buffers created by make_texture_sort().

See set_child_sort().

◆ display_regions

PointerToDisplayRegion display_regions[]

◆ engine

Returns the graphics engine that created this output.

Since there is normally only one GraphicsEngine object in an application, this is usually the same as the global GraphicsEngine.

◆ fb_size

LVecBase2i fb_size

Returns the internal size of the window or buffer.

This is almost always the same as get_size(), except when a pixel_zoom is in effect–see set_pixel_zoom().

◆ gsg

Returns the GSG that is associated with this window.

There is a one-to-one association between windows and GSG's.

This may return NULL if the graphics context has not yet been created for the window, e.g. before the first frame has rendered; or after the window has been closed.

◆ inverted

bool inverted

Returns the current setting of the inverted flag.

When this is true, the scene is rendered into the window upside-down, flipped like a mirror along the X axis. See set_inverted().

◆ name

const String name

Returns the name that was passed to the GraphicsOutput constructor.

◆ one_shot

bool one_shot

Returns the current setting of the one-shot flag.

When this is true, the GraphicsOutput will automatically set itself inactive after the next frame.

◆ pipe

Returns the GraphicsPipe that this window is associated with.

It is possible that the GraphicsPipe might have been deleted while an outstanding PT(GraphicsOutput) prevented all of its children windows from also being deleted; in this unlikely case, get_pipe() may return NULL.

◆ sbs_left_size

LVecBase2i sbs_left_size

If side-by-side stereo is enabled, this returns the pixel size of the left eye, based on scaling get_size() by get_sbs_left_dimensions().

If side-by- side stereo is not enabled, this returns the same as get_size().

◆ sbs_right_size

LVecBase2i sbs_right_size

If side-by-side stereo is enabled, this returns the pixel size of the right eye, based on scaling get_size() by get_sbs_right_dimensions().

If side- by-side stereo is not enabled, this returns the same as get_size().

◆ size

const LVecBase2i size

Returns the visible size of the window or buffer, if it is known.

In certain cases (e.g. fullscreen windows), the size may not be known until after the object has been fully created. Check has_size() first.

Certain objects (like windows) may change size spontaneously; this method is not thread-safe. To get the size of a window in a thread-safe manner, query get_properties().

◆ sort

int sort

Returns the sorting order of this particular GraphicsOutput.

The various GraphicsOutputs within a particular thread will be rendered in the indicated order.

◆ supports_render_texture

bool supports_render_texture

Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.

◆ swap_eyes

bool swap_eyes

Returns the current setting of the "swap eyes" flag.

See set_swap_eyes().