cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
cae::GLFW Class Referencefinal

Class for the GLFW plugin. More...

#include <GLFW.hpp>

+ Inheritance diagram for cae::GLFW:
+ Collaboration diagram for cae::GLFW:

Public Member Functions

 GLFW ()=default
 
 ~GLFW () override=default
 
 GLFW (const GLFW &)=delete
 
GLFWoperator= (const GLFW &)=delete
 
 GLFW (GLFW &&)=delete
 
GLFWoperator= (GLFW &&)=delete
 
std::string getName () const override
 Get the name of the plugin.
 
utl::PluginType getType () const override
 Get the type of the plugin.
 
utl::PluginPlatform getPlatform () const override
 Get the handled platform of the plugin.
 
bool create (const std::string &name, WindowSize size) override
 Create a window with the given name and size.
 
void close () override
 Close the window.
 
NativeWindowHandle getNativeHandle () const override
 Get the native window handle.
 
WindowSize getWindowSize () const override
 Get the current window size.
 
void setIcon (const std::string &path) const override
 Set the window icon from the given image path.
 
bool shouldClose () const override
 Check if the window should close.
 
void pollEvents () override
 Poll window events.
 
bool pollEvent (WindowEvent &event) override
 Poll window events into outEvent.
 
bool wasResized () const override
 Check if the window was resized.
 
void resetResizedFlag () override
 Reset the resized flag.
 
- Public Member Functions inherited from cae::AWindow
 ~AWindow () override=default
 
- Public Member Functions inherited from cae::IWindow
 ~IWindow () override=default
 
- Public Member Functions inherited from utl::IPlugin
virtual ~IPlugin ()=default
 

Static Private Member Functions

static void frameBufferResizeCallback (GLFWwindow *window, int width, int height)
 
static void keyCallback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
static void mouseButtonCallback (GLFWwindow *window, int button, int action, int mods)
 
static void cursorPosCallback (GLFWwindow *window, double x, double y)
 
static void scrollCallback (GLFWwindow *window, double xoffset, double yoffset)
 

Private Attributes

std::queue< WindowEventm_eventQueue
 
GLFWwindow * m_window = nullptr
 
WindowSize m_frameBufferSize {}
 
bool m_frameBufferResized = false
 

Detailed Description

Class for the GLFW plugin.

Definition at line 30 of file GLFW.hpp.

Constructor & Destructor Documentation

◆ GLFW() [1/3]

cae::GLFW::GLFW ( )
default

◆ ~GLFW()

cae::GLFW::~GLFW ( )
overridedefault

◆ GLFW() [2/3]

cae::GLFW::GLFW ( const GLFW & )
delete

◆ GLFW() [3/3]

cae::GLFW::GLFW ( GLFW && )
delete

Member Function Documentation

◆ close()

void cae::GLFW::close ( )
overridevirtual

Close the window.

Implements cae::IWindow.

Definition at line 302 of file glfw.cpp.

◆ create()

bool cae::GLFW::create ( const std::string & name,
WindowSize size )
overridevirtual

Create a window with the given name and size.

Parameters
nameWindow name
sizeWindow size
Returns
True if the window was created successfully

Implements cae::IWindow.

Definition at line 268 of file glfw.cpp.

References cae::WindowSize::height, utl::Logger::log(), utl::WARNING, and cae::WindowSize::width.

+ Here is the call graph for this function:

◆ cursorPosCallback()

void cae::GLFW::cursorPosCallback ( GLFWwindow * window,
double x,
double y )
staticprivate

Definition at line 217 of file glfw.cpp.

References cae::MouseMove, and cae::WindowEvent::type.

◆ frameBufferResizeCallback()

void cae::GLFW::frameBufferResizeCallback ( GLFWwindow * window,
int width,
int height )
staticprivate

Definition at line 249 of file glfw.cpp.

References m_frameBufferResized, cae::Resize, and cae::WindowEvent::type.

◆ getName()

std::string cae::GLFW::getName ( ) const
inlinenodiscardoverridevirtual

Get the name of the plugin.

Returns
The name of the plugin

Implements utl::IPlugin.

Definition at line 42 of file GLFW.hpp.

◆ getNativeHandle()

cae::NativeWindowHandle cae::GLFW::getNativeHandle ( ) const
nodiscardoverridevirtual

Get the native window handle.

Returns
Native window handle

Implements cae::IWindow.

Definition at line 320 of file glfw.cpp.

