nCine::Viewport class

Handles a viewport and its corresponding render target texture.

Derived classes

class ScreenViewport
Handles the screen viewport.

Public types

enum class Type { WithTexture, NoTexture, Screen }
Types of viewports available.
enum class ClearMode { EveryDraw, EveryFrame, ThisFrameOnly, NextFrameOnly, Never }
Clear mode for a viewport with a texture or for the screen.
enum class DepthStencilFormat { None, Depth16, Depth24, Depth24_Stencil8 }
Depth and stencil format for a viewport with a texture or for the screen.

Public static functions

static auto chain() -> SmallVectorImpl<Viewport*>&
Returns the reverse ordered array of viewports to be drawn before the screen.

Constructors, destructors, conversion operators

Viewport(const char* name, Texture* texture, DepthStencilFormat depthStencilFormat)
Creates a new viewport with the specified name and texture, plus a depth and stencil renderbuffer.
Viewport(Texture* texture, DepthStencilFormat depthStencilFormat)
Creates a new viewport with the specified texture, plus a depth and stencil renderbuffer.
Viewport(const char* name, Texture* texture)
Creates a new viewport with the specified name and texture.
Viewport(Texture* texture) explicit
Creates a new viewport with the specified texture.
Viewport()
Creates a new viewport with no texture.
~Viewport()
Viewport(const Viewport&) deleted

Public functions

auto operator=(const Viewport&) -> Viewport& deleted
auto type() const -> Type
Returns the viewport type.
auto texture(std::uint32_t index) -> Texture*
Returns the texture at the specified viewport's FBO color attachment index, if any.
auto texture() -> Texture*
Returns the texture at the first viewport's FBO color attachment index.
auto setTexture(std::uint32_t index, Texture* texture) -> bool
Adds or removes a texture at the specified viewport's FBO color attachment index.
auto setTexture(Texture* texture) -> bool
Adds or removes a texture at the first viewport's FBO color attachment index.
auto depthStencilFormat() const -> DepthStencilFormat
Returns the depth and stencil format of the viewport's FBO renderbuffer.
auto setDepthStencilFormat(DepthStencilFormat depthStencilFormat) -> bool
Sets the depth and stencil format of the viewport's FBO renderbuffer.
auto removeAllTextures() -> bool
Removes all textures and the depth stencil renderbuffer from the viewport's FBO.
auto size() const -> Vector2i
Returns viewport's FBO size as a Vector2i object, or a zero vector if no texture is present.
auto width() const -> std::int32_t
Returns viewport's FBO width or zero if no texture is present.
auto height() const -> std::int32_t
Returns viewport's FBO height or zero if no texture is present.
auto numColorAttachments() const -> std::uint32_t
Returns the number of color attachments of the viewport's FBO.
auto viewportRect() const -> Recti
Returns the OpenGL viewport rectangle.
void setViewportRect(const Recti& viewportRect)
Sets the OpenGL viewport rectangle through a Recti object.
auto scissorRect() const -> Recti
Returns the OpenGL scissor test rectangle.
void setScissorRect(const Recti& scissorRect)
Sets the OpenGL scissor test rectangle through a Recti object.
auto cullingRect() const -> Rectf
Returns the rectangle for screen culling.
auto lastFrameCleared() const -> unsigned long int
Returns the last frame this viewport was cleared.
auto clearMode() const -> ClearMode
Returns the viewport clear mode.
void setClearMode(ClearMode clearMode)
Sets the viewport clear mode.
auto clearColor() const -> Colorf
Returns the viewport clear color as a Colorf object.
void setClearColor(float red, float green, float blue, float alpha)
Sets the viewport clear color through four floats.
void setClearColor(const Colorf& color)
Sets the viewport clear color through a Colorf object.
auto rootNode() const -> const SceneNode*
Returns the root node as a constant.
auto rootNode() -> SceneNode*
Returns the root node.
void setRootNode(SceneNode* rootNode)
Sets the root node.
auto camera() const -> const Camera*
Returns the camera used for rendering as a constant.
auto camera() -> Camera*
Returns the camera used for rendering.
void setCamera(Camera* camera)
Sets the camera to be used for rendering.
void setGLFramebufferLabel(const char* label)
Sets the OpenGL object label for the viewport framebuffer object.

Protected functions

void calculateCullingRect()
void update()
void visit()
void sortAndCommitQueue()
void draw(std::uint32_t nextIndex)

Enum documentation

enum class nCine::Viewport::Type

Types of viewports available.

Enumerators
WithTexture

The viewport renders in one or more textures.

NoTexture

The viewport has no texture of its own, it uses the one from the previous viewport.

Screen

The viewport is the screen.

enum class nCine::Viewport::ClearMode

Clear mode for a viewport with a texture or for the screen.

Enumerators
EveryDraw

The viewport is cleared every time it is drawn.

EveryFrame

The viewport is cleared once per frame (default behavior)

ThisFrameOnly

The viewport is cleared only once, at this frame.

NextFrameOnly

The viewport is cleared only once, at next frame.

Never

The viewport is never cleared.