Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Headless::OpenGLContext Class Referenceabstract

#include <Headless/OpenGLContext/OpenGLContext.hpp>

+ Collaboration diagram for Ra::Headless::OpenGLContext:

Public Member Functions

OpenGL context management

These methods allow to create and manipulate an openGLContext. Using this function, the openGL context created is an offscreen context with no exposed window.

 OpenGLContext (const glbinding::Version &glVersion={ 4, 1 }, const std::array< int, 2 > &size={ { 1, 1 } })
 
virtual ~OpenGLContext ()=default
 destructor
 
virtual void makeCurrent () const =0
 make the context active
 
virtual void doneCurrent () const =0
 make the context inactive
 
virtual bool isValid () const =0
 Check for validity of the context.
 
virtual bool isWindow () const
 Check if the context is associated to a window.
 
virtual std::string getInfo () const
 Return a string identifying the openGL Context and its supported versions.
 

Protected Member Functions

virtual bool processEvents ()
 Process the pending events according to the window show mode.
 
void resizeFrameBuffer (int width, int height)
 Resize callback.
 
void keyboardEventCallback (int key, int scancode, int action, int mods)
 Keyboard callback.
 
void mouseEventCallback (int button, int action, int mods, int x, int y)
 Mouse callback.
 
void mouseMoveEventCallback (int x, int y)
 Mouse move callback.
 
void scrollEventCallback (int xoffset, int yoffset)
 Scroll callback.
 

Protected Attributes

Ra::Core::Utils::Observable< int, int > m_resizers
 Resize event observable.
 
Ra::Core::Utils::Observable< int, int, int, int > m_keyboardObservers
 Keyboard event observable.
 
Ra::Core::Utils::Observable< int, int, int, int, int > m_mouseObservers
 Mouse event observable.
 
Ra::Core::Utils::Observable< int, int > m_mouseMoveObservers
 Mouse move event observable.
 
Ra::Core::Utils::Observable< int, int > m_scrollObservers
 Scroll event observable.
 
EventMode m_mode { EventMode::POLL }
 Event processing mode.
 
float m_delay { 1.f / 60.f }
 Timeout delay for event processing.
 

Window management from an openGL context

These methods allow to display and interact with a simple window associated with the created OpenGL Context, if any.

enum class  EventMode : int { POLL = 0 , WAIT , TIMEOUT , NUM_MODES }
 Identify the event processing method when the window is exposed. More...
 
virtual void show (EventMode, float)
 Show the window.
 
virtual void hide ()
 Hide the window.
 
virtual void resize (const std::array< int, 2 > &)
 Resize the window.
 
virtual void renderLoop (std::function< void(float)>)
 loop on events and execute the functor render after each event
 
Ra::Core::Utils::Observable< int, int > & resizeListener ()
 
Ra::Core::Utils::Observable< int, int, int, int > & keyboardListener ()
 
Ra::Core::Utils::Observable< int, int, int, int, int > & mouseListener ()
 
Ra::Core::Utils::Observable< int, int > & mouseMoveListener ()
 
Ra::Core::Utils::Observable< int, int > & scrollListener ()
 

Detailed Description

This class defines the interface for any off-screen OpenGL Context. There are two use cases of such a context :

  • headless rendering application.
  • simple window with limited interaction for context providers supporting windows

Definition at line 22 of file OpenGLContext.hpp.

Member Enumeration Documentation

◆ EventMode

enum class Ra::Headless::OpenGLContext::EventMode : int
strong

Identify the event processing method when the window is exposed.

Definition at line 68 of file OpenGLContext.hpp.

Constructor & Destructor Documentation

◆ OpenGLContext()

Ra::Headless::OpenGLContext::OpenGLContext ( const glbinding::Version & glVersion = { 4, 1 },
const std::array< int, 2 > & size = { { 1, 1 } } )
inlineexplicit

Create an offscreen openGl context. The created context has the following properties

  • OpenGL version requested : (default >= 4.1)
  • OpenGL context profile : Core Profile The created context is associated with a hidden window that can be shown later.
    Parameters
    glVersion(optional, default is 4.1) indicates the OpenGL version the context MUST be compatible with. If there is no compatible context, the application will stop
    size

Definition at line 41 of file OpenGLContext.hpp.

Member Function Documentation

◆ getInfo()

std::string Ra::Headless::OpenGLContext::getInfo ( ) const
inlinenodiscardvirtual

Return a string identifying the openGL Context and its supported versions.

Definition at line 164 of file OpenGLContext.hpp.

+ Here is the call graph for this function:

◆ hide()

virtual void Ra::Headless::OpenGLContext::hide ( )
inlinevirtual

Hide the window.

Definition at line 72 of file OpenGLContext.hpp.

◆ isWindow()

virtual bool Ra::Headless::OpenGLContext::isWindow ( ) const
inlinevirtual

Check if the context is associated to a window.

Definition at line 56 of file OpenGLContext.hpp.

◆ keyboardEventCallback()

void Ra::Headless::OpenGLContext::keyboardEventCallback ( int key,
int scancode,
int action,
int mods )
inlineprotected

Keyboard callback.

Definition at line 184 of file OpenGLContext.hpp.

+ Here is the call graph for this function:

◆ keyboardListener()

Ra::Core::Utils::Observable< int, int, int, int > & Ra::Headless::OpenGLContext::keyboardListener ( )
inline

Give access to the keyboard event observable so that client can add Observer to this event.

The parameters sent to the keyboard listeners are the keyboard key, platform-specific scancode, key action and modifier bits.

See also
https://www.glfw.org/docs/latest/input_guide.html#input_keyboard

