Skip to main content

Window Class

Abstract base class representing a generic window. More...

Declaration

class helios::window::Window { ... }

Derived Classes

classGLFWWindow

An OpenGL focused window implementation using GLFW. More...

Public Constructors Index

Window (const Window &)=delete
Window (Window &&) noexcept=default
Window (std::unique_ptr< helios::rendering::RenderTarget > renderTarget, const WindowConfig &cfg)

Constructs a new Window based on the provided configuration. More...

Public Destructor Index

~Window ()=default

Public Operators Index

Window &operator= (const Window &)=delete
Window &operator= (Window &&) noexcept=default
booloperator== (const Window &win) const noexcept

Compares two window instances for equality. More...

Public Member Functions Index

boolshouldClose () const =0

Checks if the window has received a close request. More...

voidsetShouldClose (bool close)=0

Sets the close flag of this window. More...

const util::Guid &guid () const noexcept

Returns the unique guid for this window instance. More...

boolshow () noexcept=0

Shows the underlying native window. More...

voidswapBuffers () const noexcept=0

Instructs the rendering system to swap the front and back buffers. More...

voidpollEvents () const noexcept=0

Poll this window for native window events. More...

intwidth () const noexcept

Returns the current width of this window. More...

intheight () const noexcept

Returns the current height of this window. More...

helios::rendering::RenderTarget &renderTarget () const noexcept

Returns the RenderTarget associated with this Window. More...

std::shared_ptr< helios::rendering::Viewport >addViewport (std::shared_ptr< helios::rendering::Viewport > viewport) const

Adds the viewport to the underlying RenderTarget of this Window. More...

std::vector< helios::rendering::ViewportSnapshot >viewportSnapshots ()

Returns snapshots of all viewports with assigned IDs. More...

Protected Member Attributes Index

intwidth_

The current width of the window. More...

intheight_

The current height of the window. More...

std::stringtitle_

The title of the window. More...

intaspectRatioNumer_ = 0

Aspect ratio numerator. More...

intaspectRatioDenom_ = 0

Aspect ratio denominator. More...

std::unique_ptr< helios::rendering::RenderTarget >renderTarget_

The default render target for this Window. The default RenderTarget represents the default framebuffer, e.g. the "0" FBO in OpenGL. More...

Private Member Attributes Index

util::Guidguid_

Unique identifier for this window instance. More...

Protected Static Attributes Index

static const helios::util::log::Logger &logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE)

The logger used with this Window instance. More...

Description

Abstract base class representing a generic window.

This class provides a common interface for window management without depending on the underlying native window implementation.

A Window can be uniquely identified via its Guid.

Definition at line 34 of file Window.ixx.

Public Constructors

Window()

helios::window::Window::Window (const Window &)
delete

Window()

helios::window::Window::Window (Window &&)
noexcept default

Definition at line 92 of file Window.ixx.

Reference Window.

Window()

helios::window::Window::Window (std::unique_ptr< helios::rendering::RenderTarget > renderTarget, const WindowConfig & cfg)
inline explicit

Constructs a new Window based on the provided configuration.

Initializes basic properties such as width, height and the viewport of the window.

Parameters
renderTarget

The RenderTarget for this window. Ownership is transferred.

cfg

A const ref to the window configuration used for this instance.

Exceptions
std::invalid_argument

if renderTarget is a nullptr.

Definition at line 106 of file Window.ixx.

106 explicit Window(
107 std::unique_ptr<helios::rendering::RenderTarget> renderTarget,
108 const WindowConfig& cfg
109 ) :
110 renderTarget_(std::move(renderTarget)),
111 width_(cfg.width),
112 height_(cfg.height),
113 title_(cfg.title),
114 aspectRatioNumer_(cfg.aspectRatioNumer),
115 aspectRatioDenom_(cfg.aspectRatioDenom),
116 guid_(util::Guid::generate()) {
117
118 if (!renderTarget_) {
119 throw std::invalid_argument("Window received a nullptr renderTarget");
120 }
121 }

References aspectRatioDenom_, aspectRatioNumer_, height, height_, renderTarget, renderTarget_, title_, width, width_ and Window.

Public Destructor

~Window()

virtual helios::window::Window::~Window ()
virtual default

Definition at line 85 of file Window.ixx.

Public Operators

operator=()

Window & helios::window::Window::operator= (const Window &)
delete

Definition at line 89 of file Window.ixx.

Reference Window.

operator=()

Window & helios::window::Window::operator= (Window &&)
noexcept default

Definition at line 93 of file Window.ixx.

Reference Window.

operator==()

virtual bool helios::window::Window::operator== (const Window & win)
inline noexcept virtual

Compares two window instances for equality.

Two windows are considered equal if their GUIDs are equal.

Parameters
win

The window to compare with this window.

Returns

true if both windows are equal, otherwise false.

Definition at line 255 of file Window.ixx.

255 virtual bool operator==(const Window& win) const noexcept {
256 return guid_ == win.guid();
257 }

Reference Window.

Public Member Functions

addViewport()

std::shared_ptr< helios::rendering::Viewport > helios::window::Window::addViewport (std::shared_ptr< helios::rendering::Viewport > viewport)
inline

Adds the viewport to the underlying RenderTarget of this Window.

Parameters
viewport

The Viewport instance to add to the RenderTarget owned by this Window.

Returns

The Viewport added to the Window's RenderTarget as a shared pointer.

Definition at line 224 of file Window.ixx.

224 std::shared_ptr<helios::rendering::Viewport> addViewport(std::shared_ptr<helios::rendering::Viewport> viewport) const {
225 return renderTarget_->addViewport(std::move(viewport));
226 }

Reference renderTarget_.

guid()

const util::Guid & helios::window::Window::guid ()
inline nodiscard noexcept

Returns the unique guid for this window instance.

Returns

A const reference to the Guid of this window.

Definition at line 153 of file Window.ixx.

153 [[nodiscard]] const util::Guid& guid() const noexcept {
154 return guid_;
155 }

Referenced by helios::ext::glfw::app::GLFWApplication::setCurrent.

height()

int helios::window::Window::height ()
inline nodiscard noexcept

Returns the current height of this window.

Returns

The current height of this window.

Definition at line 203 of file Window.ixx.

203 [[nodiscard]] int height() const noexcept {
204 return height_;
205 }

Reference height_.

Referenced by Window.

pollEvents()

virtual void helios::window::Window::pollEvents ()
noexcept

Poll this window for native window events.

This method processes pending events from the native window system. Implementing APIs should call this method at regular intervals, e.g. once per frame.

Definition at line 185 of file Window.ixx.

Reference pollEvents.

Referenced by pollEvents.

renderTarget()

helios::rendering::RenderTarget & helios::window::Window::renderTarget ()
inline nodiscard noexcept

Returns the RenderTarget associated with this Window.

Returns

A reference to the RenderTarget of this window.

Definition at line 213 of file Window.ixx.

213 [[nodiscard]] helios::rendering::RenderTarget& renderTarget() const noexcept {
214 return *renderTarget_;
215 }

Reference renderTarget_.

Referenced by helios::ext::glfw::window::GLFWWindow::GLFWWindow and Window.

setShouldClose()

virtual void helios::window::Window::setShouldClose (bool close)

Sets the close flag of this window.

Parameters
close

True to indicate this window should be closed, false otherwise.

See Also

shouldClose()

Definition at line 145 of file Window.ixx.

shouldClose()

virtual bool helios::window::Window::shouldClose ()
nodiscard

Checks if the window has received a close request.

Implementing APIs should consider this flag at regular intervals (e.g. each frame) to determine whether this window should be closed.

Returns

true if the window should be closed, otherwise false.

See Also

setShouldClose()

Definition at line 134 of file Window.ixx.

show()

virtual bool helios::window::Window::show ()
noexcept

Shows the underlying native window.

Derived classes must implement the platform-specific logic to show this window.

Returns

true if showing the window succeeded, otherwise false.

Definition at line 166 of file Window.ixx.

swapBuffers()

virtual void helios::window::Window::swapBuffers ()
noexcept

Instructs the rendering system to swap the front and back buffers.

Makes the back buffer's content visible on the screen. Derived classes must implement the platform-specific buffer mechanism.

Definition at line 175 of file Window.ixx.

Reference swapBuffers.

Referenced by swapBuffers.

viewportSnapshots()

std::vector< helios::rendering::ViewportSnapshot > helios::window::Window::viewportSnapshots ()
inline nodiscard

Returns snapshots of all viewports with assigned IDs.

Collects immutable ViewportSnapshot objects from all viewports that have a valid ViewportId. Useful for passing viewport state to systems that need frame-consistent viewport data.

Returns

A vector of ViewportSnapshot objects.

Definition at line 237 of file Window.ixx.

237 [[nodiscard]] std::vector<helios::rendering::ViewportSnapshot> viewportSnapshots() {
238 std::vector<helios::rendering::ViewportSnapshot> snapshots;
239 for (auto& viewport : renderTarget_->viewports()) {
240 if (viewport->viewportId()) {
241 snapshots.push_back(viewport->snapshot());
242 }
243 }
244 return snapshots;
245 }

Reference renderTarget_.

width()

int helios::window::Window::width ()
inline nodiscard noexcept

Returns the current width of this window.

Returns

The current width of this window.

Definition at line 193 of file Window.ixx.

193 [[nodiscard]] int width() const noexcept {
194 return width_;
195 }

References width and width_.

Referenced by width and Window.

Protected Member Attributes

aspectRatioDenom_

int helios::window::Window::aspectRatioDenom_ = 0
protected

Aspect ratio denominator.

Aspect ratio is enforced only when BOTH aspectRatioNumer and aspectRatioDenom are non-zero.

Definition at line 76 of file Window.ixx.

Referenced by helios::ext::glfw::window::GLFWWindow::show and Window.

aspectRatioNumer_

int helios::window::Window::aspectRatioNumer_ = 0
protected

Aspect ratio numerator.

Aspect ratio is enforced only when BOTH aspectRatioNumer and aspectRatioDenom are non-zero.

Definition at line 69 of file Window.ixx.

Referenced by helios::ext::glfw::window::GLFWWindow::show and Window.

height_

int helios::window::Window::height_
protected

The current height of the window.

Definition at line 57 of file Window.ixx.

57 int height_;

Referenced by height, helios::ext::glfw::window::GLFWWindow::show and Window.

renderTarget_

std::unique_ptr<helios::rendering::RenderTarget> helios::window::Window::renderTarget_
protected

The default render target for this Window. The default RenderTarget represents the default framebuffer, e.g. the "0" FBO in OpenGL.

Definition at line 82 of file Window.ixx.

82 std::unique_ptr<helios::rendering::RenderTarget> renderTarget_;

Referenced by addViewport, renderTarget, viewportSnapshots and Window.

title_

std::string helios::window::Window::title_
protected

The title of the window.

Definition at line 62 of file Window.ixx.

62 std::string title_;

Referenced by helios::ext::glfw::window::GLFWWindow::show and Window.

width_

int helios::window::Window::width_
protected

The current width of the window.

Definition at line 52 of file Window.ixx.

52 int width_;

Referenced by helios::ext::glfw::window::GLFWWindow::show, width and Window.

Private Member Attributes

guid_

util::Guid helios::window::Window::guid_

Unique identifier for this window instance.

Definition at line 40 of file Window.ixx.

40 util::Guid guid_;

Protected Static Attributes

logger_

const helios::util::log::Logger& helios::window::Window::logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE)
protected static

The logger used with this Window instance.

Definition at line 47 of file Window.ixx.

Referenced by helios::ext::glfw::window::GLFWWindow::show.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.