panda3d.core.DisplayRegion

class DisplayRegion

Bases: TypedReferenceCount, DrawableRegion

A rectangular subregion within a window for rendering into. Typically, there is one DisplayRegion that covers the whole window, but you may also create smaller DisplayRegions for having different regions within the window that represent different scenes. You may also stack up DisplayRegions like panes of glass, usually for layering 2-d interfaces on top of a 3-d scene.

Inheritance diagram

Inheritance diagram of DisplayRegion

getNumRegions() → int

Returns the number of regions, see set_num_regions.

setNumRegions(i: int) → None

Sets the number of regions that this DisplayRegion indicates. Usually, this number is 1 (and it is always at least 1), and only the first is used for rendering. However, if more than one is provided, you may select which one to render into using a geometry shader (gl_ViewportIndex in GLSL).

getDimensions(i: int) → LVecBase4

Retrieves the coordinates of the DisplayRegion’s rectangle within its GraphicsOutput. These numbers will be in the range [0..1].

Return type

LVecBase4

getLeft(i: int) → float

Retrieves the x coordinate of the left edge of the rectangle within its GraphicsOutput. This number will be in the range [0..1].

getRight(i: int) → float

Retrieves the x coordinate of the right edge of the rectangle within its GraphicsOutput. This number will be in the range [0..1].

getBottom(i: int) → float

Retrieves the y coordinate of the bottom edge of the rectangle within its GraphicsOutput. This number will be in the range [0..1].

getTop(i: int) → float

Retrieves the y coordinate of the top edge of the rectangle within its GraphicsOutput. This number will be in the range [0..1].

setDimensions(dimensions: LVecBase4) → None

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

setDimensions(l: float, r: float, b: float, t: float) → None

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

setDimensions(i: int, dimensions: LVecBase4) → None

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

setDimensions(i: int, l: float, r: float, b: float, t: float) → None

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

getWindow() → GraphicsOutput

Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no window is associated.

Return type

GraphicsOutput

getPipe() → GraphicsPipe

Returns the GraphicsPipe that this DisplayRegion is ultimately associated with, or NULL if no pipe is associated.

Return type

GraphicsPipe

isStereo() → bool

Returns true if this is a StereoDisplayRegion, false otherwise.

setCamera(camera: NodePath) → None

Sets the camera that is associated with this DisplayRegion. There is a one-to-many association between cameras and DisplayRegions; one camera may be shared by multiple DisplayRegions.

The camera is actually set via a NodePath, which clarifies which instance of the camera (if there happen to be multiple instances) we should use.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

getCamera(current_thread: Thread) → NodePath

Returns the camera associated with this DisplayRegion, or an empty NodePath if no camera is associated.

Return type

NodePath

setActive(active: bool) → None

Sets the active flag associated with the DisplayRegion. If the DisplayRegion is marked inactive, nothing is rendered.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

isActive() → bool

Returns the active flag associated with the DisplayRegion.

setSort(sort: int) → None

Sets the sort value associated with the DisplayRegion. Within a window, DisplayRegions will be rendered in order from the lowest sort value to the highest.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

getSort() → int

Returns the sort value associated with the DisplayRegion.

setStereoChannel(stereo_channel: StereoChannel) → None

Specifies whether the DisplayRegion represents the left or right channel of a stereo pair, or whether it is a normal, monocular image. This automatically adjusts the lens that is used to render to this DisplayRegion to its left or right eye, according to the lens’s stereo properties.

When the DisplayRegion is attached to a stereo window (one for which isStereo() returns true), this also specifies which physical channel the DisplayRegion renders to.

Normally you would create at least two DisplayRegions for a stereo window, one for each of the left and right channels. The two DisplayRegions may share the same camera (and thus the same lens); this parameter is used to control the exact properties of the lens when it is used to render into this DisplayRegion.

Also see the StereoDisplayRegion, which automates managing a pair of left/right DisplayRegions.