Definition at line 95 of file OpenGLContext.hpp.

◆ mouseEventCallback()

void Ra::Headless::OpenGLContext::mouseEventCallback ( int button,
int action,
int mods,
int x,
int y )
inlineprotected

Mouse callback.

Definition at line 188 of file OpenGLContext.hpp.

+ Here is the call graph for this function:

◆ mouseListener()

Ra::Core::Utils::Observable< int, int, int, int, int > & Ra::Headless::OpenGLContext::mouseListener ( )
inline

Give access to the mouse event observable so that client can add Observer to this event.

The parameters sent to the mouse listeners are the mouse button, button action and modifier bits as well as the mouse position in pixel unit and in the FrameBuffer space. The origin is at the top left of the framebuffer.

See also
https://www.glfw.org/docs/latest/input_guide.html#input_mouse

Definition at line 107 of file OpenGLContext.hpp.

◆ mouseMoveEventCallback()

void Ra::Headless::OpenGLContext::mouseMoveEventCallback ( int x,
int y )
inlineprotected

Mouse move callback.

Definition at line 192 of file OpenGLContext.hpp.

+ Here is the call graph for this function:

◆ mouseMoveListener()

Ra::Core::Utils::Observable< int, int > & Ra::Headless::OpenGLContext::mouseMoveListener ( )
inline

Give access to the mouse move event observable so that client can add Observer to this event.

The parameters sent to the mouse move listeners are the mouse position in pixel unit and in the FrameBuffer space. The origin is at the top left of the framebuffer.

See also
https://www.glfw.org/docs/latest/input_guide.html#cursor_pos

Definition at line 118 of file OpenGLContext.hpp.

◆ processEvents()

virtual bool Ra::Headless::OpenGLContext::processEvents ( )
inlineprotectedvirtual

Process the pending events according to the window show mode.

Definition at line 131 of file OpenGLContext.hpp.

◆ renderLoop()

virtual void Ra::Headless::OpenGLContext::renderLoop ( std::function< void(float)> )
inlinevirtual

loop on events and execute the functor render after each event

Definition at line 76 of file OpenGLContext.hpp.

◆ resize()

virtual void Ra::Headless::OpenGLContext::resize ( const std::array< int, 2 > & )
inlinevirtual

Resize the window.

Definition at line 74 of file OpenGLContext.hpp.

◆ resizeFrameBuffer()

void Ra::Headless::OpenGLContext::resizeFrameBuffer ( int width,
int height )
inlineprotected

Resize callback.

Definition at line 179 of file OpenGLContext.hpp.

+ Here is the call graph for this function:

◆ resizeListener()

Ra::Core::Utils::Observable< int, int > & Ra::Headless::OpenGLContext::resizeListener ( )
inline

Give access to the resize event observable so that client can add Observer to this event.

The parameters sent to the resize listeners are in pixels and correspond to the OpenGL Framebuffer size (i.e. the size given to glViewport function)

See also
https://www.glfw.org/docs/latest/window_guide.html#window_fbsize

Definition at line 84 of file OpenGLContext.hpp.

◆ scrollEventCallback()

void Ra::Headless::OpenGLContext::scrollEventCallback ( int xoffset,
int yoffset )
inlineprotected

Scroll callback.

Definition at line 196 of file OpenGLContext.hpp.

+ Here is the call graph for this function:

◆ scrollListener()

Ra::Core::Utils::Observable< int, int > & Ra::Headless::OpenGLContext::scrollListener ( )
inline

Give access to the scroll event observable so that client can add Observer to this event.

The parameters sent to the scroll listeners are two-dimensional scroll offsets in pixel unit and in the FrameBuffer space.

See also
https://www.glfw.org/docs/latest/input_guide.html#scrolling

Definition at line 126 of file OpenGLContext.hpp.

◆ show()

virtual void Ra::Headless::OpenGLContext::show ( EventMode ,
float  )
inlinevirtual

Show the window.

Definition at line 70 of file OpenGLContext.hpp.

Member Data Documentation

◆ m_delay

float Ra::Headless::OpenGLContext::m_delay { 1.f / 60.f }
protected

Timeout delay for event processing.

Definition at line 161 of file OpenGLContext.hpp.

◆ m_keyboardObservers

Ra::Core::Utils::Observable<int, int, int, int> Ra::Headless::OpenGLContext::m_keyboardObservers
protected

Keyboard event observable.

Definition at line 141 of file OpenGLContext.hpp.

◆ m_mode

EventMode Ra::Headless::OpenGLContext::m_mode { EventMode::POLL }
protected

Event processing mode.

Definition at line 159 of file OpenGLContext.hpp.

◆ m_mouseMoveObservers

Ra::Core::Utils::Observable<int, int> Ra::Headless::OpenGLContext::m_mouseMoveObservers
protected

Mouse move event observable.

Definition at line 151 of file OpenGLContext.hpp.

◆ m_mouseObservers

Ra::Core::Utils::Observable<int, int, int, int, int> Ra::Headless::OpenGLContext::m_mouseObservers
protected

Mouse event observable.

Definition at line 146 of file OpenGLContext.hpp.

◆ m_resizers

Ra::Core::Utils::Observable<int, int> Ra::Headless::OpenGLContext::m_resizers
protected

Resize event observable.

Definition at line 136 of file OpenGLContext.hpp.

◆ m_scrollObservers

Ra::Core::Utils::Observable<int, int> Ra::Headless::OpenGLContext::m_scrollObservers
protected

Scroll event observable.

Definition at line 156 of file OpenGLContext.hpp.


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