Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
OpenGLContext.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef OpenGLContext_INCLUDE_ONCE
33 #define OpenGLContext_INCLUDE_ONCE
34 
35 #include <vlCore/Object.hpp>
37 #include <vlGraphics/FramebufferObject.hpp> // Framebuffer and FramebufferObject
40 #include <vlGraphics/GLSL.hpp>
41 #include <vector>
42 #include <set>
43 
44 namespace vl
45 {
46  class EnableSet;
47  class RenderStateSet;
48  class UniformSet;
49  class IVertexAttribSet;
50  class ArrayAbstract;
51 
52  //-----------------------------------------------------------------------------
53  // OpenGLContextFormat
54  //-----------------------------------------------------------------------------
57  {
58  public:
60  mRGBABits(ivec4(8,8,8,0)),
61  mAccumRGBABits(ivec4(0,0,0,0)),
62  mZBufferBits(24),
66  mMajVersion(0),
67  mMinVersion(0),
68  mHasDoubleBuffer(true),
69  mHasMultisample(false),
70  mStereo(false),
71  mFullscreen(false),
72  mVSync(false),
74 
75  void setRGBABits(int r, int g, int b, int a) { mRGBABits = ivec4(r,g,b,a); }
76  void setAccumRGBABits(int r, int g, int b, int a) { mAccumRGBABits = ivec4(r,g,b,a); }
77  void setDoubleBuffer(bool double_buffer_on) { mHasDoubleBuffer = double_buffer_on; }
78  void setDepthBufferBits(int bits) { mZBufferBits = bits; }
79  void setStencilBufferBits(int bits) { mStencilBufferBits = bits; }
80  void setMultisample(bool multisample_on) { mHasMultisample = multisample_on; }
81  void setMultisampleSamples(int samples) { mMultisampleSamples = samples; }
82  void setStereo(bool stereo_on) { mStereo = stereo_on; }
83  void setFullscreen(bool fullscreent) { mFullscreen = fullscreent; }
84  void setVSync(bool vsync_on) { mVSync = vsync_on; }
86  void setContextClientVersion(int version) { mContextClientVersion = version; }
87 
88  const ivec4& rgbaBits() const { return mRGBABits; }
89  const ivec4& accumRGBABits() const { return mAccumRGBABits; }
90  bool doubleBuffer() const { return mHasDoubleBuffer; }
91  int depthBufferBits() const { return mZBufferBits; }
92  int stencilBufferBits() const { return mStencilBufferBits; }
93  bool multisample() const { return mHasMultisample; }
94  int multisampleSamples() const { return mMultisampleSamples; }
95  bool stereo() const { return mStereo; }
96  bool fullscreen() const { return mFullscreen; }
97  bool vSync() const { return mVSync; }
100 
102  int bitsPerPixel() const { return rgbaBits().r() + rgbaBits().g() + rgbaBits().b() + rgbaBits().a(); }
103 
108 
110  void setVersion( int majv, int minv ) { mMajVersion = majv; mMinVersion = minv; }
111  int majVersion() const { return mMajVersion; }
112  int minVersion() const { return mMinVersion; }
113 
114  protected:
125  bool mStereo;
127  bool mVSync;
129  };
130  //-----------------------------------------------------------------------------
131  // OpenGLContext
132  //-----------------------------------------------------------------------------
145  {
147  friend class VertexAttrib;
148  friend class Color;
149  friend class SecondaryColor;
150  friend class Normal;
151 
152  public:
154  OpenGLContext(int w=0, int h=0);
155 
157  ~OpenGLContext();
158 
160  virtual void swapBuffers() = 0;
161 
163  virtual void makeCurrent() = 0;
164 
166  bool initGLContext(bool log=true);
167 
169  void logOpenGLInfo();
170 
172  const std::string& extensions() const { return mExtensions; }
173 
176  bool isExtensionSupported(const char* ext_name);
177 
179  void* getProcAddress(const char* function_name);
180 
184  Framebuffer* leftFramebuffer() { return mLeftFramebuffer.get(); }
185 
189  const Framebuffer* leftFramebuffer() const { return mLeftFramebuffer.get(); }
190 
194  Framebuffer* rightFramebuffer() { return mRightFramebuffer.get(); }
195 
199  const Framebuffer* rightFramebuffer() const { return mRightFramebuffer.get(); }
200 
203  Framebuffer* framebuffer() { return leftFramebuffer(); }
204 
207  const Framebuffer* framebuffer() const { return leftFramebuffer(); }
208 
211 
214  ref<FramebufferObject> createFramebufferObject(int width, int height,
217 
219  void destroyFramebufferObject(FramebufferObject* fbort);
220 
222  void destroyAllFramebufferObjects();
223 
225  void destroyAllOpenGLResources();
226 
228  virtual void quitApplication() {}
229 
231  virtual void update() = 0;
232 
234  virtual void setWindowTitle(const String&) {}
235 
237  virtual bool setFullscreen(bool) { mFullscreen = false; return false; }
238 
240  virtual bool fullscreen() const { return mFullscreen; }
241 
243  virtual void show() {}
244 
246  virtual void hide() {}
247 
249  virtual void setPosition(int /*x*/, int /*y*/) {}
250 
252  virtual ivec2 position() const { return ivec2(); }
253 
255  virtual void setSize(int /*w*/, int /*h*/) {}
256 
258  int width() const { return framebuffer()->width(); }
259 
261  int height() const { return framebuffer()->height(); }
262 
264  virtual void setMouseVisible(bool) { mMouseVisible=false; }
265 
267  virtual bool mouseVisible() const { return mMouseVisible; }
268 
270  virtual void setMousePosition(int /*x*/, int /*y*/) {}
271 
273  virtual void getFocus() {}
274 
276  void setVSyncEnabled(bool enable);
277 
279  bool vsyncEnabled() const;
280 
282  virtual void setContinuousUpdate(bool continuous) { mContinuousUpdate = continuous; }
283 
285  bool continuousUpdate() const { return mContinuousUpdate; }
286 
290  void addEventListener(UIEventListener* el);
291 
293  void removeEventListener(UIEventListener* el);
294 
296  void eraseAllEventListeners();
297 
299  const std::vector< ref<UIEventListener> >& eventListeners() const { return mEventListeners; }
300 
302  const UIEventListener* eventListener(int i) const { return mEventListeners[i].get(); }
303 
305  UIEventListener* eventListener(int i) { return mEventListeners[i].get(); }
306 
308  int eventListenerCount() const { return (int)mEventListeners.size(); }
309 
311  const OpenGLContextFormat& openglContextInfo() const { return mGLContextInfo; }
312 
314  void setOpenGLContextInfo(const OpenGLContextFormat& info) { mGLContextInfo = info; }
315 
317  void ignoreNextMouseMoveEvent() { mIgnoreNextMouseMoveEvent = true; }
318 
321  void dispatchResizeEvent(int w, int h)
322  {
323  makeCurrent();
324  leftFramebuffer()->setWidth(w);
325  leftFramebuffer()->setHeight(h);
326  rightFramebuffer()->setWidth(w);
327  rightFramebuffer()->setHeight(h);
328 
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 );
333  }
334 
336  void dispatchMouseMoveEvent(int x, int y)
337  {
338  makeCurrent();
339  if (mIgnoreNextMouseMoveEvent)
340  mIgnoreNextMouseMoveEvent = false;
341  else
342  {
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);
347  }
348  }
349 
351  void dispatchMouseUpEvent(EMouseButton button, int x, int y)
352  {
353  makeCurrent();
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);
358  }
359 
361  void dispatchMouseDownEvent(EMouseButton button, int x, int y)
362  {
363  makeCurrent();
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);
368  }
369 
372  {
373  makeCurrent();
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);
378  }
379 
381  void dispatchKeyPressEvent(unsigned short unicode_ch, EKey key)
382  {
383  makeCurrent();
384  keyPress(key);
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);
389  }
390 
392  void dispatchKeyReleaseEvent(unsigned short unicode_ch, EKey key)
393  {
394  makeCurrent();
395  keyRelease(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);
400  }
401 
406  {
407  makeCurrent();
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();
414  }
415 
418  {
419  makeCurrent();
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();
424  }
425 
427  void dispatchVisibilityEvent(bool visible)
428  {
429  makeCurrent();
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);
434  }
435 
437  // - called as soon as the OpenGL context is available but before the first resize event
438  // - when initEvent() is called all the supported OpenGL extensions are already available
439  // - when initEvent() is called the window has already acquired its width and height
440  // - only the enabled event listeners receive this message
442  {
443  makeCurrent();
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();
448  }
449 
451  void dispatchFileDroppedEvent(const std::vector<String>& files)
452  {
453  makeCurrent();
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);
458  }
459 
461  const std::set<EKey>& keyboard() const { return mKeyboard; }
462 
464  bool isKeyPressed(EKey key) const { return mKeyboard.find(key) != mKeyboard.end(); }
465 
467  void keyPress(EKey key) { mKeyboard.insert(key); }
468 
470  void keyRelease(EKey key) { mKeyboard.erase(key); }
471 
473  bool isInitialized() const { return mIsInitialized; }
474 
476  int vertexAttribCount() const { return mVertexAttribCount; }
477 
479  int textureImageUnitCount() const { return mTextureImageUnitCount; }
480 
483  int textureCoordCount() const { return mTextureCoordCount; }
484 
486  bool hasDoubleBuffer() const { return mHasDoubleBuffer; }
487 
488  // --- render states management ---
489 
491  void useGLSLProgram(const GLSLProgram* glsl);
492 
498  void bindVAS(const IVertexAttribSet* vas, bool use_vbo, bool force);
499  void bindVAS_Attribs(const IVertexAttribSet* vas, bool use_vbo);
500  void bindVAS_Fixed(const IVertexAttribSet* vas, bool use_vbo);
501  void bindVAS_Reset();
502 
504  void applyEnables( const EnableSet* cur );
505 
507  void applyRenderStates( const RenderStateSet* cur, const Camera* camera );
508 
510  void resetEnables();
511 
513  void resetRenderStates();
514 
517  {
518  mDefaultRenderStates[rs_slot.type()] = rs_slot;
519  // if we are in the default render state then apply it immediately
520  if (!mCurrentRenderStateSet->hasKey(rs_slot.type()))
521  {
522  mDefaultRenderStates[rs_slot.type()].apply(NULL, this); VL_CHECK_OGL();
523  }
524  }
525 
527  const RenderStateSlot& defaultRenderState(ERenderState rs) { return mDefaultRenderStates[rs]; }
528 
530  void resetContextStates(EResetContextStates start_or_finish);
531 
533  void setTexUnitBinding(int unit_i, ETextureDimension target)
534  {
535  VL_CHECK(unit_i <= VL_MAX_TEXTURE_IMAGE_UNITS);
536  mTexUnitBinding[unit_i] = target;
537  }
538 
541  {
542  VL_CHECK(unit_i <= VL_MAX_TEXTURE_IMAGE_UNITS);
543  return mTexUnitBinding[unit_i];
544  }
545 
546  const GLSLProgram* glslProgram() const { return mGLSLProgram.get(); }
547  GLSLProgram* glslProgram() { return mGLSLProgram.get(); }
548 
549 
551  static bool areUniformsColliding(const UniformSet* u1, const UniformSet* u2);
552 
571  bool isCleanState(bool verbose);
572 
573  public:
574  // constant color
575  const fvec3& normal() const { return mNormal; }
576  const fvec4& color() const { return mColor; }
577  const fvec3& secondaryColor() const { return mSecondaryColor; }
578  const fvec4& vertexAttribValue(int i) const { VL_CHECK(i<VA_MaxAttribCount); return mVertexAttribValue[i]; }
579 
580  protected:
583  std::vector< ref<FramebufferObject> > mFramebufferObject;
584  std::vector< ref<UIEventListener> > mEventListeners;
585  std::set<EKey> mKeyboard;
596  std::string mExtensions;
597 
598  // --- Render States ---
599 
600  // default render states
601  RenderStateSlot mDefaultRenderStates[RS_RenderStateCount];
602 
603  // applyEnables()
606 
607  // applyRenderStates()
610 
611  // for each texture unit tells which target has been bound last.
612  ETextureDimension mTexUnitBinding[VL_MAX_TEXTURE_IMAGE_UNITS];
613 
614  // current GLSL
617 
618  private:
619  struct VertexArrayInfo
620  {
621  VertexArrayInfo(): mBufferObject(0), mPtr(0), mEnabled(false) {}
622  int mBufferObject;
623  const unsigned char* mPtr;
624  bool mEnabled;
625  };
626 
627  protected:
628  // --- VertexAttribSet Management ---
630  VertexArrayInfo mVertexArray;
631  VertexArrayInfo mNormalArray;
632  VertexArrayInfo mColorArray;
633  VertexArrayInfo mSecondaryColorArray;
634  VertexArrayInfo mFogArray;
635  VertexArrayInfo mTexCoordArray[VA_MaxTexCoordCount];
636  VertexArrayInfo mVertexAttrib[VA_MaxAttribCount];
637 
638  // save and restore constant attributes
642  fvec4 mVertexAttribValue[VA_MaxAttribCount];
643  GLuint mDefaultVAO;
644 
645  private:
646  void setupDefaultRenderStates();
647  };
648  // ----------------------------------------------------------------------------
649 }
650 
651 #endif
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.
Definition: Vector2.hpp:278
void dispatchInitEvent()
Dispatches the UIEventListener::initEvent() notification to the subscribed UIEventListener objects...
Abstract interface to manipulate OpenGL&#39;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
ERenderState
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...
Definition: Shader.hpp:162
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
VertexArrayInfo mFogArray
int multisampleSamples() const
const T_Scalar & r() const
Definition: Vector4.hpp:111
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...
STL namespace.
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
EOpenGLProfile
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. ...
Definition: GLSL.hpp:233
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.
std::string mExtensions
EResetContextStates
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.
T log(T a)
Definition: glsl_math.hpp:486
void setFullscreen(bool fullscreent)
RenderState wrapping the OpenGL function glColor(), see also http://www.opengl.org/sdk/docs/man/xhtml...
Definition: Shader.hpp:94
const std::vector< ref< UIEventListener > > & eventListeners() const
The currently UIEventListener registered to be notified of OpenGLContext related events.
const fvec3 & normal() const
EReadDrawBuffer
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
Definition: Vector4.hpp:112
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
void setOpenGLContextInfo(const OpenGLContextFormat &info)
Sets the OpenGLContextFormat associated to an OpenGLContext.
Vector4< int > ivec4
A 4 components vector with int precision.
Definition: Vector4.hpp:275
RenderState wrapping the OpenGL function glVertexAttrib(), see also http://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttrib.xml for more information.
Definition: Shader.hpp:60
int height() const
Returns the height in pixels of an OpenGLContext.
The base class for all the reference counted objects.
Definition: Object.hpp:158
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.
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
EMouseButton
const fvec4 & vertexAttribValue(int i) const
ref< Framebuffer > mRightFramebuffer
VertexArrayInfo mNormalArray
const T_Scalar & b() const
Definition: Vector4.hpp:113
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.
#define NULL
Definition: OpenGLDefs.hpp:81
const UIEventListener * eventListener(int i) const
Returns the i-th UIEventListener registered to an OpenGLContext.
A set of RenderState objects managed by a Shader.
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.
ETextureDimension
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&#39;d like to access.
void dispatchFileDroppedEvent(const std::vector< String > &files)
Dispatches the UIEventListener::fileDroppedEvent() notification to the subscribed UIEventListener obj...
#define VL_CHECK_OGL()
Definition: OpenGL.hpp:156
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:145
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)...
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)
A set of Uniform objects managed by a Shader.
Definition: UniformSet.hpp:50
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.
Definition: Object.hpp:55
void setMultisample(bool multisample_on)
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
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.
#define VL_CHECK(expr)
Definition: checks.hpp:73
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 &#39;surface&#39; where OpenGL can render into. ...
Definition: Framebuffer.hpp:49
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.
Definition: Shader.hpp:128
const T_Scalar & a() const
Definition: Vector4.hpp:114
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.
Definition: EnableSet.hpp:47
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...