Viewport class
#include <nCine/Graphics/Viewport.h>
Render target with its own scene root, camera and render queue.
Visits a scene graph from its root node through a camera and collects the resulting draw commands into its own render queue. A viewport can render into one or more textures (as multiple render targets), reuse the previous viewport's texture, or, as ScreenViewport, draw to the screen. Viewports are chained and drawn in order before the screen.
Derived classes
- class ScreenViewport
- Viewport that renders directly to the screen.
Public types
- enum class Type { WithTexture, NoTexture, Screen }
- Type of viewport.
- 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 viewport with the specified name and texture, plus a depth and stencil renderbuffer.
- Viewport(Texture* texture, DepthStencilFormat depthStencilFormat)
- Creates a viewport with the specified texture, plus a depth and stencil renderbuffer.
- Viewport(const char* name, Texture* texture)
- Creates a viewport with the specified name and texture.
- Viewport(Texture* texture) explicit
- Creates a viewport with the specified texture.
- Viewport()
- Creates a 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 FBO color attachment index, or
nullptrif none. - auto GetTexture() -> Texture*
- Returns the texture at the first FBO color attachment index.
-
auto SetTexture(std::
uint32_t index, Texture* texture) -> bool - Adds or removes a texture at the specified FBO color attachment index.
- auto SetTexture(Texture* texture) -> bool
- Adds or removes a texture at the first FBO color attachment index.
- auto GetDepthStencilFormat() const -> DepthStencilFormat
- Returns the depth and stencil format of the FBO renderbuffer.
- auto SetDepthStencilFormat(DepthStencilFormat depthStencilFormat) -> bool
- Sets the depth and stencil format of the FBO renderbuffer.
- auto RemoveAllTextures() -> bool
- Removes all textures and the depth and stencil renderbuffer from the FBO.
- auto GetSize() const -> Vector2i
- Returns the FBO size, or a zero vector if no texture is present.
-
auto GetWidth() const -> std::
int32_t - Returns the FBO width, or zero if no texture is present.
-
auto GetHeight() const -> std::
int32_t - Returns the FBO height, or zero if no texture is present.
-
auto GetColorAttachmentCount() const -> std::
uint32_t - Returns the number of color attachments of the FBO.
- auto GetViewportRect() const -> Recti
- Returns the OpenGL viewport rectangle.
- void SetViewportRect(const Recti& viewportRect)
- Sets the OpenGL viewport rectangle.
- auto GetScissorRect() const -> Recti
- Returns the OpenGL scissor test rectangle.
- void SetScissorRect(const Recti& scissorRect)
- Sets the OpenGL scissor test rectangle.
- auto GetCullingRect() const -> Rectf
- Returns the rectangle used 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.
- void SetClearColor(float red, float green, float blue, float alpha)
- Sets the viewport clear color through four float components.
- void SetClearColor(const Colorf& color)
- Sets the viewport clear color through a
Colorfobject. - auto GetRootNode() const -> const SceneNode*
- Returns the scene root node as constant.
- auto GetRootNode() -> SceneNode*
- Returns the scene root node.
- void SetRootNode(SceneNode* rootNode)
- Sets the scene root node.
- auto GetCamera() const -> const Camera*
- Returns the camera used for rendering as 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's 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
Type of viewport.
| Enumerators | |
|---|---|
| WithTexture |
The viewport renders into one or more textures. |
| NoTexture |
The viewport has no texture of its own and reuses 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 |
Cleared every time it is drawn. |
| EveryFrame |
Cleared once per frame (default behavior). |
| ThisFrameOnly |
Cleared only once, during this frame. |
| NextFrameOnly |
Cleared only once, during the next frame. |
| Never |
Never cleared. |