Wasabi
Public Member Functions | Protected Attributes | List of all members
WWindowAndInputComponent Class Referenceabstract

#include <WWindowAndInputComponent.hpp>

Inheritance diagram for WWindowAndInputComponent:
WGLFWWindowAndInputComponent WWindowsWindowAndInputComponent

Public Member Functions

 WWindowAndInputComponent (class Wasabi *const app)
 
virtual WError Initialize (int width, int height)=0
 
virtual bool Loop ()=0
 
virtual void Cleanup ()=0
 
virtual void * GetPlatformHandle () const =0
 
virtual void * GetWindowHandle () const =0
 
virtual VkSurfaceKHR GetVulkanSurface () const =0
 
virtual void GetVulkanRequiredExtensions (std::vector< const char * > &extensions)=0
 
virtual void ShowErrorMessage (std::string error, bool warning=false)=0
 
virtual void SetWindowTitle (const char *const title)
 
virtual void SetWindowPosition (int x, int y)
 
virtual void SetWindowSize (int width, int height)
 
virtual void MaximizeWindow ()
 
virtual void MinimizeWindow ()
 
virtual uint32_t RestoreWindow ()
 
virtual uint32_t GetWindowWidth (bool framebuffer=true) const
 
virtual uint32_t GetWindowHeight (bool framebuffer=true) const
 
virtual int GetWindowPositionX () const
 
virtual int GetWindowPositionY () const
 
virtual void SetFullScreenState (bool bFullScreen)
 
virtual bool GetFullScreenState () const
 
virtual void SetWindowMinimumSize (int minX, int minY)
 
virtual void SetWindowMaximumSize (int maxX, int maxY)
 
virtual bool MouseClick (W_MOUSEBUTTON button) const =0
 
virtual double MouseX (W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT, uint32_t vpID=0) const =0
 
virtual double MouseY (W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT, uint32_t vpID=0) const =0
 
virtual double MouseZ () const =0
 
virtual bool MouseInScreen (W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT, uint32_t vpID=0) const =0
 
virtual void SetMousePosition (double x, double y, W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT)=0
 
virtual void SetMouseZ (double value)=0
 
virtual void ShowCursor (bool bShow)=0
 
virtual void SetCursorMotionMode (bool bEnable)=0
 
virtual void SetQuitKeys (bool escape=true, bool cmdW=true)=0
 
virtual bool KeyDown (uint32_t key) const =0
 
virtual void InsertRawInput (uint32_t key, bool state)=0
 

Protected Attributes

class Wasabim_app
 

Detailed Description

This defines the bare minimum requirements for an window/input component to be usable by Wasabi.

Member Function Documentation

◆ Cleanup()

virtual void WWindowAndInputComponent::Cleanup ( )
pure virtual

Thus function is called by Wasabi before it exists to allow the window component to cleanup its resources. This function must be implemented by a child class.

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetFullScreenState()

virtual bool WWindowAndInputComponent::GetFullScreenState ( ) const
inlinevirtual

Retrieves the full-screen state of the window, see SetFullScreenState().

Returns
true if the window is in full-screen, false otherwise

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetPlatformHandle()

virtual void* WWindowAndInputComponent::GetPlatformHandle ( ) const
pure virtual

Retrieves the platform-specific handle needed by Vulkan. For example, on Windows, this must return the HINSTANCE of the application.

Returns
The platform-specific application handle

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetVulkanRequiredExtensions()

virtual void WWindowAndInputComponent::GetVulkanRequiredExtensions ( std::vector< const char * > &  extensions)
pure virtual

Retrieves the Vulkan extensions required to run this window manager.

Parameters
extensionsA vector to be populated with required extensions

Implemented in WGLFWWindowAndInputComponent.

◆ GetVulkanSurface()

virtual VkSurfaceKHR WWindowAndInputComponent::GetVulkanSurface ( ) const
pure virtual

Retrieves the Vulkan Surface that can be used to render.

Returns
The created VkSurfaceKHR

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetWindowHandle()

