Cogs.Core
Public Member Functions | Public Attributes | Private Attributes | List of all members
Cogs::Core::ViewContext Class Reference
Inheritance diagram for Cogs::Core::ViewContext:
Cogs::PlatformContext

Public Member Functions

 ViewContext (Context *ctx, WindowData *windowData)
 Constructs a new ViewContext instance.
 
bool initialize (const Cogs::Core::EntityPtr &renderCamera)
 Initialises the standard components in this ViewContext instance.
 
void update ()
 Updates the components in this view. Called once per frame from the owning Context's update call.
 
void preRender ()
 Called by the owning Context during its preRender call.
 
void setCamera (const Cogs::Core::EntityPtr &renderCamera)
 Sets or updates the camera of this ViewContext instance.
 
void setSize (int newWidth, int newHeight)
 Resizes this view.
 
void setDPI (int newDPI, float scaleFactor)
 
constexpr ContextgetContext () const
 
constexpr ISwapChaingetSwapChain () const
 
glm::vec2 getSize () const
 
Cogs::Core::EntityPtr getCamera () const
 Gets view camera. The camera must be valid when rendering a frame in the view.
 
CameraComponentgetCameraComponent () const
 Utility to get the CameraComponent from.
 
void addResizeCallback (ResizeCallback *callback)
 
void removeResizeCallback (ResizeCallback *callback)
 
- Public Member Functions inherited from Cogs::PlatformContext
void setWindowData (WindowData *data)
 
WindowDatarefWindowData ()
 
KeyboardrefKeyboard ()
 
MouserefMouse ()
 
GesturesrefGestures ()
 
const KeyboardgetKeyboard () const
 
const MousegetMouse () const
 
const GesturesgetGestures () const
 

Public Attributes

std::unique_ptr< class DPIServicedpiService
 DPI service instance.
 
std::unique_ptr< Platform::GamepadHandlergamepadHandler
 Gamepad input handler.
 
std::unique_ptr< class InputManagerinputManager
 

Private Attributes

std::vector< ResizeCallback * > resizeCallbacks
 List of callbacks to be called when this view is resized.
 
Cogs::Core::WeakEntityPtr camera
 The entity that's rendering this view. (Needs a CameraComponent at the bare minimum, and a TransformComponent for some things.)
 
Contextcontext = nullptr
 Context that owns this view.
 
ISwapChainswapChain = nullptr
 The swap chain that will be used for display.
 
TextureHandle texture
 Cogs.Core texture that represents the swapchain's buffers.
 

Detailed Description

Definition at line 23 of file ViewContext.h.

Constructor & Destructor Documentation

◆ ViewContext()

Cogs::Core::ViewContext::ViewContext ( Context ctx,
WindowData windowData 
)

Constructs a new ViewContext instance.

This constructor overload will be called by Context::createView when creating a new window/view.

Definition at line 26 of file ViewContext.cpp.

◆ ~ViewContext()

Cogs::Core::ViewContext::~ViewContext ( )
override

Definition at line 34 of file ViewContext.cpp.

Member Function Documentation

◆ addResizeCallback()

void Cogs::Core::ViewContext::addResizeCallback ( ResizeCallback *  callback)

Definition at line 188 of file ViewContext.cpp.

◆ getCamera()

Cogs::Core::EntityPtr Cogs::Core::ViewContext::getCamera ( ) const

Gets view camera. The camera must be valid when rendering a frame in the view.

Definition at line 178 of file ViewContext.cpp.

◆ getCameraComponent()

Cogs::Core::CameraComponent * Cogs::Core::ViewContext::getCameraComponent ( ) const

Utility to get the CameraComponent from.

See also
getCamera

Definition at line 183 of file ViewContext.cpp.

References Cogs::ComponentModel::Component::getComponent().

◆ getContext()

constexpr Context * Cogs::Core::ViewContext::getContext ( ) const
inlineconstexpr

Definition at line 57 of file ViewContext.h.

◆ getSize()

glm::vec2 Cogs::Core::ViewContext::getSize ( ) const

