Threading in OpenGL is non-trivial! Just do some internet searches for "OpenGL multithreading context" and you'll see what I mean.
More...
Classes | |
class | glut::Task |
Create one of these (you'll have to inherit) if you have openGL work you need to submit to requestTask(). More... | |
Functions | |
void | glut::fcolor_t::clear (void) throw () |
bool | glut::fcolor_t::isValid (void) const throw () |
glut::fcolor_t::operator float * (void) throw () | |
glut::fcolor_t::operator const float * (void) const throw () | |
virtual | glut::Host::~Host (void) throw () |
virtual void | glut::Host::init (void) |
Called once, at initialization (just before main glut loop). | |
virtual eBehavior | glut::Host::tick (IN float dt) |
Called on every glut idle event, with elapsed seconds since last. | |
virtual void | glut::Host::display (IN int w, IN int h) |
Called for every display frame. | |
virtual eBehavior | glut::Host::mouseMove (IN int x, IN int y) |
Called on mouse motion (see glutPassiveMotionFunc()). | |
virtual eBehavior | glut::Host::mouseButton (IN int button, IN int state, IN int x, IN int y) |
Called on mouse button events (see glutMouseFunc()). | |
virtual eBehavior | glut::Host::keyboard (IN int key, IN int mods) |
Called on keyboard events. | |
virtual eBehavior | glut::Host::specialKey (IN int key, IN int mods) |
Called when a special key is pressed (see glutSpecialFunc()). | |
virtual int | glut::Host::shutdown (void) |
Called only once, at glut shutdown. | |
virtual void | glut::Task::doTask (void)=0 |
here is where the implementer can do any OpenGL-specific work | |
void | glut::requestTask (IO Task *task) |
Here a thread can request that a task be handled by the open GL thread. | |
void | glut::drawRectLines (IN const rect3d_t &r, IN const glut_color_t &c) throw () |
draw the outline of a 3D rectangle | |
void | glut::getModelViewMatrix (OUT matrix4_t &T) throw () |
get a 4x4 matrix from the given OpenGL matrix | |
Variables | |
float | glut::fcolor_t::red |
float | glut::fcolor_t::green |
float | glut::fcolor_t::blue |
float | glut::fcolor_t::alpha |
Threading in OpenGL is non-trivial! Just do some internet searches for "OpenGL multithreading context" and you'll see what I mean.
In general, OpenGL isn't easy to use in a multithreaded way. It can be done, but for most purposes, diving into OpenGL contexts is probably overkill. However, by default OpenGL isn't thread-friendly, so some sort of synchronization is required.
This library uses multithreading in OpenGL in a very basic way: a single thread is doing all of the rendering, but background threads occasionally kick in and need to load and set up textures, etc.
When a thread needs to do some open-GL specific work (that is, any time it needs to call OpenGL or glut APIs!) it should request that as a task. If the calling thread is not the OpenGL thread, the call (requestTask()) will block until the OpenGL thread gets to it. If the thread is the OpenGL thread, then the task executes right away.
void glut::fcolor_t::clear | ( | void | ) | throw () [inline, inherited] |
Definition at line 85 of file lib/wave-glut/wave-glut.h.
bool glut::fcolor_t::isValid | ( | void | ) | const throw () [inline, inherited] |
Definition at line 89 of file lib/wave-glut/wave-glut.h.
glut::fcolor_t::operator float * | ( | void | ) | throw () [inline, inherited] |
Definition at line 95 of file lib/wave-glut/wave-glut.h.
glut::fcolor_t::operator const float * | ( | void | ) | const throw () [inline, inherited] |
Definition at line 98 of file lib/wave-glut/wave-glut.h.
glut::Host::~Host | ( | void | ) | throw () [virtual, inherited] |
Definition at line 48 of file wave-glut.cpp.
virtual void glut::Host::init | ( | void | ) | [inline, virtual, inherited] |
Called once, at initialization (just before main glut loop).
Definition at line 130 of file lib/wave-glut/wave-glut.h.
virtual eBehavior glut::Host::tick | ( | IN float | dt | ) | [inline, virtual, inherited] |
Called on every glut idle event, with elapsed seconds since last.
Definition at line 133 of file lib/wave-glut/wave-glut.h.
virtual void glut::Host::display | ( | IN int | w, | |
IN int | h | |||
) | [inline, virtual, inherited] |
Called for every display frame.
Definition at line 136 of file lib/wave-glut/wave-glut.h.
virtual eBehavior glut::Host::mouseMove | ( | IN int | x, | |
IN int | y | |||
) | [inline, virtual, inherited] |
Called on mouse motion (see glutPassiveMotionFunc()).
Definition at line 139 of file lib/wave-glut/wave-glut.h.
virtual eBehavior glut::Host::mouseButton | ( | IN int | button, | |
IN int | state, | |||
IN int | x, | |||
IN int | y | |||
) | [inline, virtual, inherited] |
Called on mouse button events (see glutMouseFunc()).
Definition at line 142 of file lib/wave-glut/wave-glut.h.
virtual eBehavior glut::Host::keyboard | ( | IN int | key, | |
IN int | mods | |||
) | [inline, virtual, inherited] |
Called on keyboard events.
Definition at line 147 of file lib/wave-glut/wave-glut.h.
virtual eBehavior glut::Host::specialKey | ( | IN int | key, | |
IN int | mods | |||
) | [inline, virtual, inherited] |
Called when a special key is pressed (see glutSpecialFunc()).
Definition at line 151 of file lib/wave-glut/wave-glut.h.
virtual int glut::Host::shutdown | ( | void | ) | [inline, virtual, inherited] |
Called only once, at glut shutdown.
Host can provide program return value (typically zero if no errors).
Definition at line 156 of file lib/wave-glut/wave-glut.h.
virtual void glut::Task::doTask | ( | void | ) | [pure virtual, inherited] |
here is where the implementer can do any OpenGL-specific work
void glut::requestTask | ( | IO Task * | task | ) |
Here a thread can request that a task be handled by the open GL thread.
Blocks until task is completed! If task throws an exception, the exception will also be thrown back to the caller.
void glut::drawRectLines | ( | IN const rect3d_t & | r, | |
IN const glut_color_t & | c | |||
) | throw () |
draw the outline of a 3D rectangle
void glut::getModelViewMatrix | ( | OUT matrix4_t & | T | ) | throw () |
get a 4x4 matrix from the given OpenGL matrix
float glut::fcolor_t::red [inherited] |
Definition at line 103 of file lib/wave-glut/wave-glut.h.
float glut::fcolor_t::green [inherited] |
Definition at line 104 of file lib/wave-glut/wave-glut.h.
float glut::fcolor_t::blue [inherited] |
Definition at line 105 of file lib/wave-glut/wave-glut.h.
float glut::fcolor_t::alpha [inherited] |
Definition at line 106 of file lib/wave-glut/wave-glut.h.