class ffw::GLRenderWindow
Class List > ffw :: GLRenderWindow
An OpenGL render window using GLFW library.
Inherits the following classes: ffw::RenderWindow
Friends
Type | Name |
---|---|
friend struct | WindowCallback |
Public Static Functions
Type | Name |
---|---|
static std::vector< Monitor > | getMonitors () Returns a vector of all physical monitors available. |
static Monitor | getPrimaryMonitor () Returns the primary monitor defined by the OS. |
static std::vector< Monitor::Mode > | getMonitorModes (const Monitor & monitor) Returns all possible modes for the given monitor. |
Public Functions
Type | Name |
---|---|
GLRenderWindow (const RenderWindowArgs & args, GLRenderWindow * other, Monitor * monitor = nullptr) Creates the window. | |
virtual | ~GLRenderWindow () |
virtual void | setPos (int posx, int posy) override Sets the position of the window relative to the framebuffer. |
virtual void | setSize (int width, int height) override Sets the size of the window's framebuffer. |
virtual Vec2< int > | getPos () override const Returns the position of the window relative to the framebuffer (not relative to the OS specific border around the window) |
virtual Vec2< int > | getSize () override const Returns the size of the window's framebuffer (does not include the OS specific border) |
void | setWindowedMode () const Sets the window into windowed mode, if the window was in maximized mode. |
void | setWindowedMode (int posx, int posy, int width, int height) const Sets the window into windowed mode with specific size and position. |
void | setFullscreen (const Monitor * monitor) const Sets the window into fullscreen mode. |
virtual bool | shouldRender () override const Returns true if shouldClose() has been set to true. |
virtual void | renderFrame () override Renders the frame by setting up the context and calling protected method render() |
virtual void | poolEvents () override Processes all user events. |
virtual void | waitForEvents () override Waits for user events and processes them all. |
virtual bool | isInitialized () override const Returns true if the window has been initialized. |
virtual void * | getGlextFunc (const std::string & name) override const Returns the address of the specified function for the current context. |
virtual bool | isGlextExtSupported (const std::string & name) override const Returns wheter given GL extension is supported. |
void | setSwapInterval (int interval) const Sets swap interval (enables or disables V-sync) |
virtual void | shouldClose (bool close) override Sets the internal should close flag. |
virtual void | show () override Makes the window visible. |
virtual void | hide () override Makes the window hidden. |
virtual void | iconify () override Iconifies the specified window. |
virtual void | restore () override Restores the specified window. |
virtual void | maximize () override Maximizes the specified window. |
virtual void | setSingleBufferMode (bool enabled) override Sets single buffer mode. |
Protected Functions
Type | Name |
---|---|
virtual void | render () = 0 Called every time the frame is being rendered. |
virtual void | textInputEvent (unsigned int c) Called when the user presses a key to type text (unicode only) |
virtual void | keyPressedEvent (ffw::Key key, ffw::KeyMode mode) Called when the user presses a physical key. |
virtual void | mouseMovedEvent (int mousex, int mousey) Called when the user moves a mouse. |
virtual void | mouseScrollEvent (int scroll) Called when the user scrolls down or up. |
virtual void | mouseButtonEvent (ffw::MouseButton button, ffw::MouseMode mode) Called when the user presses a mouse button. |
virtual void | windowResizedEvent (int width, int height) Called when the window is resized to a new size. |
virtual void | windowMovedEvent (int posx, int posy) Called when the window is moved to a new position. |
virtual void | windowCloseEvent () Called when the user presses the [X] button on the window. |
virtual void | windowFocusEvent (bool focus) Called when the window will gain or looses focus. |
virtual void | filesDroppedEvent (std::vector< std::string > filelist) Called when the user drags and drops one or multiple files. |
Friends Documentation
friend WindowCallback
friend struct WindowCallback;
Public Static Functions Documentation
function getMonitors
static std::vector< Monitor > ffw::GLRenderWindow::getMonitors ()
Returns a vector of all physical monitors available.
function getPrimaryMonitor
static Monitor ffw::GLRenderWindow::getPrimaryMonitor ()
Returns the primary monitor defined by the OS.
function getMonitorModes
static std::vector< Monitor::Mode > ffw::GLRenderWindow::getMonitorModes (
const Monitor & monitor
)
Returns all possible modes for the given monitor.
Public Functions Documentation
function GLRenderWindow
ffw::GLRenderWindow::GLRenderWindow (
const RenderWindowArgs & args,
GLRenderWindow * other,
Monitor * monitor = nullptr
)
Creates the window.
Parameters:
- args Arguments and hints for the window
- other If another window is provided, their OpenGL context will be shared, otherwise NULL
- monitor If a monitor is provided, the window will be fullscreen
function ~GLRenderWindow
virtual ffw::GLRenderWindow::~GLRenderWindow ()
function setPos
virtual void ffw::GLRenderWindow::setPos (
int posx,
int posy
)
Sets the position of the window relative to the framebuffer.
Note:
This function must only be called from the main thread.
Implements RenderWindow::setPos
function setSize
virtual void ffw::GLRenderWindow::setSize (
int width,
int height
)
Sets the size of the window's framebuffer.
Note:
This function must only be called from the main thread.
Implements RenderWindow::setSize
function getPos
virtual Vec2< int > ffw::GLRenderWindow::getPos () const
Returns the position of the window relative to the framebuffer (not relative to the OS specific border around the window)
Implements RenderWindow::getPos
function getSize
virtual Vec2< int > ffw::GLRenderWindow::getSize () const
Returns the size of the window's framebuffer (does not include the OS specific border)
Implements RenderWindow::getSize
function setWindowedMode (1/2)
void ffw::GLRenderWindow::setWindowedMode () const
Sets the window into windowed mode, if the window was in maximized mode.
Note:
This function must only be called from the main thread.
This function sets the window in windowed mode. This function does not update the height, width, or position. Instead, it uses the last size and position before entering fullscreen mode.
function setWindowedMode (2/2)
void ffw::GLRenderWindow::setWindowedMode (
int posx,
int posy,
int width,
int height
) const
Sets the window into windowed mode with specific size and position.
Note:
This function must only be called from the main thread.
This function sets the window in windowed mode. This function also updates the widh, height, and position.
function setFullscreen
void ffw::GLRenderWindow::setFullscreen (
const Monitor * monitor
) const
Sets the window into fullscreen mode.
Note:
This function must only be called from the main thread.
This function sets the monitor that the window uses for full screen mode. When setting a monitor, this function updates the width, height and refresh rate of the desired video mode and switches to the video mode closest to it. The window position is ignored when setting a monitor.
function shouldRender
virtual bool ffw::GLRenderWindow::shouldRender () const
Returns true if shouldClose() has been set to true.
Implements RenderWindow::shouldRender
function renderFrame
virtual void ffw::GLRenderWindow::renderFrame ()
Renders the frame by setting up the context and calling protected method render()
This function makes the OpenGL or OpenGL ES context of the specified window current on the calling thread. A context can only be made current on a single thread at a time and each thread can have only a single current context at a time. This function also calls glViewport with the current window's framebuffer size.
Implements RenderWindow::renderFrame
function poolEvents
virtual void ffw::GLRenderWindow::poolEvents ()
Processes all user events.
This function processes only those events that are already in the event queue and then returns immediately. Processing events will cause the window and input callbacks associated with those events to be called. On some platforms, a window move, resize will cause event processing to block. This is due to how event processing is designed on those platforms. You can use the window refresh callback to redraw the contents of your window when necessary during such operations.
Implements RenderWindow::poolEvents
function waitForEvents
virtual void ffw::GLRenderWindow::waitForEvents ()
Waits for user events and processes them all.
Note:
This function must only be called from the main thread.
This function puts the calling thread to sleep until at least one event is available in the event queue. Once one or more events are available, it behaves exactly like poolEvents, i.e. the events in the queue are processed and the function then returns immediately. Processing events will cause the window and input callbacks associated with those events to be called. Since not all events are associated with callbacks, this function may return without a callback having been called even if you are monitoring all callbacks. On some platforms, a window move, resize or menu operation will cause event processing to block. This is due to how event processing is designed on those platforms. You can use the window refresh callback to redraw the contents of your window when necessary during such operations.
Implements RenderWindow::waitForEvents
function isInitialized
virtual bool ffw::GLRenderWindow::isInitialized () const
Returns true if the window has been initialized.
Note:
This function must only be called from the main thread.
Implements RenderWindow::isInitialized
function getGlextFunc
virtual void * ffw::GLRenderWindow::getGlextFunc (
const std::string & name
) const
Returns the address of the specified function for the current context.
This function returns the address of the specified OpenGL or OpenGL ES core or extension function, if it is supported by the current context. A context must be current on the calling thread. Calling this function without a current context will cause a GLFW_NO_CURRENT_CONTEXT error.
PFNGLACTIVETEXTUREPROC myGlActiveTexture = getGlextFunc("glActiveTexture");
if (myGlActiveTexture != nullptr) {
std::cout << "myGlActiveTexture is loaded" << std::endl;
}
Implements RenderWindow::getGlextFunc
function isGlextExtSupported
virtual bool ffw::GLRenderWindow::isGlextExtSupported (
const std::string & name
) const
Returns wheter given GL extension is supported.
Implements RenderWindow::isGlextExtSupported
function setSwapInterval
void ffw::GLRenderWindow::setSwapInterval (
int interval
) const
Sets swap interval (enables or disables V-sync)
Note:
This function must only be called from the main thread.
function shouldClose
virtual void ffw::GLRenderWindow::shouldClose (
bool close
)
Sets the internal should close flag.
This function sets the swap interval for the current OpenGL or OpenGL ES context, i.e. the number of screen updates to wait from the time glfwSwapBuffers was called before swapping the buffers and returning. This is sometimes called vertical synchronization, vertical retrace synchronization or just vsync.
Implements RenderWindow::shouldClose
function show
virtual void ffw::GLRenderWindow::show ()
Makes the window visible.
This function makes the specified window visible if it was previously hidden. If the window is already visible or is in full screen mode, this function does nothing.
Note:
This function must only be called from the main thread.
Implements RenderWindow::show
function hide
virtual void ffw::GLRenderWindow::hide ()
Makes the window hidden.
This function hides the specified window if it was previously visible. If the window is already hidden or is in full screen mode, this function does nothing.
Note:
This function must only be called from the main thread.
Implements RenderWindow::hide
function iconify
virtual void ffw::GLRenderWindow::iconify ()
Iconifies the specified window.
This function iconifies (minimizes) the specified window if it was previously restored. If the window is already iconified, this function does nothing.If the specified window is a full screen window, the original monitor resolution is restored until the window is restored.
Note:
This function must only be called from the main thread.
Implements RenderWindow::iconify
function restore
virtual void ffw::GLRenderWindow::restore ()
Restores the specified window.
This function restores the specified window if it was previously iconified (minimized) or maximized. If the window is already restored, this function does nothing. If the specified window is a full screen window, the resolution chosen for the window is restored on the selected monitor.
Note:
This function must only be called from the main thread.
Implements RenderWindow::restore
function maximize
virtual void ffw::GLRenderWindow::maximize ()
Maximizes the specified window.
This function maximizes the specified window if it was previously not maximized. If the window is already maximized, this function does nothing. If the specified window is a full screen window, this function does nothing.
Note:
This function must only be called from the main thread.
Implements RenderWindow::maximize
function setSingleBufferMode
virtual void ffw::GLRenderWindow::setSingleBufferMode (
bool enabled
)
Sets single buffer mode.
In single buffer mode, no back and front buffer swapping is done. Instead, glFlush and glFinish is used.
Note:
This function must only be called from the main thread.
Implements RenderWindow::setSingleBufferMode
Protected Functions Documentation
function render
virtual void ffw::GLRenderWindow::render () = 0
Called every time the frame is being rendered.
function textInputEvent
virtual void ffw::GLRenderWindow::textInputEvent (
unsigned int c
)
Called when the user presses a key to type text (unicode only)
function keyPressedEvent
virtual void ffw::GLRenderWindow::keyPressedEvent (
ffw::Key key,
ffw::KeyMode mode
)
Called when the user presses a physical key.
function mouseMovedEvent
virtual void ffw::GLRenderWindow::mouseMovedEvent (
int mousex,
int mousey
)
Called when the user moves a mouse.
function mouseScrollEvent
virtual void ffw::GLRenderWindow::mouseScrollEvent (
int scroll
)
Called when the user scrolls down or up.
function mouseButtonEvent
virtual void ffw::GLRenderWindow::mouseButtonEvent (
ffw::MouseButton button,
ffw::MouseMode mode
)
Called when the user presses a mouse button.
function windowResizedEvent
virtual void ffw::GLRenderWindow::windowResizedEvent (
int width,
int height
)
Called when the window is resized to a new size.
function windowMovedEvent
virtual void ffw::GLRenderWindow::windowMovedEvent (
int posx,
int posy
)
Called when the window is moved to a new position.
function windowCloseEvent
virtual void ffw::GLRenderWindow::windowCloseEvent ()
Called when the user presses the [X] button on the window.
function windowFocusEvent
virtual void ffw::GLRenderWindow::windowFocusEvent (
bool focus
)
Called when the window will gain or looses focus.
function filesDroppedEvent
virtual void ffw::GLRenderWindow::filesDroppedEvent (
std::vector< std::string > filelist
)
Called when the user drags and drops one or multiple files.
Note:
UTF-8 enabled
The documentation for this class was generated from the following file: include/ffw/graphics/glrenderwindow.h