Wasabi
Public Member Functions | Friends | List of all members
WWindowsWindowAndInputComponent Class Reference

#include <WWindowsWindowAndInputComponent.hpp>

Inheritance diagram for WWindowsWindowAndInputComponent:
WWindowAndInputComponent

Public Member Functions

 WWindowsWindowAndInputComponent (class Wasabi *const app)
 
virtual WError Initialize (int width, int height)
 
virtual bool Loop ()
 
virtual void Cleanup ()
 
HWND GetWindow () const
 
HINSTANCE GetInstance () const
 
void SetWndProcCallback (LRESULT(CALLBACK *proc)(Wasabi *, HWND, UINT, WPARAM, LPARAM, bool))
 
virtual void * GetPlatformHandle () const
 
virtual void * GetWindowHandle () const
 
virtual VkSurfaceKHR GetVulkanSurface () const
 
virtual void ShowErrorMessage (std::string error, bool warning=false)
 
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
 
virtual double MouseX (W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT, uint32_t vpID=0) const
 
virtual double MouseY (W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT, uint32_t vpID=0) const
 
virtual double MouseZ () const
 
virtual bool MouseInScreen (W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT, uint32_t vpID=0) const
 
virtual void SetMousePosition (double x, double y, W_MOUSEPOSTYPE posT=MOUSEPOS_VIEWPORT)
 
virtual void SetMouseZ (double value)
 
virtual void ShowCursor (bool bShow)
 
virtual void SetCursorMotionMode (bool bEnable)
 
virtual void SetQuitKeys (bool escape=true, bool cmdW=true)
 
virtual bool KeyDown (uint32_t key) const
 
virtual void InsertRawInput (uint32_t key, bool state)
 
- Public Member Functions inherited from WWindowAndInputComponent
 WWindowAndInputComponent (class Wasabi *const app)
 
virtual void GetVulkanRequiredExtensions (std::vector< const char * > &extensions)=0
 

Friends

LRESULT CALLBACK hMainWndProc (HWND hWnd, uint32_t msg, WPARAM wParam, LPARAM lParam)
 

Additional Inherited Members

- Protected Attributes inherited from WWindowAndInputComponent
class Wasabim_app
 

Detailed Description

Creating an instance of this class creates the following engine parameters:

Member Function Documentation

◆ Cleanup()

virtual void WWindowsWindowAndInputComponent::Cleanup ( )
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.

Implements WWindowAndInputComponent.

◆ GetFullScreenState()

virtual bool WWindowsWindowAndInputComponent::GetFullScreenState ( ) const
virtual

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

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

Reimplemented from WWindowAndInputComponent.

◆ GetInstance()

HINSTANCE WWindowsWindowAndInputComponent::GetInstance ( ) const

Retrieves the Windows application instance handle (HINSTANCE).

Returns
Instance handle

◆ GetPlatformHandle()

virtual void* WWindowsWindowAndInputComponent::GetPlatformHandle ( ) const
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

Implements WWindowAndInputComponent.

◆ GetVulkanSurface()

virtual VkSurfaceKHR WWindowsWindowAndInputComponent::GetVulkanSurface ( ) const
virtual

Retrieves the Vulkan Surface that can be used to render.

Returns
The created VkSurfaceKHR

Implements WWindowAndInputComponent.

◆ GetWindow()

HWND WWindowsWindowAndInputComponent::GetWindow ( ) const

Retrieves the window (HWND) handle.

Returns
Window handle

◆ GetWindowHandle()

virtual void* WWindowsWindowAndInputComponent::GetWindowHandle ( ) const
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

Implements WWindowAndInputComponent.

◆ GetWindowHeight()

virtual uint32_t WWindowsWindowAndInputComponent::GetWindowHeight ( bool  framebuffer = true) const
virtual

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 from WWindowAndInputComponent.

◆ GetWindowPositionX()

virtual int WWindowsWindowAndInputComponent::GetWindowPositionX ( ) const
virtual

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

Returns
X-coordinate of the window on the screen

Reimplemented from WWindowAndInputComponent.

◆ GetWindowPositionY()

virtual int WWindowsWindowAndInputComponent::GetWindowPositionY ( ) const
virtual

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

Returns
Y-coordinate of the window on the screen

Reimplemented from WWindowAndInputComponent.

◆ GetWindowWidth()

virtual uint32_t WWindowsWindowAndInputComponent::GetWindowWidth ( bool  framebuffer = true) const
virtual

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 from WWindowAndInputComponent.

◆ Initialize()

virtual WError WWindowsWindowAndInputComponent::Initialize ( int  width,
int  height 
)
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

Implements WWindowAndInputComponent.

◆ InsertRawInput()

virtual void WWindowsWindowAndInputComponent::InsertRawInput ( uint32_t  key,
bool  state 
)
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

Implements WWindowAndInputComponent.

◆ KeyDown()

virtual bool WWindowsWindowAndInputComponent::KeyDown ( uint32_t  key) const
virtual

Checks if a key is currently pressed.

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

