2#include <Core/Utils/Observable.hpp>
3#include <Headless/RaHeadless.hpp>
9#include <glbinding-aux/ContextInfo.h>
10#include <glbinding/Version.h>
11#include <glbinding/gl/gl.h>
43 CORE_UNUSED( glVersion );
56 virtual bool isWindow()
const {
return false; }
68 enum class EventMode :
int { POLL = 0, WAIT, TIMEOUT, NUM_MODES };
96 return m_keyboardObservers;
108 return m_mouseObservers;
134 void resizeFrameBuffer(
int width,
int height );
139 void keyboardEventCallback(
int key,
int scancode,
int action,
int mods );
144 void mouseEventCallback(
int button,
int action,
int mods,
int x,
int y );
149 void mouseMoveEventCallback(
int x,
int y );
154 void scrollEventCallback(
int xoffset,
int yoffset );
161 float m_delay { 1.f / 60.f };
166 using ContextInfo = glbinding::aux::ContextInfo;
168 infoText <<
"*** OffScreen OpenGL context ***" <<
std::endl;
169 infoText <<
"Renderer (glbinding) : " << ContextInfo::renderer() <<
"\n";
170 infoText <<
"Vendor (glbinding) : " << ContextInfo::vendor() <<
"\n";
171 infoText <<
"OpenGL (glbinding) : " << ContextInfo::version().toString() <<
"\n";
172 infoText <<
"GLSL : " << gl::glGetString( gl::GL_SHADING_LANGUAGE_VERSION )
176 return infoText.
str();
180 gl::glViewport( 0, 0, width, height );
void notify(Args... p) const
Notify (i.e. call) each attached observer with argument p.
Ra::Core::Utils::Observable< int, int > m_scrollObservers
Scroll event observable.
void scrollEventCallback(int xoffset, int yoffset)
Scroll callback.
void mouseEventCallback(int button, int action, int mods, int x, int y)
Mouse callback.
virtual void resize(const std::array< int, 2 > &)
Resize the window.
virtual ~OpenGLContext()=default
destructor
virtual void doneCurrent() const =0
make the context inactive
Ra::Core::Utils::Observable< int, int > m_resizers
Resize event observable.
Ra::Core::Utils::Observable< int, int > & mouseMoveListener()
virtual void hide()
Hide the window.
Ra::Core::Utils::Observable< int, int > & scrollListener()
Ra::Core::Utils::Observable< int, int > m_mouseMoveObservers
Mouse move event observable.
virtual void renderLoop(std::function< void(float)>)
loop on events and execute the functor render after each event
void mouseMoveEventCallback(int x, int y)
Mouse move callback.
virtual void makeCurrent() const =0
make the context active
EventMode
Identify the event processing method when the window is exposed.
Ra::Core::Utils::Observable< int, int, int, int, int > & mouseListener()
Ra::Core::Utils::Observable< int, int, int, int > & keyboardListener()
OpenGLContext(const glbinding::Version &glVersion={ 4, 1 }, const std::array< int, 2 > &size={ { 1, 1 } })
void resizeFrameBuffer(int width, int height)
Resize callback.
virtual std::string getInfo() const
Return a string identifying the openGL Context and its supported versions.
void keyboardEventCallback(int key, int scancode, int action, int mods)
Keyboard callback.
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.
virtual bool processEvents()
Process the pending events according to the window show mode.
virtual void show(EventMode, float)
Show the window.
virtual bool isValid() const =0
Check for validity of the context.
Ra::Core::Utils::Observable< int, int > & resizeListener()
virtual bool isWindow() const
Check if the context is associated to a window.
hepler function to manage enum as underlying types in VariableSet