|
Glfwx
0.1.0
C++ wrapper for GLFW
|
C++ wrapper for a GLFW window. More...
#include <Glfwx/Window.h>
Public Types | |
| enum | Hint { FOCUSED = GLFW_FOCUSED, ICONIFIED = GLFW_ICONIFIED, RESIZABLE = GLFW_RESIZABLE, VISIBLE = GLFW_VISIBLE, DECORATED = GLFW_DECORATED, AUTO_ICONIFY = GLFW_AUTO_ICONIFY, FLOATING = GLFW_FLOATING, MAXIMIZED = GLFW_MAXIMIZED, CENTER_CURSOR = GLFW_CENTER_CURSOR, TRANSPARENT_FRAMEBUFFER = GLFW_TRANSPARENT_FRAMEBUFFER, HOVERED = GLFW_HOVERED, FOCUS_ON_SHOW = GLFW_FOCUS_ON_SHOW, RED_BITS = GLFW_RED_BITS, GREEN_BITS = GLFW_GREEN_BITS, BLUE_BITS = GLFW_BLUE_BITS, ALPHA_BITS = GLFW_ALPHA_BITS, DEPTH_BITS = GLFW_DEPTH_BITS, STENCIL_BITS = GLFW_STENCIL_BITS, ACCUM_RED_BITS = GLFW_ACCUM_RED_BITS, ACCUM_GREEN_BITS = GLFW_ACCUM_GREEN_BITS, ACCUM_BLUE_BITS = GLFW_ACCUM_BLUE_BITS, ACCUM_ALPHA_BITS = GLFW_ACCUM_ALPHA_BITS, AUX_BUFFERS = GLFW_AUX_BUFFERS, STEREO = GLFW_STEREO, SAMPLES = GLFW_SAMPLES, SRGB_CAPABLE = GLFW_SRGB_CAPABLE, REFRESH_RATE = GLFW_REFRESH_RATE, DOUBLEBUFFER = GLFW_DOUBLEBUFFER, CLIENT_API = GLFW_CLIENT_API, CONTEXT_VERSION_MAJOR = GLFW_CONTEXT_VERSION_MAJOR, CONTEXT_VERSION_MINOR = GLFW_CONTEXT_VERSION_MINOR, CONTEXT_REVISION = GLFW_CONTEXT_REVISION, CONTEXT_ROBUSTNESS = GLFW_CONTEXT_ROBUSTNESS, OPENGL_FORWARD_COMPAT = GLFW_OPENGL_FORWARD_COMPAT, OPENGL_DEBUG_CONTEXT = GLFW_OPENGL_DEBUG_CONTEXT, OPENGL_PROFILE = GLFW_OPENGL_PROFILE, CONTEXT_RELEASE_BEHAVIOR = GLFW_CONTEXT_RELEASE_BEHAVIOR, CONTEXT_NO_ERROR = GLFW_CONTEXT_NO_ERROR, CONTEXT_CREATION_API = GLFW_CONTEXT_CREATION_API, SCALE_TO_MONITOR = GLFW_SCALE_TO_MONITOR, COCOA_RETINA_FRAMEBUFFER = GLFW_COCOA_RETINA_FRAMEBUFFER, COCOA_FRAME_NAME = GLFW_COCOA_FRAME_NAME, COCOA_GRAPHICS_SWITCHING = GLFW_COCOA_GRAPHICS_SWITCHING, X11_CLASS_NAME = GLFW_X11_CLASS_NAME, X11_INSTANCE_NAME = GLFW_X11_INSTANCE_NAME, JOYSTICK_HAT_BUTTONS = GLFW_JOYSTICK_HAT_BUTTONS, COCOA_CHDIR_RESOURCES = GLFW_COCOA_CHDIR_RESOURCES, COCOA_MENUBAR = GLFW_COCOA_MENUBAR } |
| Window hints. More... | |
| enum | Attribute { FOCUSED = GLFW_FOCUSED, ICONIFIED = GLFW_ICONIFIED, VISIBLE = GLFW_VISIBLE, DECORATED = GLFW_DECORATED, AUTO_ICONIFY = GLFW_AUTO_ICONIFY, RESIZABLE = GLFW_RESIZABLE, FLOATING = GLFW_FLOATING, MAXIMIZED = GLFW_MAXIMIZED, TRANSPARENT_FRAMEBUFFER = GLFW_TRANSPARENT_FRAMEBUFFER, HOVERED = GLFW_HOVERED, FOCUS_ON_SHOW = GLFW_FOCUS_ON_SHOW, CLIENT_API = GLFW_CLIENT_API, CONTEXT_VERSION_MAJOR = GLFW_CONTEXT_VERSION_MAJOR, CONTEXT_VERSION_MINOR = GLFW_CONTEXT_VERSION_MINOR, CONTEXT_REVISION = GLFW_CONTEXT_REVISION, CONTEXT_ROBUSTNESS = GLFW_CONTEXT_ROBUSTNESS, OPENGL_FORWARD_COMPAT = GLFW_OPENGL_FORWARD_COMPAT, OPENGL_DEBUG_CONTEXT = GLFW_OPENGL_DEBUG_CONTEXT, OPENGL_PROFILE = GLFW_OPENGL_PROFILE, CONTEXT_RELEASE_BEHAVIOR = GLFW_CONTEXT_RELEASE_BEHAVIOR, CONTEXT_NO_ERROR = GLFW_CONTEXT_NO_ERROR, CONTEXT_CREATION_API = GLFW_CONTEXT_CREATION_API } |
| Window attributes. More... | |
Public Member Functions | |
| Window (int width, int height, char const *title, Monitor *monitor=nullptr, GLFWwindow *share=nullptr) | |
| Constructor. More... | |
| virtual | ~Window () |
| Destructor. More... | |
| void | setTitle (char const *title) |
| Sets the title. More... | |
| void | setIcon (std::vector< GLFWimage > images=std::vector< GLFWimage >()) |
| Sets the window's icon. More... | |
| void | setPosition (int x, int y) |
| Sets the window's position. More... | |
| void | position (int &x, int &y) const |
| Returns the window's position. More... | |
| void | setSize (int width, int height) |
| Sets the size of the window. More... | |
| void | size (int &width, int &height) const |
| Returns the width and height of the window. More... | |
| void | contentScale (float &x, float &y) const |
| Returns the content scale. More... | |
| void | setSizeLimits (int minWidth=-1, int minHeight=-1, int maxWidth=-1, int maxHeight=-1) |
| Limits the size of the window. More... | |
| void | setAspectRatio (int n, int d) |
| Sets the window's aspect ratio. More... | |
| void | framebufferSize (int &width, int &height) const |
| Returns the width and height of the window's framebuffer. More... | |
| void | frame (int &left, int &top, int &right, int &bottom) const |
| Returns the locations of the edges of the window's frame. More... | |
| void | iconify () |
| Reduces the window to an icon. | |
| void | restore () |
| Displays the window normally. | |
| void | maximize () |
| Fits the window to the size of the screen. | |
| void | show (bool shown=true) |
| Shows or hides the window. More... | |
| void | focus () |
| Sets the focus to the window. | |
| Monitor | monitor () const |
| Returns the window's monitor. More... | |
| void | setMonitor (GLFWmonitor *monitor, int x, int y, int width, int height, int refreshRate) |
| Sets the window's monitor parameters. More... | |
| void | setAttribute (Attribute id, int value) |
| Sets the value of the specified attribute. More... | |
| int | attribute (Attribute id) const |
| Returns the value of the specified attribute. More... | |
| void | setContext (void *context) |
| Saves a context for the window. More... | |
| void * | context () const |
| Returns the previously set context, or nullptr. | |
| int | processEvents () |
| Processes any window activity. More... | |
| int | waitEvents () |
| Waits for any window activity and processes it. More... | |
Vulkan-specific | |
These methods are specific to Vulkan and defined only when GLFW_INCLUDE_VULKAN is defined | |
| VkSurfaceKHR | createSurface (VkInstance instance, VkAllocationCallbacks *allocator) const |
| Creates a device-specific Vulkan surface. More... | |
Static Public Member Functions | |
| static void | resetHints () |
| Resets all window hints back to default values. More... | |
| static void | hint (Hint id, int value) |
| Provides some window initialization context. More... | |
Private Member Functions | |
Overridable Notifications | |
These methods must be overridden in order to receive the appropriate notifications. | |
| virtual void | onPositionChanged (int x, int y) |
| Called when the window position is changed. More... | |
| virtual void | onSizeChanged (int width, int height) |
| Called when the size of the window is changed. More... | |
| virtual void | onClose () |
| Called before the window is closed. More... | |
| virtual void | onRefresh () |
| Called when the contents of the window need to be refreshed. More... | |
| virtual void | onFocusChanged (int gained) |
| Called when the window focused has changed to or from the window. More... | |
| virtual void | onIconifyChanged (int iconified) |
| Called when the window has changed to or from the icon state. More... | |
| virtual void | onMaximizeChanged (int maximized) |
| Called when the when changes to or from maximized state. More... | |
| virtual void | onFramebufferSizeChanged (int width, int height) |
| Called when the size of the window's framebuffer changes. More... | |
| virtual void | onContentScaleChanged (float x, float y) |
| Called when the window's content scale changes. More... | |
C++ wrapper for a GLFW window.
|
strong |
Window attributes.
|
strong |
Window hints.
| Glfwx::Window::Window | ( | int | width, |
| int | height, | ||
| char const * | title, | ||
| Monitor * | monitor = nullptr, |
||
| GLFWwindow * | share = nullptr |
||
| ) |
Constructor.
| width | The desired width of the window (must be > 0) |
| height | The desired height of the window (must be > 0) |
| title | The initial UTF-8 window title |
| monitor | The monitor to use for full screen mode, or nullptr for windowed mode (optional) |
| share | The window whose context to share resources with, or nullptr to not share resources (optional) |
|
virtual |
Destructor.
| int Glfwx::Window::attribute | ( | Attribute | id | ) | const |
Returns the value of the specified attribute.
| id | The attribute to query |
| void Glfwx::Window::contentScale | ( | float & | x, |
| float & | y | ||
| ) | const |
Returns the content scale.
| [out] | x | Scale |
| [out] | y | Scale |
| VkSurfaceKHR Glfwx::Window::createSurface | ( | VkInstance | instance, |
| VkAllocationCallbacks * | allocator | ||
| ) | const |
Creates a device-specific Vulkan surface.
| instance | Vulkan instance |
| allocator | Vulkan allocator |
| void Glfwx::Window::frame | ( | int & | left, |
| int & | top, | ||
| int & | right, | ||
| int & | bottom | ||
| ) | const |
Returns the locations of the edges of the window's frame.
| [out] | left | Location of the left edge |
| [out] | top | Location of the top edge |
| [out] | right | Location of the right edge |
| [out] | bottom | Location of the bottom edge |
| void Glfwx::Window::framebufferSize | ( | int & | width, |
| int & | height | ||
| ) | const |
Returns the width and height of the window's framebuffer.
| [out] | width | Width |
| [out] | height | Height |
|
static |
Provides some window initialization context.
| id | Hint ID |
| value | Value |
| Monitor Glfwx::Window::monitor | ( | ) | const |
Returns the window's monitor.
|
privatevirtual |
Called before the window is closed.
|
privatevirtual |
Called when the window's content scale changes.
| x | New scale |
| y | New scale |
|
privatevirtual |
Called when the window focused has changed to or from the window.
| gained | 1 if the window gains focus. 0 if the window loses focus. |
|
privatevirtual |
Called when the size of the window's framebuffer changes.
| width | New framebuffer size |
| height | New framebuffer size |
|
privatevirtual |
Called when the window has changed to or from the icon state.
| iconified | 1 if the window is iconified. 0 if the window is opened. |
|
privatevirtual |
Called when the when changes to or from maximized state.
| maximized | 1 if the window is maximized, 0 if the window returns to normal |
|
privatevirtual |
Called when the window position is changed.
| x | New location |
| y | New location |
|
privatevirtual |
Called when the contents of the window need to be refreshed.
|
privatevirtual |
Called when the size of the window is changed.
| width | New size |
| height | New size |
| void Glfwx::Window::position | ( | int & | x, |
| int & | y | ||
| ) | const |
Returns the window's position.
| [out] | x | Horizontal position |
| [out] | y | Vertical position |
| int Glfwx::Window::processEvents | ( | ) |
Processes any window activity.
|
static |
Resets all window hints back to default values.
| void Glfwx::Window::setAspectRatio | ( | int | n, |
| int | d | ||
| ) |
Sets the window's aspect ratio.
The aspect ratio is set the value of the fraction n/d.
| n | numerator |
| d | denominator |
| void Glfwx::Window::setAttribute | ( | Attribute | id, |
| int | value | ||
| ) |
Sets the value of the specified attribute.
| id | The attribute to change |
| value | THe value to set |
| void Glfwx::Window::setContext | ( | void * | context | ) |
Saves a context for the window.
| context | Value to set |
| void Glfwx::Window::setIcon | ( | std::vector< GLFWimage > | images = std::vector<GLFWimage>() | ) |
Sets the window's icon.
| images | icon images (default: reset to default) |
| void Glfwx::Window::setMonitor | ( | GLFWmonitor * | monitor, |
| int | x, | ||
| int | y, | ||
| int | width, | ||
| int | height, | ||
| int | refreshRate | ||
| ) |
Sets the window's monitor parameters.
| monitor | Monitor to display window |
| x | Location |
| y | Location |
| width | Size |
| height | Size |
| refreshRate | Refresh rate |
| void Glfwx::Window::setPosition | ( | int | x, |
| int | y | ||
| ) |
Sets the window's position.
| x | Horizontal position |
| y | Vertical position |
| void Glfwx::Window::setSize | ( | int | width, |
| int | height | ||
| ) |
Sets the size of the window.
| width | Size |
| height | Size |
| void Glfwx::Window::setSizeLimits | ( | int | minWidth = -1, |
| int | minHeight = -1, |
||
| int | maxWidth = -1, |
||
| int | maxHeight = -1 |
||
| ) |
Limits the size of the window.
| minWidth | Minimum size (-1 = no limit, optional, default is -1) |
| minHeight | Minimum size (-1 = no limit, optional, default is -1) |
| maxWidth | Maximum size (-1 = no limit, optional, default is -1) |
| maxHeight | Maximum size (-1 = no limit, optional, default is -1) |
| void Glfwx::Window::setTitle | ( | char const * | title | ) |
Sets the title.
| title | New title |
| void Glfwx::Window::show | ( | bool | shown = true | ) |
Shows or hides the window.
| shown | Shows if true, hides if false (optional, default is true) |
| void Glfwx::Window::size | ( | int & | width, |
| int & | height | ||
| ) | const |
Returns the width and height of the window.
| [out] | width | Size |
| [out] | height | Size |
| int Glfwx::Window::waitEvents | ( | ) |
Waits for any window activity and processes it.
1.8.14