An ordinary DisplayRegion may be set to SC_mono, SC_left, or SC_right. You may set SC_stereo only on a StereoDisplayRegion.

This call also resets tex_view_offset to its default value, which is 0 for the left eye or 1 for the right eye of a stereo display region, or 0 for a mono display region.

getStereoChannel() → StereoChannel

Returns whether the DisplayRegion is specified as the left or right channel of a stereo pair, or whether it is a normal, monocular image. See setStereoChannel().

Return type

StereoChannel

setTexViewOffset(tex_view_offset: int) → None

Sets the current texture view offset for this DisplayRegion. This is normally set to zero. If nonzero, it is used to select a particular view of any multiview textures that are rendered within this DisplayRegion.

For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for the right eye, to support stereo textures. This is set automatically when you call setStereoChannel().

getTexViewOffset() → int

Returns the current texture view offset for this DisplayRegion. This is normally set to zero. If nonzero, it is used to select a particular view of any multiview textures that are rendered within this DisplayRegion.

For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for the right eye, to support stereo textures.

setIncompleteRender(incomplete_render: bool) → None

Sets the incomplete_render flag. When this is true, the frame will be rendered even if some of the geometry or textures in the scene are not available (e.g. they have been temporarily paged out). When this is false, the frame will be held up while this data is reloaded.

This flag may also be set on the GraphicsStateGuardian. It will be considered true for a given DisplayRegion only if it is true on both the GSG and on the DisplayRegion.

See GraphicsStateGuardian.setIncompleteRender() for more detail.

getIncompleteRender() → bool

Returns the incomplete_render flag. See setIncompleteRender().

setTextureReloadPriority(texture_reload_priority: int) → None

Specifies an integer priority which is assigned to any asynchronous texture reload requests spawned while processing this DisplayRegion. This controls which textures are loaded first when multiple textures need to be reloaded at once; it also controls the relative priority between asynchronous texture loads and asynchronous model or animation loads.

Specifying a larger number here makes the textures rendered by this DisplayRegion load up first. This may be particularly useful to do, for instance, for the DisplayRegion that renders the gui.

getTextureReloadPriority() → int

Returns the priority which is assigned to asynchronous texture reload requests. See setTextureReloadPriority().

setLensIndex(index: int) → None

Sets the lens index, allows for multiple lenses to be attached to a camera. This is useful for a variety of setups, such as fish eye rendering. The default is 0.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

getLensIndex() → int

Returns the specific lens of the associated Camera that will be used for rendering this scene. Most Cameras hold only one lens, but for multiple lenses this method may be used to selected between them.

setCullTraverser(trav: CullTraverser) → None

Specifies the CullTraverser that will be used to draw the contents of this DisplayRegion. Normally the default CullTraverser is sufficient, but this may be changed to change the default cull behavior.

getCullTraverser() → CullTraverser

Returns the CullTraverser that will be used to draw the contents of this DisplayRegion.

Return type

CullTraverser

setCubeMapIndex(cube_map_index: int) → None

Deprecated; replaced by setTargetTexPage().

setTargetTexPage(page: int) → None

This is a special parameter that is only used when rendering the faces of a cube map or multipage and/or multiview texture.

This sets up the DisplayRegion to render to the ith page and jth view of its associated texture(s); the value must be consistent with the range of values availble to the texture. A normal DisplayRegion that is not associated with any particular page should be set to page -1 and view 0.

This is particularly useful when rendering cube maps and/or stereo textures.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

getTargetTexPage() → int

Returns the target page number associated with this particular DisplayRegion, or -1 if it is not associated with a page. See setTargetTexPage().

setScissorEnabled(scissor_enabled: bool) → None

Sets whether or not scissor testing is enabled for this region. The default is true, except for the overlay display region.

getScissorEnabled() → bool

Returns whether or not scissor testing is enabled for this region. The default is true, except for the overlay display region.

setCullCallback(object: CallbackObject) → None

Sets the CallbackObject that will be notified when the DisplayRegion is visited during the cull traversal. This callback will be made during the cull thread.

The cull traversal is responsible for determining which nodes are visible and within the view frustum, and for accumulating state and transform, and generally building up the list of CullableObjects that are to be eventually passed to the draw traversal for rendering.

At the time the cull traversal callback is made, the traversal for this DisplayRegion has not yet started.

The callback is passed an instance of a DisplayRegionCullCallbackData, which contains pointers to the current scene information, as well as the current DisplayRegion and GSG. The callback replaces the normal cull behavior, so if your callback does nothing, the scene graph will not be traversed and therefore nothing will be drawn. If you wish the normal cull traversal to be performed for this DisplayRegion, you must call cbdata->upcall() from your callback.

clearCullCallback() → None

Removes the callback set by an earlier call to setCullCallback().

getCullCallback() → CallbackObject

Returns the CallbackObject set by setCullCallback().

Return type

CallbackObject

setDrawCallback(object: CallbackObject) → None

Sets the CallbackObject that will be notified when the contents of DisplayRegion is drawn during the draw traversal. This callback will be made during the draw thread.

The draw traversal is responsible for actually issuing the commands to the graphics engine to draw primitives. Its job is to walk through the list of CullableObjects build up by the cull traversal, as quickly as possible, issuing the appropriate commands to draw each one.

At the time the draw traversal callback is made, the graphics state is in the initial state, and no projection matrix or modelview matrix is in effect. begin_scene() has not yet been called, and no objects have yet been drawn. However, the viewport has already been set to the appropriate part of the window, and the clear commands for this DisplayRegion (if any) have been issued.

The callback is passed an instance of a DisplayRegionDrawCallbackData, which contains pointers to the current scene information, as well as the current DisplayRegion and GSG. The callback replaces the normal draw behavior, so if your callback does nothing, nothing in the DisplayRegion will be drawn. If you wish the draw traversal to continue to draw the contents of this DisplayRegion, you must call cbdata->upcall() from your callback.

clearDrawCallback() → None

Removes the callback set by an earlier call to setDrawCallback().

getDrawCallback() → CallbackObject

Returns the CallbackObject set by setDrawCallback().

Return type

CallbackObject

getPixelWidth(i: int) → int

Returns the width of the DisplayRegion in pixels.

getPixelHeight(i: int) → int

Returns the height of the DisplayRegion in pixels.

getPixelSize(i: int) → LVecBase2i

Returns the size of the DisplayRegion in pixels.

Return type

LVecBase2i

output(out: ostream) → None
static makeScreenshotFilename(prefix: str) → Filename

Synthesizes a suitable default filename for passing to saveScreenshot().

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

Return type

Filename

saveScreenshotDefault(prefix: str) → Filename

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

Return type

Filename

saveScreenshot(filename: Filename, image_comment: str) → bool

Saves a screenshot of the region to the indicated filename. Returns true on success, false on failure.

getScreenshot() → Texture

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

Return type

Texture

getScreenshot(image: PNMImage) → bool

Captures the most-recently rendered image from the framebuffer into the indicated PNMImage. Returns true on success, false on failure.

makeCullResultGraph() → PandaNode

Returns a special scene graph constructed to represent the results of the last frame’s cull operation.

This will be a hierarchy of nodes, one node for each bin, each of which will in term be a parent of a number of GeomNodes, representing the geometry drawn in each bin.

This is useful mainly for high-level debugging and abstraction tools; it should not be mistaken for the low-level cull result itself, which is constructed and maintained internally. No such scene graph is normally constructed during the rendering of a frame; this is an artificial construct created for the purpose of making it easy to analyze the results of the cull operation.

Return type

PandaNode

static getClassType() → TypeHandle
Return type

TypeHandle

property dimensions
Getter

Retrieves the coordinates of the DisplayRegion’s rectangle within its GraphicsOutput. These numbers will be in the range [0..1].

Retrieves the coordinates of the DisplayRegion’s rectangle within its GraphicsOutput. These numbers will be in the range [0..1].

