class GUIViewport

Inherits: GUIInteractable

Displays a Camera view in the form of a GUI element.

Public

Methods

staticGetGuiTypeName

static const String &GetGuiTypeName()

Returns type name of the GUI element used for finding GUI element styles.

staticCreate

static GUIViewport *Create(const HCamera &camera, float aspectRatio, Degree fieldOfView, const String &styleName = StringUtility::kBlank)

Creates a new GUI viewport element.

camera
Camera whos view to display in the element. Element will update the camera as it resizes.
aspectRatio
Initial aspect of the camera. Determines how is FOV adjusted as the element resizes.
fieldOfView
Initial FOV of the camera. Determines how is FOV adjusted as the element resizes.
styleName
Optional style to use for the element. Style will be retrieved from GUISkin of the GUIWidget the element is used on. If not specified default style is used.

staticCreate

static GUIViewport *Create(const GUIOptions &options, const HCamera &camera, float aspectRatio, Degree fieldOfView, const String &styleName = StringUtility::kBlank)

Creates a new GUI viewport element.

camera
Camera whos view to display in the element. Element will update the camera as it resizes.
aspectRatio
Initial aspect of the camera. Determines how is FOV adjusted as the element resizes.
fieldOfView
Initial FOV of the camera. Determines how is FOV adjusted as the element resizes.
options
Options that allow you to control how is the element positioned and sized. This will override any similar options set by style.
styleName
Optional style to use for the element. Style will be retrieved from GUISkin of the GUIWidget the element is used on. If not specified default style is used.

Internal

Methods

CalculateUnconstrainedOptimalSize

GUILogicalSize CalculateUnconstrainedOptimalSize() const override

Calculates the optimal size for the GUI element, ignoring size constraints.

Protected

Methods

~GUIViewport

~GUIViewport() noexcept = default

FillBuffer

void FillBuffer(u8 *vertices, u32 *indices, u32 vertexOffset, u32 indexOffset, const Vector2I &offset, u32 maxVertexCount, u32 maxIndexCount, u32 renderElementIdx) const override

Fill the pre-allocated vertex, uv and index buffers with the mesh data for the specified render element.

vertices
Previously allocated buffer where to store the vertices. Output is expected to match the GUIMeshType as returned by getRenderElements() for the specified element.
indices
Previously allocated buffer where to store the indices.
vertexOffset
At which vertex should the method start filling the buffer.
offset
Offset that should be applied to all output vertex positions.
indexOffset
At which index should the method start filling the buffer.
maxVertexCount
Total number of vertices the buffers were allocated for. Used only for memory safety.
maxIndexCount
Total number of indices the buffers were allocated for. Used only for memory safety.
renderElementIdx
Zero-based index of the render element.

UpdateRenderElements

void UpdateRenderElements() override

Recreates the internal render elements.

Must be called before GetRenderElementVertexAndIndexData/FillBuffer if element is dirty. Marks the element as non dirty.

Private

Constructors

GUIViewport

GUIViewport(const String &styleName, const HCamera &camera, float aspectRatio, Degree fieldOfView, const GUISizeConstraints &dimensions)

Methods

ChangeParentWidget

void ChangeParentWidget(GUIWidget *widget) override

Changes the active GUI element widget.

This allows you to move an element to a different viewport, or change element style by using a widget with a different skin. You are allowed to pass null here, but elements with no parent will be unmanaged. You will be responsible for deleting them manually, and they will not render anywhere.

Fields

mCamera

HCamera mCamera

mAspectRatio

float mAspectRatio

mFieldOfView

Degree mFieldOfView

mVerticalFOV

Radian mVerticalFOV