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 GetChain() -> 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 GetType() const -> Type
Returns the viewport type.
auto GetTexture(std::uint32_t index) -> Texture*
Returns the texture at the specified viewport's FBO color attachment index, if any.
auto GetTexture() -> 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 GetDepthStencilFormat() 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 GetSize() const -> Vector2i
Returns viewport's FBO size as a Vector2i object, or a zero vector if no texture is present.
auto GetWidth() const -> std::int32_t
Returns viewport's FBO width or zero if no texture is present.
auto GetHeight() const -> std::int32_t
Returns viewport's FBO height or zero if no texture is present.
auto GetColorAttachmentCount() const -> std::uint32_t
Returns the number of color attachments of the viewport's FBO.
auto GetViewportRect() const -> Recti
Returns the OpenGL viewport rectangle.
void SetViewportRect(const Recti& viewportRect)
Sets the OpenGL viewport rectangle through a Recti object.
auto GetScissorRect() const -> Recti
Returns the OpenGL scissor test rectangle.
void SetScissorRect(const Recti& scissorRect)
Sets the OpenGL scissor test rectangle through a Recti object.
auto GetCullingRect() const -> Rectf
Returns the rectangle for screen culling.
auto GetLastFrameCleared() const -> unsigned long int
Returns the last frame this viewport was cleared.
auto GetClearMode() const -> ClearMode
Returns the viewport clear mode.
void SetClearMode(ClearMode clearMode)
Sets the viewport clear mode.
auto GetClearColor() 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 GetRootNode() const -> const SceneNode*
Returns the root node as a constant.
auto GetRootNode() -> SceneNode*
Returns the root node.
void SetRootNode(SceneNode* rootNode)
Sets the root node.
auto GetCamera() const -> const Camera*
Returns the camera used for rendering as a constant.
auto GetCamera() -> 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.