Retrieves the coordinates of the DisplayRegion’s rectangle within its GraphicsOutput. These numbers will be in the range [0..1].

Setter

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

Changes the portion of the framebuffer this DisplayRegion corresponds to. The parameters range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

Return type

LVecBase4

property window

Returns the GraphicsOutput that this DisplayRegion is ultimately associated with, or NULL if no window is associated.

Return type

GraphicsOutput

property pipe

Returns the GraphicsPipe that this DisplayRegion is ultimately associated with, or NULL if no pipe is associated.

Return type

GraphicsPipe

property stereo

Returns true if this is a StereoDisplayRegion, false otherwise.

Return type

bool

property camera
Getter

Returns the camera associated with this DisplayRegion, or an empty NodePath if no camera is associated.

Setter

Sets the camera that is associated with this DisplayRegion. There is a one-to-many association between cameras and DisplayRegions; one camera may be shared by multiple DisplayRegions.

The camera is actually set via a NodePath, which clarifies which instance of the camera (if there happen to be multiple instances) we should use.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

Return type

NodePath

property active
Getter

Returns the active flag associated with the DisplayRegion.

Setter

Sets the active flag associated with the DisplayRegion. If the DisplayRegion is marked inactive, nothing is rendered.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

Return type

bool

property sort
Getter

Returns the sort value associated with the DisplayRegion.

Setter

Sets the sort value associated with the DisplayRegion. Within a window, DisplayRegions will be rendered in order from the lowest sort value to the highest.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

Return type

int

property stereo_channel
Getter

Returns whether the DisplayRegion is specified as the left or right channel of a stereo pair, or whether it is a normal, monocular image. See setStereoChannel().

Setter

Specifies whether the DisplayRegion represents the left or right channel of a stereo pair, or whether it is a normal, monocular image. This automatically adjusts the lens that is used to render to this DisplayRegion to its left or right eye, according to the lens’s stereo properties.

When the DisplayRegion is attached to a stereo window (one for which isStereo() returns true), this also specifies which physical channel the DisplayRegion renders to.

Normally you would create at least two DisplayRegions for a stereo window, one for each of the left and right channels. The two DisplayRegions may share the same camera (and thus the same lens); this parameter is used to control the exact properties of the lens when it is used to render into this DisplayRegion.

Also see the StereoDisplayRegion, which automates managing a pair of left/right DisplayRegions.

An ordinary DisplayRegion may be set to SC_mono, SC_left, or SC_right. You may set SC_stereo only on a StereoDisplayRegion.

This call also resets tex_view_offset to its default value, which is 0 for the left eye or 1 for the right eye of a stereo display region, or 0 for a mono display region.

Return type

StereoChannel

property tex_view_offset
Getter

Returns the current texture view offset for this DisplayRegion. This is normally set to zero. If nonzero, it is used to select a particular view of any multiview textures that are rendered within this DisplayRegion.

For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for the right eye, to support stereo textures.

Setter

Sets the current texture view offset for this DisplayRegion. This is normally set to zero. If nonzero, it is used to select a particular view of any multiview textures that are rendered within this DisplayRegion.

For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for the right eye, to support stereo textures. This is set automatically when you call setStereoChannel().

Return type

int

property incomplete_render
Getter

Returns the incomplete_render flag. See setIncompleteRender().

Setter

Sets the incomplete_render flag. When this is true, the frame will be rendered even if some of the geometry or textures in the scene are not available (e.g. they have been temporarily paged out). When this is false, the frame will be held up while this data is reloaded.

This flag may also be set on the GraphicsStateGuardian. It will be considered true for a given DisplayRegion only if it is true on both the GSG and on the DisplayRegion.

See GraphicsStateGuardian.setIncompleteRender() for more detail.

Return type

bool

property texture_reload_priority
Getter

Returns the priority which is assigned to asynchronous texture reload requests. See setTextureReloadPriority().

Setter

Specifies an integer priority which is assigned to any asynchronous texture reload requests spawned while processing this DisplayRegion. This controls which textures are loaded first when multiple textures need to be reloaded at once; it also controls the relative priority between asynchronous texture loads and asynchronous model or animation loads.

Specifying a larger number here makes the textures rendered by this DisplayRegion load up first. This may be particularly useful to do, for instance, for the DisplayRegion that renders the gui.

Return type

int

property lens_index
Getter

Returns the specific lens of the associated Camera that will be used for rendering this scene. Most Cameras hold only one lens, but for multiple lenses this method may be used to selected between them.

Setter

Sets the lens index, allows for multiple lenses to be attached to a camera. This is useful for a variety of setups, such as fish eye rendering. The default is 0.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

Return type

int

property cull_traverser
Getter

Returns the CullTraverser that will be used to draw the contents of this DisplayRegion.

Setter

Specifies the CullTraverser that will be used to draw the contents of this DisplayRegion. Normally the default CullTraverser is sufficient, but this may be changed to change the default cull behavior.

Return type

CullTraverser

property target_tex_page
Getter

Returns the target page number associated with this particular DisplayRegion, or -1 if it is not associated with a page. See setTargetTexPage().

Setter

This is a special parameter that is only used when rendering the faces of a cube map or multipage and/or multiview texture.

This sets up the DisplayRegion to render to the ith page and jth view of its associated texture(s); the value must be consistent with the range of values availble to the texture. A normal DisplayRegion that is not associated with any particular page should be set to page -1 and view 0.

This is particularly useful when rendering cube maps and/or stereo textures.

Don’t call this in a downstream thread unless you don’t mind it blowing away other changes you might have recently made in an upstream thread.

Return type

int

property scissor_enabled
Getter

Returns whether or not scissor testing is enabled for this region. The default is true, except for the overlay display region.

Setter

Sets whether or not scissor testing is enabled for this region. The default is true, except for the overlay display region.

Return type

bool

property cull_callback
Getter

Returns the CallbackObject set by setCullCallback().

Setter

Sets the CallbackObject that will be notified when the DisplayRegion is visited during the cull traversal. This callback will be made during the cull thread.

The cull traversal is responsible for determining which nodes are visible and within the view frustum, and for accumulating state and transform, and generally building up the list of CullableObjects that are to be eventually passed to the draw traversal for rendering.

At the time the cull traversal callback is made, the traversal for this DisplayRegion has not yet started.

The callback is passed an instance of a DisplayRegionCullCallbackData, which contains pointers to the current scene information, as well as the current DisplayRegion and GSG. The callback replaces the normal cull behavior, so if your callback does nothing, the scene graph will not be traversed and therefore nothing will be drawn. If you wish the normal cull traversal to be performed for this DisplayRegion, you must call cbdata->upcall() from your callback.

Return type

CallbackObject

property draw_callback
Getter

Returns the CallbackObject set by setDrawCallback().

Setter

Sets the CallbackObject that will be notified when the contents of DisplayRegion is drawn during the draw traversal. This callback will be made during the draw thread.

The draw traversal is responsible for actually issuing the commands to the graphics engine to draw primitives. Its job is to walk through the list of CullableObjects build up by the cull traversal, as quickly as possible, issuing the appropriate commands to draw each one.

At the time the draw traversal callback is made, the graphics state is in the initial state, and no projection matrix or modelview matrix is in effect. begin_scene() has not yet been called, and no objects have yet been drawn. However, the viewport has already been set to the appropriate part of the window, and the clear commands for this DisplayRegion (if any) have been issued.

The callback is passed an instance of a DisplayRegionDrawCallbackData, which contains pointers to the current scene information, as well as the current DisplayRegion and GSG. The callback replaces the normal draw behavior, so if your callback does nothing, nothing in the DisplayRegion will be drawn. If you wish the draw traversal to continue to draw the contents of this DisplayRegion, you must call cbdata->upcall() from your callback.

Return type

CallbackObject

property pixel_size

Returns the size of the DisplayRegion in pixels.

Return type

LVecBase2i