Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::core::Window Class Reference

#include <OxygenEngine/core/window.h>

Public Member Functions

 Window (const std::string &title, bool is_visible=true)
 Generate and open a fullscreen window.
 
 Window (const glm::ivec2 &dimensions, const std::string &title, bool is_visible=true)
 Generate and open a new window.
 
void setTitle (const std::string &title)
 Set window title.
 
void processEvents ()
 Process window events.
 
void beginRender ()
 Begin rendering to the main framebuffer.
 
void endRender ()
 End framebuffer rendering.
 
void lockCursor ()
 Hide cursor and lock it at window center.
 
void setCursorVisible (bool visible=true)
 
void setCursorPosition (const double &x, const double &y)
 Set cursor position relative to the window.
 
glm::vec2 getCursorPosition (const bool &absolute=false)
 Get cursor position relative to the window or screen.
 
void moveToCenter ()
 Center the window.
 
void show ()
 Display the window.
 
void hide ()
 Hide the window.
 
void blink ()
 Make the window blink to get user attention.
 
void makeContextCurrent ()
 
void setPosition (const glm::ivec2 &)
 Set window position (excluding decorations)
 
void setDimensions (const glm::ivec2 &)
 Set window dimensions (excluding decorations)
 
const glm::ivec2 getPosition () const
 Get window position (excluding decorations)
 
const glm::ivec2 getDimensions () const
 Get window dimensions (excluding decorations)
 
float getAspectRatio () const noexcept
 Get window aspect ratio.
 
glm::ivec2 getBufferDimensions ()
 Get main framebuffer dimensions.
 
void setShouldClose (bool can_close=true)
 Tell the window to close.
 
bool shouldClose () const
 Check if nothing prevented the window to close.
 
EventHandlergetEventHandler ()
 Get a reference to the event handler bound to this window.
 
const EventHandlergetEventHandler () const
 Get a const reference to the event handler bound to this window.
 
const std::string getClipboardContent ()
 Returns the contents of the system clipboard, if the content contains or is convertible to a UTF-8 encoded string.
 
void setClipboardContent (const std::string &contents)
 Set the contents of the system clipboard to the UTF-8 string.
 
bool isHovered () const noexcept
 Check if the cursor is currently directly over the content area of the window, with no other windows between.
 
bool isFocused () const noexcept
 Check if the window has input focus.
 
bool isAlwaysOnTop () const noexcept
 Check if the window is forced at foreground.
 
bool isDecorated () const noexcept
 Check if the window has decorations (title bar and OS specific borders)
 
bool isResizable () const noexcept
 Check if the window is resizable by the user.
 
bool isMousePasthrough () const noexcept
 Check if the window is transparent to mouse input, letting any mouse events pass through to whatever window is behind it.
 
void setAlwaysOnTop (const bool enable=true) noexcept
 Toggle if the window should be always on top.
 
void setDecorated (const bool enable=true) noexcept
 Toggle the decorations (title bar and OS specific borders)
 
void setResizable (const bool enable=true) noexcept
 Toggle to let the window being resizable by the user.
 
void setMousePasthrough (const bool enable=true) noexcept
 Toggle to let the window being transparent to mouse input.
 

Detailed Description

Window wrapper containing an Graphical context

Constructor & Destructor Documentation

◆ Window() [1/2]

oe::core::Window::Window ( const std::string &  title,
bool  is_visible = true 
)

Generate and open a fullscreen window.

Parameters
titlewindow title
is_visibleDoes the window is visible after creation

◆ Window() [2/2]

oe::core::Window::Window ( const glm::ivec2 &  dimensions,
const std::string &  title,
bool  is_visible = true 
)

Generate and open a new window.

Parameters
dimensionswindow dimensions
titlewindow title
is_visibleDoes the window is visible after creation

Member Function Documentation

◆ blink()

void oe::core::Window::blink ( )

Make the window blink to get user attention.

Note
actual effect depends between platforms, but a common effect is the blink of the window in taskbar

◆ endRender()

void oe::core::Window::endRender ( )

End framebuffer rendering.

Note
buffer will be swapped after this function is called

◆ getClipboardContent()

const std::string oe::core::Window::getClipboardContent ( )

Returns the contents of the system clipboard, if the content contains or is convertible to a UTF-8 encoded string.

Returns
Cliboard content or an empty string if its content isn't convertible to a string

◆ getCursorPosition()

glm::vec2 oe::core::Window::getCursorPosition ( const bool &  absolute = false)

Get cursor position relative to the window or screen.

Parameters
absoluteSet to true set get screen coordinates

◆ isResizable()

bool oe::core::Window::isResizable ( ) const
noexcept

Check if the window is resizable by the user.

Note
Even if its false, the application can still resize the window by using setDimensions()

◆ lockCursor()

void oe::core::Window::lockCursor ( )

Hide cursor and lock it at window center.

Note
use this function if you need camera controls with cursor (for example: Making a FPS Camera control)

◆ setAlwaysOnTop()

void oe::core::Window::setAlwaysOnTop ( const bool  enable = true)
noexcept

Toggle if the window should be always on top.

Parameters
enableEnabled

◆ setClipboardContent()

void oe::core::Window::setClipboardContent ( const std::string &  contents)

Set the contents of the system clipboard to the UTF-8 string.

Parameters
contentsstring to sent to the clipboard

◆ setDecorated()

void oe::core::Window::setDecorated ( const bool  enable = true)
noexcept

Toggle the decorations (title bar and OS specific borders)

Parameters
enableEnabled

◆ setMousePasthrough()

void oe::core::Window::setMousePasthrough ( const bool  enable = true)
noexcept

Toggle to let the window being transparent to mouse input.

Parameters
enableEnabled

◆ setResizable()

void oe::core::Window::setResizable ( const bool  enable = true)
noexcept

Toggle to let the window being resizable by the user.

Parameters
enableEnabled

◆ setTitle()

void oe::core::Window::setTitle ( const std::string &  title)

Set window title.

Parameters
titlewindow title

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