Definition at line 165 of file ViewContext.cpp.

◆ getSwapChain()

constexpr ISwapChain * Cogs::Core::ViewContext::getSwapChain ( ) const
inlineconstexpr

Definition at line 58 of file ViewContext.h.

◆ initialize()

bool Cogs::Core::ViewContext::initialize ( const Cogs::Core::EntityPtr renderCamera)

Initialises the standard components in this ViewContext instance.

For tertiary views, this needs to be called just after the construction. For a Context's default view this will be called during the initialisation of that context, after the device and main window have been created.

Parameters
renderCamera- Optional camera. Camera required, but can be set later using setCamera

Definition at line 62 of file ViewContext.cpp.

References Cogs::TextureFlags::ExternalTexture, Cogs::TextureFlags::RenderTarget, and Cogs::TextureFlags::Texture.

◆ preRender()

void Cogs::Core::ViewContext::preRender ( )

Called by the owning Context during its preRender call.

Definition at line 107 of file ViewContext.cpp.

◆ removeResizeCallback()

void Cogs::Core::ViewContext::removeResizeCallback ( ResizeCallback *  callback)

Definition at line 196 of file ViewContext.cpp.

◆ setCamera()

void Cogs::Core::ViewContext::setCamera ( const Cogs::Core::EntityPtr renderCamera)

Sets or updates the camera of this ViewContext instance.

Clearing the Scene or deleting the Camera entity requires replacing the ViewContext camere.

Parameters
renderCamera- New Camera - must be valid.

Definition at line 114 of file ViewContext.cpp.

References Cogs::ComponentModel::Component::getComponent(), Cogs::Core::CameraComponent::renderTexture, and Cogs::ComponentModel::Component::setChanged().

Referenced by Cogs::Core::Scene::setup().

◆ setDPI()

void Cogs::Core::ViewContext::setDPI ( int  newDPI,
float  scaleFactor 
)

Definition at line 159 of file ViewContext.cpp.

◆ setSize()

void Cogs::Core::ViewContext::setSize ( int  newWidth,
int  newHeight 
)

◆ update()

void Cogs::Core::ViewContext::update ( )

Updates the components in this view. Called once per frame from the owning Context's update call.

Definition at line 101 of file ViewContext.cpp.

Member Data Documentation

◆ camera

Cogs::Core::WeakEntityPtr Cogs::Core::ViewContext::camera
private

The entity that's rendering this view. (Needs a CameraComponent at the bare minimum, and a TransformComponent for some things.)

Definition at line 85 of file ViewContext.h.

◆ context

Context* Cogs::Core::ViewContext::context = nullptr
private

Context that owns this view.

Definition at line 88 of file ViewContext.h.

◆ dpiService

std::unique_ptr<class DPIService> Cogs::Core::ViewContext::dpiService

DPI service instance.

Definition at line 71 of file ViewContext.h.

Referenced by Cogs::Core::MarkerPointSetPicker::pickCamera(), and Cogs::Core::PotreeSystem::update().

◆ gamepadHandler

std::unique_ptr<Platform::GamepadHandler> Cogs::Core::ViewContext::gamepadHandler

Gamepad input handler.

Definition at line 74 of file ViewContext.h.

◆ inputManager

std::unique_ptr<class InputManager> Cogs::Core::ViewContext::inputManager

Generic input handler Inputs is directed to the view the user interacts in.

Definition at line 78 of file ViewContext.h.

◆ resizeCallbacks

std::vector<ResizeCallback*> Cogs::Core::ViewContext::resizeCallbacks
private

List of callbacks to be called when this view is resized.

Definition at line 82 of file ViewContext.h.

◆ swapChain

ISwapChain* Cogs::Core::ViewContext::swapChain = nullptr
private

The swap chain that will be used for display.

Definition at line 91 of file ViewContext.h.

◆ texture

TextureHandle Cogs::Core::ViewContext::texture
private

Cogs.Core texture that represents the swapchain's buffers.

Definition at line 94 of file ViewContext.h.


The documentation for this class was generated from the following files: