Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]

vl::OpenGLContext Class Reference

Represents an abstract GUI object containing an OpenGL context to which also keyboard, mouse or system events can be sent. More...

#include <OpenGLContext.hpp>

Inheritance diagram for vl::OpenGLContext:

vl::Object vlGLUT::GLUTWindow vlQt4::Qt4Widget vlSDL::SDLWindow vlWin32::Win32Context vlWX::vlWXGLCanvas vlMFC::MFCWindow vlWin32::Win32Window

List of all members.

Public Member Functions

virtual const char * className ()
 Returns the name of the class.
 OpenGLContext (int w=0, int h=0)
 Constructor.
 ~OpenGLContext ()
 Destructor.
void initExtensions (bool log=true)
 Initializes the supported OpenGL extensions.
void logOpenGLInfo ()
 Logs some information about the OpenGL context.
bool isExtensionSupported (const char *ext_name)
 Returns true if the given extension is supported.
void * getProcAddress (const char *function_name)
 Returns the address of an OpenGL extension function.
RenderTargetrenderTarget ()
 The render target representing this OpenGL context.
const RenderTargetrenderTarget () const
 The render target representing this OpenGL context.
ref< FBORenderTargetcreateFBORenderTarget (int width, int height)
 Creates a new FBORenderTarget (framebuffer object RenderTarget).
ref< FBORenderTargetcreateFBORenderTarget ()
 Equivalent to "createFBORenderTarget(0,0);".
void destroyFBORenderTarget (FBORenderTarget *fbort)
void destroyAllFBORenderTargets ()
virtual void quitApplication ()
 Asks to the windowing system that is managing the OpenGLContext to quit the application.
virtual void destroy ()
virtual void update ()
virtual void setWindowTitle (const String &)
virtual bool setFullscreen (bool)
virtual void show ()
virtual void hide ()
virtual void setPosition (int, int)
virtual void setSize (int, int)
virtual ivec2 position () const
virtual ivec2 size () const
virtual bool mouseVisible () const
virtual bool fullscreen () const
virtual void setMouseVisible (bool)
virtual void getFocus ()
virtual void swapBuffers ()
virtual void makeCurrent ()
virtual void setMousePosition (int, int)
void setVSyncEnabled (bool enable)
bool vsyncEnabled () const
virtual void setContinuousUpdate (bool continuous)
bool continuousUpdate () const
void sortEventListeners ()
void addEventListener (UIEventListener *el)
void removeEventListener (UIEventListener *el)
void eraseAllEventListeners ()
const std::vector< ref
< UIEventListener > > & 
eventListeners () const
UIEventListenereventListener (int i) const
int eventListenerCount () const
const OpenGLContextFormatopenglContextInfo () const
void setOpenGLContextInfo (const OpenGLContextFormat &info)
void ignoreNextMouseMoveEvent ()
int width () const
int height () const
void dispatchResizeEvent (int w, int h)
void dispatchMouseMoveEvent (int x, int y)
void dispatchMouseUpEvent (EMouseButton button, int x, int y)
void dispatchMouseDownEvent (EMouseButton button, int x, int y)
void dispatchMouseWheelEvent (int n)
void dispatchKeyPressEvent (unsigned short unicode_ch, EKey key)
void dispatchKeyReleaseEvent (unsigned short unicode_ch, EKey key)
void dispatchDestroyEvent ()
void dispatchRunEvent ()
void dispatchVisibilityEvent (bool visible)
void dispatchInitEvent ()
 Dispatches the init event.
void dispatchFileDroppedEvent (const std::vector< String > &files)
int textureUnitCount () const
const std::set< EKey > & keyboard () const
 Returns the std::set containing the currently pressed keys.
bool isKeyPressed (EKey key) const
 Returns true if the given key is pressed.
void keyPress (EKey key)
 For internal use only.
void keyRelease (EKey key)
 For internal use only.

Protected Attributes

ref< RenderTargetmRenderTarget
std::vector< ref
< FBORenderTarget > > 
mFBORenderTarget
std::vector< ref
< UIEventListener > > 
mEventListeners
std::set< EKeymKeyboard
OpenGLContextFormat mGLContextInfo
bool mMouseVisible
bool mContinuousUpdate
bool mIgnoreNextMouseMoveEvent
bool mFullscreen
int mTextureUnitCount


Detailed Description

Represents an abstract GUI object containing an OpenGL context to which also keyboard, mouse or system events can be sent.

OpenGLContext is an abstract class that wraps a minimal common subset of GUI APIs like Win32, Qt, wxWidgets, SDL, GLUT, etc.
In order to respond to the events generated by the OpenGLContext you must subclass an UIEventListener and bind it to the OpenGLContext using the functions addEventListener(ref<UIEventListener>) and removeEventListener(ref<UIEventListener>).

OpenGLContext custom implementation
  • Key_Alt/Ctrl/Shift events must always be notified before Key_Left/Right-Alt/Ctrl/Shift events.
  • Always update the mKeyboard structure appropriately especially with respect to Key_[Left/Right]-Alt/Ctrl/Shift events.
  • When cycling through EventListeners to dispatch the events you must do it on a temporary copy of mEventListeners so that the EventListeners can safely add/remove themselves or other EventListeners to the OpenGLContext itself.

Constructor & Destructor Documentation

vl::OpenGLContext::OpenGLContext ( int  w = 0,
int  h = 0 
) [inline]

Constructor.

vl::OpenGLContext::~OpenGLContext (  )  [inline]

Destructor.

Dispatches also destroyEvent() to its event listeners.


Member Function Documentation

virtual const char* vl::OpenGLContext::className (  )  [inline, virtual]

Returns the name of the class.

Reimplemented from vl::Object.

void OpenGLContext::initExtensions ( bool  log = true  ) 

Initializes the supported OpenGL extensions.

void OpenGLContext::logOpenGLInfo (  ) 

Logs some information about the OpenGL context.

bool OpenGLContext::isExtensionSupported ( const char *  ext_name  ) 

Returns true if the given extension is supported.

Note:
This is a relatively slow function, don't use it inside loops and similar.

void * OpenGLContext::getProcAddress ( const char *  function_name  ) 

Returns the address of an OpenGL extension function.

RenderTarget* vl::OpenGLContext::renderTarget (  )  [inline]

The render target representing this OpenGL context.

The returned RenderTarget's dimensions will be automatically updated to the OpenGLContext's dimensions.

const RenderTarget* vl::OpenGLContext::renderTarget (  )  const [inline]

The render target representing this OpenGL context.

The returned RenderTarget's dimensions will be automatically updated to the OpenGLContext's dimensions.

ref<FBORenderTarget> vl::OpenGLContext::createFBORenderTarget ( int  width,
int  height 
) [inline]

Creates a new FBORenderTarget (framebuffer object RenderTarget).

Note:
A framebuffer object always belongs to an OpenGL context and in order to render on it the appropriate OpenGL context must be active.

ref<FBORenderTarget> vl::OpenGLContext::createFBORenderTarget (  )  [inline]

Equivalent to "createFBORenderTarget(0,0);".

void vl::OpenGLContext::destroyFBORenderTarget ( FBORenderTarget fbort  )  [inline]

void vl::OpenGLContext::destroyAllFBORenderTargets (  )  [inline]

virtual void vl::OpenGLContext::quitApplication (  )  [inline, virtual]

Asks to the windowing system that is managing the OpenGLContext to quit the application.

Reimplemented in vlQt4::Qt4Widget, vlWX::vlWXGLCanvas, vlWin32::Win32Context, vlGLUT::GLUTWindow, and vlSDL::SDLWindow.

virtual void vl::OpenGLContext::destroy (  )  [inline, virtual]

virtual void vl::OpenGLContext::update (  )  [inline, virtual]

virtual void vl::OpenGLContext::setWindowTitle ( const String  )  [inline, virtual]

virtual bool vl::OpenGLContext::setFullscreen ( bool   )  [inline, virtual]

virtual void vl::OpenGLContext::show (  )  [inline, virtual]

virtual void vl::OpenGLContext::hide (  )  [inline, virtual]

virtual void vl::OpenGLContext::setPosition ( int  ,
int   
) [inline, virtual]

virtual void vl::OpenGLContext::setSize ( int  ,
int   
) [inline, virtual]

virtual ivec2 vl::OpenGLContext::position (  )  const [inline, virtual]