Implements WWindowAndInputComponent.

◆ Loop()

virtual bool WWindowsWindowAndInputComponent::Loop ( )
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)

Implements WWindowAndInputComponent.

◆ MaximizeWindow()

virtual void WWindowsWindowAndInputComponent::MaximizeWindow ( )
virtual

Maximizes the window.

Reimplemented from WWindowAndInputComponent.

◆ MinimizeWindow()

virtual void WWindowsWindowAndInputComponent::MinimizeWindow ( )
virtual

Minimizes the window.

Reimplemented from WWindowAndInputComponent.

◆ MouseClick()

virtual bool WWindowsWindowAndInputComponent::MouseClick ( W_MOUSEBUTTON  button) const
virtual

Check if a mouse button is clicked.

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

Implements WWindowAndInputComponent.

◆ MouseInScreen()

virtual bool WWindowsWindowAndInputComponent::MouseInScreen ( W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT,
uint32_t  vpID = 0 
) const
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

Implements WWindowAndInputComponent.

◆ MouseX()

virtual double WWindowsWindowAndInputComponent::MouseX ( W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT,
uint32_t  vpID = 0 
) const
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

Implements WWindowAndInputComponent.

◆ MouseY()

virtual double WWindowsWindowAndInputComponent::MouseY ( W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT,
uint32_t  vpID = 0 
) const
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

Implements WWindowAndInputComponent.

◆ MouseZ()

virtual double WWindowsWindowAndInputComponent::MouseZ ( ) const
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

Implements WWindowAndInputComponent.

◆ RestoreWindow()

virtual uint32_t WWindowsWindowAndInputComponent::RestoreWindow ( )
virtual

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 from WWindowAndInputComponent.

◆ SetCursorMotionMode()

virtual void WWindowsWindowAndInputComponent::SetCursorMotionMode ( bool  bEnable)
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

Implements WWindowAndInputComponent.

◆ SetFullScreenState()

virtual void WWindowsWindowAndInputComponent::SetFullScreenState ( bool  bFullScreen)
virtual

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 from WWindowAndInputComponent.

◆ SetMousePosition()

virtual void WWindowsWindowAndInputComponent::SetMousePosition ( double  x,
double  y,
W_MOUSEPOSTYPE  posT = MOUSEPOS_VIEWPORT 
)
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

Implements WWindowAndInputComponent.

◆ SetMouseZ()

virtual void WWindowsWindowAndInputComponent::SetMouseZ ( double  value)
virtual

Sets the value of the mouse scroll.

Parameters
valueNew value to set

Implements WWindowAndInputComponent.

◆ SetQuitKeys()

virtual void WWindowsWindowAndInputComponent::SetQuitKeys ( bool  escape = true,
bool  cmdW = true 
)
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

Implements WWindowAndInputComponent.

◆ SetWindowMaximumSize()

virtual void WWindowsWindowAndInputComponent::SetWindowMaximumSize ( int  maxX,
int  maxY 
)
virtual

Sets the maximum size the window can have.

Parameters
maxXMaximum width
maxYMaximum height

Reimplemented from WWindowAndInputComponent.

◆ SetWindowMinimumSize()

virtual void WWindowsWindowAndInputComponent::SetWindowMinimumSize ( int  minX,
int  minY 
)
virtual

Sets the minimum size the window can have.

Parameters
minXMinimum width
minYMinimum height

Reimplemented from WWindowAndInputComponent.

◆ SetWindowPosition()

virtual void WWindowsWindowAndInputComponent::SetWindowPosition ( int  x,
int  y 
)
virtual

Sets the position of the window on screen.

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

Reimplemented from WWindowAndInputComponent.

◆ SetWindowSize()

virtual void WWindowsWindowAndInputComponent::SetWindowSize ( int  width,
int  height 
)
virtual

Sets the size of the window.

Parameters
widthNew window width
heightNew window height

Reimplemented from WWindowAndInputComponent.

◆ SetWindowTitle()

virtual void WWindowsWindowAndInputComponent::SetWindowTitle ( const char *const  title)
virtual

Sets the title of the window.

Parameters
titleNew title for the window

Reimplemented from WWindowAndInputComponent.

◆ SetWndProcCallback()

void WWindowsWindowAndInputComponent::SetWndProcCallback ( LRESULT(CALLBACK *proc)(Wasabi *, HWND, UINT, WPARAM, LPARAM, bool)  )

Assigns a function to intercept window procedure callbacks. This callback will be called once before the default handler is run by Wasabi and once after.

Parameters
procA function pointer which will be called given the Wasabi instance, window proc arguments and a boolean set to true on the pre-processing call and false on the second, after-processing call

◆ ShowCursor()

virtual void WWindowsWindowAndInputComponent::ShowCursor ( bool  bShow)
virtual

Shows or hides the mouse cursor.

Parameters
bShowWhether to show or hide the cursor

Implements WWindowAndInputComponent.

◆ ShowErrorMessage()

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

Displays a platform-specific error or warning message.

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

Implements WWindowAndInputComponent.


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