virtual void* WWindowAndInputComponent::GetWindowHandle ( ) const
pure virtual

Retrieves the platform-specific window handle. For example, on Windows, this must return the HWND created by Initialize().

Returns
The platform-specific window handle

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetWindowHeight()

virtual uint32_t WWindowAndInputComponent::GetWindowHeight ( bool  framebuffer = true) const
inlinevirtual

Retrieves the height of the client area of the window.

Parameters
framebufferIf true, this function retrieves the height of the frame buffer inside the window. Otherwise it returns the height of the window
Returns
Height of the window's client area, in pixels

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetWindowPositionX()

virtual int WWindowAndInputComponent::GetWindowPositionX ( ) const
inlinevirtual

Retrieves the x-coordinate of the window on the screen.

Returns
X-coordinate of the window on the screen

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetWindowPositionY()

virtual int WWindowAndInputComponent::GetWindowPositionY ( ) const
inlinevirtual

Retrieves the y-coordinate of the window on the screen.

Returns
Y-coordinate of the window on the screen

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ GetWindowWidth()

virtual uint32_t WWindowAndInputComponent::GetWindowWidth ( bool  framebuffer = true) const
inlinevirtual

Retrieves the width of the client area of the window.

Parameters
framebufferIf true, this function retrieves the width of the frame buffer inside the window. Otherwise it returns the width of the window
Returns
Width of the window's client area, in pixels

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ Initialize()

virtual WError WWindowAndInputComponent::Initialize ( int  width,
int  height 
)
pure virtual

Initializes the window component if it is not initialized, otherwise it should resize the window (or equivalent surface) to the new size provided. This function must be implemented by a child class to initialize its resources and create/resize the window (or equivalent surface) for rendering.

Parameters
widthWidth of the window to be created/resized to
heightHeight of the window to be created/resized to
Returns
Error code, see WError.h

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ InsertRawInput()

virtual void WWindowAndInputComponent::InsertRawInput ( uint32_t  key,
bool  state 
)
pure virtual

Forcefully sets the state of a key.

Parameters
keyKey to set
stateState to set the key to, true being pressed and false being released

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ KeyDown()

virtual bool WWindowAndInputComponent::KeyDown ( uint32_t  key) const
pure virtual

Checks if a key is currently pressed.

Parameters
keyKey to check
Returns
true if key is pressed, false otherwise

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ Loop()

virtual bool WWindowAndInputComponent::Loop ( )
pure virtual

This function is called by Wasabi every frame to allow the window component to process any message pump or queue it has. This function must be implemented by a child class to perform any per-frame updates.

Returns
true if the frame should be rendered, false otherwise (if the window is not shown, e.g. minimized, this should return false)

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MaximizeWindow()

virtual void WWindowAndInputComponent::MaximizeWindow ( )
inlinevirtual

Maximizes the window.

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MinimizeWindow()

virtual void WWindowAndInputComponent::MinimizeWindow ( )
inlinevirtual

Minimizes the window.

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MouseClick()

virtual bool WWindowAndInputComponent::MouseClick ( W_MOUSEBUTTON  button) const
pure virtual

Check if a mouse button is clicked.

Parameters
buttonButton to check
Returns
true if button is clicked, false otherwise

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MouseInScreen()

virtual bool WWindowAndInputComponent::MouseInScreen ( W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT,
uint32_t  vpID = 0 
) const
pure virtual

Checks if the cursor is within the coordinate system posT.

Parameters
posTCoordinate system to check if the cursor is inside
vpIDUnused
Returns
true if the cursor is within the coordinate system posT, false otherwise

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MouseX()

virtual double WWindowAndInputComponent::MouseX ( W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT,
uint32_t  vpID = 0 
) const
pure virtual

Retrieves the x position of the system cursor.

Parameters
posTThe coordinate system which the position should be relative to
vpIDUnused
Returns
The x coordinate of the system cursor, relative to posT

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MouseY()

virtual double WWindowAndInputComponent::MouseY ( W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT,
uint32_t  vpID = 0 
) const
pure virtual