virtual ivec2 vl::OpenGLContext::size (  )  const [inline, virtual]

virtual bool vl::OpenGLContext::mouseVisible (  )  const [inline, virtual]

virtual bool vl::OpenGLContext::fullscreen (  )  const [inline, virtual]

virtual void vl::OpenGLContext::setMouseVisible ( bool   )  [inline, virtual]

virtual void vl::OpenGLContext::getFocus (  )  [inline, virtual]

virtual void vl::OpenGLContext::swapBuffers (  )  [inline, virtual]

virtual void vl::OpenGLContext::makeCurrent (  )  [inline, virtual]

virtual void vl::OpenGLContext::setMousePosition ( int  ,
int   
) [inline, virtual]

void OpenGLContext::setVSyncEnabled ( bool  enable  ) 

bool OpenGLContext::vsyncEnabled (  )  const

virtual void vl::OpenGLContext::setContinuousUpdate ( bool  continuous  )  [inline, virtual]

Reimplemented in vlQt4::Qt4Widget.

bool vl::OpenGLContext::continuousUpdate (  )  const [inline]

void OpenGLContext::sortEventListeners (  ) 

void OpenGLContext::addEventListener ( UIEventListener el  ) 

Note:
An UIEventListener can be associated only to one OpenGLContext at a time.

void OpenGLContext::removeEventListener ( UIEventListener el  ) 

void OpenGLContext::eraseAllEventListeners (  ) 

const std::vector< ref<UIEventListener> >& vl::OpenGLContext::eventListeners (  )  const [inline]

UIEventListener* vl::OpenGLContext::eventListener ( int  i  )  const [inline]

int vl::OpenGLContext::eventListenerCount (  )  const [inline]

const OpenGLContextFormat& vl::OpenGLContext::openglContextInfo (  )  const [inline]

void vl::OpenGLContext::setOpenGLContextInfo ( const OpenGLContextFormat info  )  [inline]

void vl::OpenGLContext::ignoreNextMouseMoveEvent (  )  [inline]

int vl::OpenGLContext::width (  )  const [inline]

int vl::OpenGLContext::height (  )  const [inline]

void vl::OpenGLContext::dispatchResizeEvent ( int  w,
int  h 
) [inline]

void vl::OpenGLContext::dispatchMouseMoveEvent ( int  x,
int  y 
) [inline]

void vl::OpenGLContext::dispatchMouseUpEvent ( EMouseButton  button,
int  x,
int  y 
) [inline]

void vl::OpenGLContext::dispatchMouseDownEvent ( EMouseButton  button,
int  x,
int  y 
) [inline]

void vl::OpenGLContext::dispatchMouseWheelEvent ( int  n  )  [inline]

void vl::OpenGLContext::dispatchKeyPressEvent ( unsigned short  unicode_ch,
EKey  key 
) [inline]

void vl::OpenGLContext::dispatchKeyReleaseEvent ( unsigned short  unicode_ch,
EKey  key 
) [inline]

void vl::OpenGLContext::dispatchDestroyEvent (  )  [inline]

void vl::OpenGLContext::dispatchRunEvent (  )  [inline]

void vl::OpenGLContext::dispatchVisibilityEvent ( bool  visible  )  [inline]

void vl::OpenGLContext::dispatchInitEvent (  )  [inline]

Dispatches the init event.

void vl::OpenGLContext::dispatchFileDroppedEvent ( const std::vector< String > &  files  )  [inline]

int vl::OpenGLContext::textureUnitCount (  )  const [inline]

const std::set<EKey>& vl::OpenGLContext::keyboard (  )  const [inline]

Returns the std::set containing the currently pressed keys.

bool vl::OpenGLContext::isKeyPressed ( EKey  key  )  const [inline]

Returns true if the given key is pressed.

void vl::OpenGLContext::keyPress ( EKey  key  )  [inline]

For internal use only.

void vl::OpenGLContext::keyRelease ( EKey  key  )  [inline]

For internal use only.


Member Data Documentation

std::set<EKey> vl::OpenGLContext::mKeyboard [protected]


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

Visualization Library v2009.08 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Fri Aug 28 10:14:12 2009.
Permission is granted to use this page to write and publish articles regarding Visualization Library.