Window/context manager for OpenGL (GLFW+GLEW) or WebGL (Emscripten).
More...
#include <GLEnv.h>
|
| | GLEnv (uint32_t w, uint32_t h, uint32_t s, const std::string &title, bool fpsCounter=false, bool sync=true, int major=2, int minor=1, bool core=false) |
| | Construct a GL environment and create a window/canvas + context.
|
| | ~GLEnv () |
| | Destroy window/context (desktop) or release resources (web).
|
| void | setKeyCallback (GLFWkeyfun f) |
| | Set key callback for GLFW builds.
|
| void | setKeyCallbacks (GLFWkeyfun f, GLFWcharfun c) |
| | Set key + char callbacks for GLFW builds.
|
| void | setMouseCallbacks (GLFWcursorposfun p, GLFWmousebuttonfun b, GLFWscrollfun s) |
| | Set mouse position/button/scroll callbacks for GLFW builds.
|
| void | setResizeCallback (GLFWframebuffersizefun f) |
| | Set framebuffer resize callback for GLFW builds.
|
| Dimensions | getFramebufferSize () const |
| | Get framebuffer size in texels/pixels.
|
| Dimensions | getWindowSize () const |
| | Get logical window size.
|
| bool | shouldClose () const |
| | Query whether the window should close (desktop always; web always false).
|
| void | setClose () |
| | Request closing the window (desktop only; no‑op on web).
|
| void | endOfFrame () |
| | End‑of‑frame housekeeping: swap/poll + optional FPS title update.
|
| void | setCursorMode (CursorMode mode) |
| | Set mouse cursor behavior.
|
| void | setFPSCounter (bool fpsCounter) |
| | Enable/disable FPS title updates.
|
| void | setSync (bool sync) |
| | Enable/disable vsync.
|
| bool | getSync () const |
| | Current vsync state.
|
| void | setTitle (const std::string &title) |
| | Set the window/page title (stored; displayed on next FPS refresh).
|
|
| static void | checkGLError (const std::string &id) |
| | Convenience GL error check, logs to stderr with an identifier.
|
Window/context manager for OpenGL (GLFW+GLEW) or WebGL (Emscripten).
Creates a context and provides utilities around frame management, input, vsync, and dimension queries. On errors, the desktop path throws GLException using GLFW's error callback; Web builds avoid tear‑down exceptions for shouldClose().
◆ GLEnv()
| GLEnv::GLEnv |
( |
uint32_t | w, |
|
|
uint32_t | h, |
|
|
uint32_t | s, |
|
|
const std::string & | title, |
|
|
bool | fpsCounter = false, |
|
|
bool | sync = true, |
|
|
int | major = 2, |
|
|
int | minor = 1, |
|
|
bool | core = false ) |
Construct a GL environment and create a window/canvas + context.
- Parameters
-
| w | Initial width in pixels. |
| h | Initial height in pixels. |
| s | Multisample count (GLFW window hint). |
| title | Window title (desktop) or page title (web via FPS counter). |
| fpsCounter | If true, compute FPS and append to the title each second. |
| sync | If true, enable vsync (glfwSwapInterval(1) / RAF timing). |
| major | Requested GL major version (desktop) / WebGL major. |
| minor | Requested GL minor version (desktop) / WebGL minor. |
| core | If true (desktop), request a core profile context. |
- Exceptions
-
| GLException | On GLFW/GLEW initialization or window creation failures. |
◆ ~GLEnv()
Destroy window/context (desktop) or release resources (web).
◆ checkGLError()
| void GLEnv::checkGLError |
( |
const std::string & | id | ) |
|
|
static |
Convenience GL error check, logs to stderr with an identifier.
- Parameters
-
| id | Human‑readable label for the check site. |
◆ endOfFrame()
| void GLEnv::endOfFrame |
( |
| ) |
|
End‑of‑frame housekeeping: swap/poll + optional FPS title update.
◆ getFramebufferSize()
Get framebuffer size in texels/pixels.
- Returns
- Dimensions with width/height (framebuffer).
◆ getSync()
| bool GLEnv::getSync |
( |
| ) |
const |
|
inline |
◆ getWindowSize()
Get logical window size.
- Returns
- Dimensions with width/height (window/canvas).
◆ setClose()
Request closing the window (desktop only; no‑op on web).
◆ setCursorMode()
Set mouse cursor behavior.
- Parameters
-
| mode | NORMAL (visible), HIDDEN, or FIXED (pointer‑lock/web or disabled cursor/desktop). |
◆ setFPSCounter()
| void GLEnv::setFPSCounter |
( |
bool | fpsCounter | ) |
|
Enable/disable FPS title updates.
◆ setKeyCallback()
| void GLEnv::setKeyCallback |
( |
GLFWkeyfun | f | ) |
|
Set key callback for GLFW builds.
◆ setKeyCallbacks()
| void GLEnv::setKeyCallbacks |
( |
GLFWkeyfun | f, |
|
|
GLFWcharfun | c ) |
Set key + char callbacks for GLFW builds.
◆ setMouseCallbacks()
| void GLEnv::setMouseCallbacks |
( |
GLFWcursorposfun | p, |
|
|
GLFWmousebuttonfun | b, |
|
|
GLFWscrollfun | s ) |
Set mouse position/button/scroll callbacks for GLFW builds.
◆ setResizeCallback()
| void GLEnv::setResizeCallback |
( |
GLFWframebuffersizefun | f | ) |
|
Set framebuffer resize callback for GLFW builds.
◆ setSync()
| void GLEnv::setSync |
( |
bool | sync | ) |
|
◆ setTitle()
| void GLEnv::setTitle |
( |
const std::string & | title | ) |
|
Set the window/page title (stored; displayed on next FPS refresh).
◆ shouldClose()
| bool GLEnv::shouldClose |
( |
| ) |
const |
Query whether the window should close (desktop always; web always false).
The documentation for this class was generated from the following files: