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);
224 void destroyAllFramebufferObjects();
227 void destroyAllOpenGLResources();
233 virtual void update() = 0;
260 int width()
const {
return framebuffer()->width(); }
263 int height()
const {
return framebuffer()->height(); }
278 void setVSyncEnabled(
bool enable);
281 bool vsyncEnabled()
const;
298 void eraseAllEventListeners();
301 const std::vector< ref<UIEventListener> >&
eventListeners()
const {
return mEventListeners; }
326 leftFramebuffer()->setWidth(w);
327 leftFramebuffer()->setHeight(h);
328 rightFramebuffer()->setWidth(w);
329 rightFramebuffer()->setHeight(h);
331 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
332 for(
unsigned i=0; i<temp_clients.size(); ++i )
333 if ( temp_clients[i]->isEnabled() )
334 temp_clients[i]->resizeEvent( w, h );
341 if (mIgnoreNextMouseMoveEvent)
342 mIgnoreNextMouseMoveEvent =
false;
345 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
346 for(
unsigned i=0; i<temp_clients.size(); ++i )
347 if ( temp_clients[i]->isEnabled() )
348 temp_clients[i]->mouseMoveEvent(x, y);
356 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
357 for(
unsigned i=0; i<temp_clients.size(); ++i )
358 if ( temp_clients[i]->isEnabled() )
359 temp_clients[i]->mouseUpEvent(button, x, y);
366 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
367 for(
unsigned i=0; i<temp_clients.size(); ++i )
368 if ( temp_clients[i]->isEnabled() )
369 temp_clients[i]->mouseDownEvent(button, x, y);
376 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
377 for(
unsigned i=0; i<temp_clients.size(); ++i )
378 if ( temp_clients[i]->isEnabled() )
379 temp_clients[i]->mouseWheelEvent(n);
387 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
388 for(
unsigned i=0; i<temp_clients.size(); ++i )
389 if ( temp_clients[i]->isEnabled() )
390 temp_clients[i]->keyPressEvent(unicode_ch, key);
398 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
399 for(
unsigned i=0; i<temp_clients.size(); ++i )
400 if ( temp_clients[i]->isEnabled() )
401 temp_clients[i]->keyReleaseEvent(unicode_ch, key);
410 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
411 for(
unsigned i=0; i<temp_clients.size(); ++i )
412 if ( temp_clients[i]->isEnabled() )
413 temp_clients[i]->destroyEvent();
414 destroyAllOpenGLResources();
415 eraseAllEventListeners();
422 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
423 for(
unsigned i=0; i<temp_clients.size(); ++i )
424 if ( temp_clients[i]->isEnabled() )
425 temp_clients[i]->updateEvent();
432 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
433 for(
unsigned i=0; i<temp_clients.size(); ++i )
434 if ( temp_clients[i]->isEnabled() )
435 temp_clients[i]->visibilityEvent(visible);
446 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
447 for(
unsigned i=0; i<temp_clients.size(); ++i )
448 if ( temp_clients[i]->isEnabled() )
449 temp_clients[i]->initEvent();
456 std::vector< ref<UIEventListener> > temp_clients = eventListeners();
457 for(
unsigned i=0; i<temp_clients.size(); ++i )
458 if ( temp_clients[i]->isEnabled() )
459 temp_clients[i]->fileDroppedEvent(files);
463 const std::set<EKey>&
keyboard()
const {
return mKeyboard; }
503 void bindVAS_Reset();
506 void applyEnables(
const EnableSet* cur );
515 void resetRenderStates();
520 mDefaultRenderStates[rs_slot.
type()] = rs_slot;
522 if (!mCurrentRenderStateSet->hasKey(rs_slot.
type()))
537 VL_CHECK(unit_i <= VL_MAX_TEXTURE_IMAGE_UNITS);
538 mTexUnitBinding[unit_i] = target;
544 VL_CHECK(unit_i <= VL_MAX_TEXTURE_IMAGE_UNITS);
545 return mTexUnitBinding[unit_i];
573 bool isCleanState(
bool verbose);
621 struct VertexArrayInfo
623 VertexArrayInfo(): mBufferObject(0), mPtr(0), mEnabled(
false) {}
625 const unsigned char* mPtr;
648 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
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
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 FramebufferObject * framebuffer() const
The default render target (always returns leftFramebuffer()).
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.
FramebufferObject * framebuffer()
The default render target (always returns leftFramebuffer()).
void keyPress(EKey key)
Inserts the specified key in the set of currently active keys - For internal use only.
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.
const FramebufferObject * rightFramebuffer() const
The render target representing the default right framebuffer (if a stereo OpenGL context is present)...
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...
FramebufferObject * createFramebufferObject()
Equivalent to "createFramebufferObject(0,0);".
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.
ref< FramebufferObject > mRightFramebuffer
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
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...
ref< FramebufferObject > mLeftFramebuffer
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_...
int depthBufferBits() const
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...
void setVSync(bool vsync_on)
OpenGLContextFormat mGLContextInfo
ERenderState type() const
void setMultisampleSamples(int samples)
void setStereo(bool stereo_on)
const FramebufferObject * leftFramebuffer() const
The render target representing the default left framebuffer.
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)
FramebufferObject * leftFramebuffer()
The render target representing the default left framebuffer.
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.
FramebufferObject * rightFramebuffer()
The render target representing the default right framebuffer (if a stereo OpenGL context is present)...
int mTextureImageUnitCount
ref< NaryQuickMap< EEnable, EEnable, EN_EnableCount > > mCurrentEnableSet
std::vector< ref< FramebufferObject > > mFramebufferObject
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.
void dispatchMouseUpEvent(EMouseButton button, int x, int y)
Dispatches the UIEventListener::mouseUpEvent() notification to the subscribed UIEventListener objects...