Retrieves the y position of the system cursor.

Parameters
posTThe coordinate system which the position should be relative to
vpIDUnused
Returns
The y coordinate of the system cursor, relative to posT

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ MouseZ()

virtual double WWindowAndInputComponent::MouseZ ( ) const
pure virtual

Retrieves the current scroll value of the mouse wheel. When the mouse wheel is spun, each tick will increment or decrement this value.

Returns
Current scroll value of the mouse wheel

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ RestoreWindow()

virtual uint32_t WWindowAndInputComponent::RestoreWindow ( )
inlinevirtual

Restores the window (if it was minimized, it should make it appear).

Returns
0 if the window was hidden before this call, nonzero otherwise

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetCursorMotionMode()

virtual void WWindowAndInputComponent::SetCursorMotionMode ( bool  bEnable)
pure virtual

Enables or disables cursor motion mode. In motion mode, the cursor is locked in place, hidden, and all mouse input is made to be relative to that locked position

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetFullScreenState()

virtual void WWindowAndInputComponent::SetFullScreenState ( bool  bFullScreen)
inlinevirtual

Sets the screen to full-screen or windowed.

Parameters
bFullScreentrue to set the window to full-screen mode, false to set it to windowed mode

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetMousePosition()

virtual void WWindowAndInputComponent::SetMousePosition ( double  x,
double  y,
W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT 
)
pure virtual

Sets the cursor position, relative to the rendering viewport.

Parameters
xNew mouse position x
yNew mouse position y
posTThe coordinate system which the position should be relative to

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetMouseZ()

virtual void WWindowAndInputComponent::SetMouseZ ( double  value)
pure virtual

Sets the value of the mouse scroll.

Parameters
valueNew value to set

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetQuitKeys()

virtual void WWindowAndInputComponent::SetQuitKeys ( bool  escape = true,
bool  cmdW = true 
)
pure virtual

Enables or disables closing the application when certain keys are pressed

Parameters
escapeWhether or not to quit when escape is pressed
cmdWWhether or not to quit when cmd-W (Mac) is pressed

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetWindowMaximumSize()

virtual void WWindowAndInputComponent::SetWindowMaximumSize ( int  maxX,
int  maxY 
)
inlinevirtual

Sets the maximum size the window can have.

Parameters
maxXMaximum width
maxYMaximum height

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetWindowMinimumSize()

virtual void WWindowAndInputComponent::SetWindowMinimumSize ( int  minX,
int  minY 
)
inlinevirtual

Sets the minimum size the window can have.

Parameters
minXMinimum width
minYMinimum height

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetWindowPosition()

virtual void WWindowAndInputComponent::SetWindowPosition ( int  x,
int  y 
)
inlinevirtual

Sets the position of the window on screen.

Parameters
xNew x-coordinate of the window
yNew y-coordinate of the window

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetWindowSize()

virtual void WWindowAndInputComponent::SetWindowSize ( int  width,
int  height 
)
inlinevirtual

Sets the size of the window.

Parameters
widthNew window width
heightNew window height

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ SetWindowTitle()

virtual void WWindowAndInputComponent::SetWindowTitle ( const char *const  title)
inlinevirtual

Sets the title of the window.

Parameters
titleNew title for the window

Reimplemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ ShowCursor()

virtual void WWindowAndInputComponent::ShowCursor ( bool  bShow)
pure virtual

Shows or hides the mouse cursor.

Parameters
bShowWhether to show or hide the cursor

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

◆ ShowErrorMessage()

virtual void WWindowAndInputComponent::ShowErrorMessage ( std::string  error,
bool  warning = false 
)
pure virtual

Displays a platform-specific error or warning message.

Parameters
errorError message to display
warningwhether or not to show a warning or error

Implemented in WWindowsWindowAndInputComponent, and WGLFWWindowAndInputComponent.

Member Data Documentation

◆ m_app

class Wasabi* WWindowAndInputComponent::m_app
protected

Pointer to the owner Wasabi class


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