References cae::NativeWindowHandle::window.

◆ getPlatform()

utl::PluginPlatform cae::GLFW::getPlatform ( ) const
inlinenodiscardoverridevirtual

Get the handled platform of the plugin.

Returns
The handled platform of the plugin

Implements utl::IPlugin.

Definition at line 44 of file GLFW.hpp.

References utl::ALL.

◆ getType()

utl::PluginType cae::GLFW::getType ( ) const
inlinenodiscardoverridevirtual

Get the type of the plugin.

Returns
The type of the plugin

Implements utl::IPlugin.

Definition at line 43 of file GLFW.hpp.

References utl::WINDOW.

◆ getWindowSize()

cae::WindowSize cae::GLFW::getWindowSize ( ) const
nodiscardoverridevirtual

Get the current window size.

Returns
Current window size

Implements cae::IWindow.

Definition at line 312 of file glfw.cpp.

◆ keyCallback()

void cae::GLFW::keyCallback ( GLFWwindow * window,
int key,
int scancode,
int action,
int mods )
staticprivate

Definition at line 176 of file glfw.cpp.

References cae::KeyDown, cae::KeyUp, translateKey(), and cae::WindowEvent::type.

+ Here is the call graph for this function:

◆ mouseButtonCallback()

void cae::GLFW::mouseButtonCallback ( GLFWwindow * window,
int button,
int action,
int mods )
staticprivate

Definition at line 202 of file glfw.cpp.

References cae::MouseButtonDown, cae::MouseButtonUp, and cae::WindowEvent::type.

◆ operator=() [1/2]

GLFW & cae::GLFW::operator= ( const GLFW & )
delete

◆ operator=() [2/2]

GLFW & cae::GLFW::operator= ( GLFW && )
delete

◆ pollEvent()

bool cae::GLFW::pollEvent ( WindowEvent & outEvent)
overridevirtual

Poll window events into outEvent.

Parameters
outEventEvent to be filled
Returns
True if an event was polled

Implements cae::IWindow.

Definition at line 348 of file glfw.cpp.

◆ pollEvents()

void cae::GLFW::pollEvents ( )
inlineoverridevirtual

Poll window events.

Implements cae::IWindow.

Definition at line 55 of file GLFW.hpp.

◆ resetResizedFlag()

void cae::GLFW::resetResizedFlag ( )
inlineoverridevirtual

Reset the resized flag.

Implements cae::IWindow.

Definition at line 59 of file GLFW.hpp.

References m_frameBufferResized.

◆ scrollCallback()

void cae::GLFW::scrollCallback ( GLFWwindow * window,
double xoffset,
double yoffset )
staticprivate

Definition at line 233 of file glfw.cpp.

References cae::MouseScroll, and cae::WindowEvent::type.

◆ setIcon()

void cae::GLFW::setIcon ( const std::string & path) const
overridevirtual

Set the window icon from the given image path.

Parameters
pathPath to the icon image
Returns
True if the icon was set successfully

Implements cae::IWindow.

Definition at line 336 of file glfw.cpp.

References utl::Image::height, utl::Logger::log(), utl::Image::pixels, utl::WARNING, and utl::Image::width.

+ Here is the call graph for this function:

◆ shouldClose()

bool cae::GLFW::shouldClose ( ) const
inlinenodiscardoverridevirtual

Check if the window should close.

Returns
True if the window should close

Implements cae::IWindow.

Definition at line 54 of file GLFW.hpp.

References m_window.

◆ wasResized()

bool cae::GLFW::wasResized ( ) const
inlinenodiscardoverridevirtual

Check if the window was resized.

Returns
True if the window was resized

Implements cae::IWindow.

Definition at line 58 of file GLFW.hpp.

References m_frameBufferResized.

Member Data Documentation

◆ m_eventQueue

std::queue<WindowEvent> cae::GLFW::m_eventQueue
private

Definition at line 68 of file GLFW.hpp.

◆ m_frameBufferResized

bool cae::GLFW::m_frameBufferResized = false
private

Definition at line 72 of file GLFW.hpp.

Referenced by frameBufferResizeCallback(), resetResizedFlag(), and wasResized().

◆ m_frameBufferSize

WindowSize cae::GLFW::m_frameBufferSize {}
private

Definition at line 71 of file GLFW.hpp.

◆ m_window

GLFWwindow* cae::GLFW::m_window = nullptr
private

Definition at line 70 of file GLFW.hpp.

Referenced by shouldClose().


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