32 #ifndef OpenGLContext_INCLUDE_ONCE 33 #define OpenGLContext_INCLUDE_ONCE 49 class IVertexAttribSet;
160 virtual
void swapBuffers() = 0;
163 virtual
void makeCurrent() = 0;
166 bool initGLContext(
bool log=true);
169 void logOpenGLInfo();
172 const
std::
string& extensions()
const {
return mExtensions; }
176 bool isExtensionSupported(
const char* ext_name);
179 void* getProcAddress(
const char* function_name);
222 void destroyAllFramebufferObjects();
225 void destroyAllOpenGLResources();
231 virtual void update() = 0;
258 int width()
const {
return framebuffer()->width(); }
261 int height()
const {
return framebuffer()->height(); }
276 void setVSyncEnabled(
bool enable);
279 bool vsyncEnabled()
const;
296 void eraseAllEventListeners();
299 const std::vector< ref<UIEventListener> >&
eventListeners()
const {
return mEventListeners; }
324 leftFramebuffer()->setWidth(w);
325 leftFramebuffer()->setHeight(h);
326 rightFramebuffer()->setWidth(w);
327 rightFramebuffer()->setHeight(h);
329 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
330 for(
unsigned i=0; i<temp_clients.size(); ++i )
331 if ( temp_clients[i]->isEnabled() )
332 temp_clients[i]->resizeEvent( w, h );
339 if (mIgnoreNextMouseMoveEvent)
340 mIgnoreNextMouseMoveEvent =
false;
343 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
344 for(
unsigned i=0; i<temp_clients.size(); ++i )
345 if ( temp_clients[i]->isEnabled() )
346 temp_clients[i]->mouseMoveEvent(x, y);
354 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
355 for(
unsigned i=0; i<temp_clients.size(); ++i )
356 if ( temp_clients[i]->isEnabled() )
357 temp_clients[i]->mouseUpEvent(button, x, y);
364 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
365 for(
unsigned i=0; i<temp_clients.size(); ++i )
366 if ( temp_clients[i]->isEnabled() )
367 temp_clients[i]->mouseDownEvent(button, x, y);
374 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
375 for(
unsigned i=0; i<temp_clients.size(); ++i )
376 if ( temp_clients[i]->isEnabled() )
377 temp_clients[i]->mouseWheelEvent(n);
385 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
386 for(
unsigned i=0; i<temp_clients.size(); ++i )
387 if ( temp_clients[i]->isEnabled() )
388 temp_clients[i]->keyPressEvent(unicode_ch, key);
396 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
397 for(
unsigned i=0; i<temp_clients.size(); ++i )
398 if ( temp_clients[i]->isEnabled() )
399 temp_clients[i]->keyReleaseEvent(unicode_ch, key);
408 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
409 for(
unsigned i=0; i<temp_clients.size(); ++i )
410 if ( temp_clients[i]->isEnabled() )
411 temp_clients[i]->destroyEvent();
412 destroyAllOpenGLResources();
413 eraseAllEventListeners();
420 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
421 for(
unsigned i=0; i<temp_clients.size(); ++i )
422 if ( temp_clients[i]->isEnabled() )
423 temp_clients[i]->updateEvent();
430 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
431 for(
unsigned i=0; i<temp_clients.size(); ++i )
432 if ( temp_clients[i]->isEnabled() )
433 temp_clients[i]->visibilityEvent(visible);
444 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
445 for(
unsigned i=0; i<temp_clients.size(); ++i )
446 if ( temp_clients[i]->isEnabled() )
447 temp_clients[i]->initEvent();
454 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
455 for(
unsigned i=0; i<temp_clients.size(); ++i )
456 if ( temp_clients[i]->isEnabled() )
457 temp_clients[i]->fileDroppedEvent(files);
461 const std::set<EKey>&
keyboard()
const {
return mKeyboard; }
501 void bindVAS_Reset();
504 void applyEnables(
const EnableSet* cur );
513 void resetRenderStates();
518 mDefaultRenderStates[rs_slot.
type()] = rs_slot;
520 if (!mCurrentRenderStateSet->hasKey(rs_slot.
type()))
535 VL_CHECK(unit_i <= VL_MAX_TEXTURE_IMAGE_UNITS);
536 mTexUnitBinding[unit_i] = target;
542 VL_CHECK(unit_i <= VL_MAX_TEXTURE_IMAGE_UNITS);
543 return mTexUnitBinding[unit_i];
571 bool isCleanState(
bool verbose);
619 struct VertexArrayInfo
621 VertexArrayInfo(): mBufferObject(0), mPtr(0), mEnabled(
false) {}
623 const unsigned char* mPtr;
646 void setupDefaultRenderStates();
virtual void setWindowTitle(const String &)
If the OpenGL context is a top window this function sets its title.
const fvec4 & color() const
const IVertexAttribSet * mCurVAS
ref< Framebuffer > mLeftFramebuffer
int vertexAttribCount() const
The number (clamped to VA_MaxAttribCount) of generic vertex attributes as returned by glGet(GL_MAX_VE...
void dispatchKeyReleaseEvent(unsigned short unicode_ch, EKey key)
Dispatches the UIEventListener::keyReleaseEvent() notification to the subscribed UIEventListener obje...
const fvec3 & secondaryColor() const
Vector2< int > ivec2
A 2 components vector with int precision.
void dispatchInitEvent()
Dispatches the UIEventListener::initEvent() notification to the subscribed UIEventListener objects...
Abstract interface to manipulate OpenGL's vertex attribute arrays.
void keyRelease(EKey key)
Removes the specified key from the set of currently active keys - For internal use only...
void setAccumRGBABits(int r, int g, int b, int a)
bool isInitialized() const
Returns true if the OpenGLContext is in an initialized state.
VertexArrayInfo mSecondaryColorArray
int stencilBufferBits() const
void setDoubleBuffer(bool double_buffer_on)
void dispatchMouseDownEvent(EMouseButton button, int x, int y)
Dispatches the UIEventListener::mouseDownEvent() notification to the subscribed UIEventListener objec...
The UIEventListener class listens to the events emitted by an OpenGLContext.
std::vector< ref< UIEventListener > > mEventListeners
Framebuffer * framebuffer()
The default render target (always returns leftFramebuffer()).
void ignoreNextMouseMoveEvent()
Requests not to dispatch the next mouse move event.
RenderState wrapping the OpenGL function glNormal(), see also http://www.opengl.org/sdk/docs/man/xhtm...
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
VertexArrayInfo mFogArray
int multisampleSamples() const
const T_Scalar & r() const
ETextureDimension texUnitBinding(int unit_i) const
Returnes the texture target currently active for the specified texture unit. - For internal use only...
void setDepthBufferBits(int bits)
int bitsPerPixel() const
Returns rgbaBits().r() + rgbaBits().g() + rgbaBits().b() + rgbaBits().a()
virtual void hide()
If the OpenGL context is a widget this function makes it invisible to the user.
int textureImageUnitCount() const
The number (clamped to VL_MAX_TEXTURE_IMAGE_UNITS) of texture image units supported by the current ha...
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
UIEventListener * eventListener(int i)
Returns the i-th UIEventListener registered to an OpenGLContext.
const std::set< EKey > & keyboard() const
Returns the std::set containing the currently pressed keys.
ref< NaryQuickMap< ERenderState, RenderStateSlot, RS_RenderStateCount > > mCurrentRenderStateSet
virtual void setPosition(int, int)
If the OpenGL context is a widget this function sets its position.
virtual bool fullscreen() const
If the OpenGL context is a widget this function returns whether it has been maximized to fullscreen...
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. ...
void dispatchVisibilityEvent(bool visible)
Dispatches the UIEventListener::visibilityEvent() notification to the subscribed UIEventListener obje...
void setContextClientVersion(int version)
Used by EGLWindow to initialize either GLES 1.x or GLES 2.x contexts.
VertexArrayInfo mVertexArray
ref< NaryQuickMap< EEnable, EEnable, EN_EnableCount > > mNewEnableSet
void setDefaultRenderState(const RenderStateSlot &rs_slot)
Defines the default render state slot to be used by the opengl context.
void dispatchKeyPressEvent(unsigned short unicode_ch, EKey key)
Dispatches the UIEventListener::keyPressEvent() notification to the subscribed UIEventListener object...
void dispatchResizeEvent(int w, int h)
Dispatches the UIEventListener::resizeEvent() notification to the subscribed UIEventListener objects...
virtual void quitApplication()
Asks to the windowing system that is managing the OpenGLContext to quit the application.
void keyPress(EKey key)
Inserts the specified key in the set of currently active keys - For internal use only.
const Framebuffer * leftFramebuffer() const
The render target representing the default left framebuffer.
void setFullscreen(bool fullscreent)
RenderState wrapping the OpenGL function glColor(), see also http://www.opengl.org/sdk/docs/man/xhtml...
const std::vector< ref< UIEventListener > > & eventListeners() const
The currently UIEventListener registered to be notified of OpenGLContext related events.
const fvec3 & normal() const
Visualization Library main namespace.
int eventListenerCount() const
Returns the number of UIEventListener registered to an OpenGLContext.
virtual void show()
If the OpenGL context is a widget this function makes it visible to the user.
const OpenGLContextFormat & openglContextInfo() const
Returns an OpenGLContextFormat structure describing an OpenGLContext.
virtual void setSize(int, int)
If the OpenGL context is a widget this function sets its size.
const T_Scalar & g() const
bool continuousUpdate() const
If the OpenGL context is a widget this function returns whether its area is continuously updated at e...
void setRGBABits(int r, int g, int b, int a)
void dispatchUpdateEvent()
Dispatches the UIEventListener::updateEvent() notification to the subscribed UIEventListener objects...
The OpenGLContextFormat class encapsulates the settings of an OpenGL rendering context.
virtual void setContinuousUpdate(bool continuous)
If the OpenGL context is a widget this function sets whether its area is continuously updated at each...
const ivec4 & rgbaBits() const
int mContextClientVersion
void setOpenGLContextInfo(const OpenGLContextFormat &info)
Sets the OpenGLContextFormat associated to an OpenGLContext.
Vector4< int > ivec4
A 4 components vector with int precision.
RenderState wrapping the OpenGL function glVertexAttrib(), see also http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttrib.xml for more information.
int height() const
Returns the height in pixels of an OpenGLContext.
The base class for all the reference counted objects.
GLSLProgram * glslProgram()
std::set< EKey > mKeyboard
virtual ivec2 position() const
If the OpenGL context is a widget this function returns its position.
const GLSLProgram * glslProgram() const
const ivec4 & accumRGBABits() const
virtual void setMousePosition(int, int)
If the OpenGL context is a widget this function sets the mouse position.
bool mIgnoreNextMouseMoveEvent
int width() const
Returns the width in pixels of an OpenGLContext.
VertexArrayInfo mColorArray
int textureCoordCount() const
The number (clamped to VL_MAX_LEGACY_TEXTURE_UNITS) of fixed function pipeline texture units supporte...
virtual void apply(const Camera *camera, OpenGLContext *ctx) const
const fvec4 & vertexAttribValue(int i) const
ref< Framebuffer > mRightFramebuffer
VertexArrayInfo mNormalArray
const T_Scalar & b() const
void dispatchMouseWheelEvent(int n)
Dispatches the UIEventListener::mouseWheelEvent() notification to the subscribed UIEventListener obje...
int contextClientVersion() const
Used by EGLWindow to initialize either GLES 1.x or GLES 2.x contexts.
const UIEventListener * eventListener(int i) const
Returns the i-th UIEventListener registered to an OpenGLContext.
A set of RenderState objects managed by a Shader.
#define VLGRAPHICS_EXPORT
EOpenGLProfile openGLProfile() const
virtual bool mouseVisible() const
If the OpenGL context is a widget this function returns whether the mouse is visible over it or not...
bool isKeyPressed(EKey key) const
Returns true if the given key is pressed.
void setVersion(int majv, int minv)
Sets the OpenGL version you want to access when using vl::GLP_Compatibility or vl::GLP_Core profiles ...
void dispatchDestroyEvent()
Dispatches the UIEventListener::destroyEvent() notification to the subscribed UIEventListener(s), calls destroyAllOpenGLResources() and eraseAllEventListeners() This event must be issued just before the actual GL context is destroyed.
void setOpenGLProfile(EOpenGLProfile p)
The OpenGL profile you'd like to access.
void dispatchFileDroppedEvent(const std::vector< String > &files)
Dispatches the UIEventListener::fileDroppedEvent() notification to the subscribed UIEventListener obj...
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
Implements a framebuffer object to be used as a rendering target as specified by the ARB_framebuffer_...
Framebuffer * rightFramebuffer()
The render target representing the default right framebuffer (if a stereo OpenGL context is present)...
int depthBufferBits() const
ref< FramebufferObject > createFramebufferObject()
Equivalent to "createFramebufferObject(0,0);".
bool hasDoubleBuffer() const
Returns true if an OpenGLContext supports double buffering.
ref< GLSLProgram > mGLSLProgram
void dispatchMouseMoveEvent(int x, int y)
Dispatches the UIEventListener::mouseMoveEvent() notification to the subscribed UIEventListener objec...
Framebuffer * leftFramebuffer()
The render target representing the default left framebuffer.
void setVSync(bool vsync_on)
OpenGLContextFormat mGLContextInfo
ERenderState type() const
void setMultisampleSamples(int samples)
void setStereo(bool stereo_on)
void setTexUnitBinding(int unit_i, ETextureDimension target)
Declares that texture unit unit_i is currently bound to the specified texture target. - For internal use only.
The ref<> class is used to reference-count an Object.
void setMultisample(bool multisample_on)
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
virtual void setMouseVisible(bool)
If the OpenGL context is a widget this function sets whether the mouse is visible over it or not...
virtual void getFocus()
If the OpenGL context is a widget this function requests the mouse focus on it.
int mTextureImageUnitCount
const Framebuffer * rightFramebuffer() const
The render target representing the default right framebuffer (if a stereo OpenGL context is present)...
ref< NaryQuickMap< EEnable, EEnable, EN_EnableCount > > mCurrentEnableSet
std::vector< ref< FramebufferObject > > mFramebufferObject
The Framebuffer class defines an abstract 'surface' where OpenGL can render into. ...
bool doubleBuffer() const
ref< NaryQuickMap< ERenderState, RenderStateSlot, RS_RenderStateCount > > mNewRenderStateSet
const RenderStateSlot & defaultRenderState(ERenderState rs)
Returns the default render state slot used by VL when a specific render state type is left undefined...
void setStencilBufferBits(int bits)
RenderState wrapping the OpenGL function glSecondaryColor(), see also http://www.opengl.org/sdk/docs/man/xhtml/glSecondaryColor.xml for more information.
const T_Scalar & a() const
virtual bool setFullscreen(bool)
If the OpenGL context is a widget this function requests a maximization to fullscreen.
A set of enables managed by Shader.
const Framebuffer * framebuffer() const
The default render target (always returns leftFramebuffer()).
void dispatchMouseUpEvent(EMouseButton button, int x, int y)
Dispatches the UIEventListener::mouseUpEvent() notification to the subscribed UIEventListener objects...