#include <mesa_base.h>
Inheritance diagram for mimas::mesa_base:
Public Member Functions | |
virtual | ~mesa_base (void) |
Destructor. | |
virtual void | finish (void) |
Finish output on the image. | |
virtual void | ortho2D (void) const =0 |
Switch to two-dimensional drawing mode. | |
virtual void | ortho2D (int x1, int y1, int x2, int y2) const =0 |
Switch to two-dimensional drawing mode with clipping. | |
void | setColor (const rgba< unsigned char > &color) const |
Set color. | |
void | setGray (unsigned char gray) const |
Set luminance. | |
void | rectangle (int x1, int y1, int x2, int y2) const |
Draw rectangle. | |
void | text (const std::string &s) const |
Write text. | |
Protected Member Functions | |
mesa_base (x11_display *_display, XVisualInfo *_visualInfo) throw (mimasexception) | |
Protected constructor. | |
void | glWrap (bool condition, const char *message) throw (mimasexception) |
Wrapper for converting OpenGL error messages to exceptions. | |
Protected Attributes | |
x11_display * | display |
X11-display. | |
XVisualInfo * | visualInfo |
X11-visual with desired attributes. | |
bool | finishBase |
State of object. | |
Static Protected Attributes | |
static bool | existInstance |
There must be only one instance of this class. |
The mesa-functionality mainly consists in offering initialisation of an OpenGL-context for on-screen- or off-screen-rendering.
After initialisation of a deriving non-abstract class, the OpenGL functionality can be either accessed directly using the OpenGL methods bypassing this class or accessed indirectly by using one of the few wrappers for setting the color, for drawing rectangles and for displaying text, being provided by this class.
At any time there must be only one instance of this class to avoid crashes of X11, side-effects or deadlocks.
Xorg 6.9.0 does not display gray images properly (GL_LUMINANCE). A bug report was filed: http://bugs.freedesktop.org/show_bug.cgi?id=7444
If you experience problems, you may want to try:
export LIBGL_ALWAYS_INDIRECT=1
If it works:
If it doesn't:
Do not forget to initialise glut at the beginning of your program:
glutInit( &argc, argv );
References:
Definition at line 58 of file mesa_base.h.
virtual mimas::mesa_base::~mesa_base | ( | void | ) | [virtual] |
mimas::mesa_base::mesa_base | ( | x11_display * | _display, | |
XVisualInfo * | _visualInfo | |||
) | throw (mimasexception) [protected] |
Protected constructor.
The display
and visualInfo
variables must be destructed by the calling program.
_display | X11 display variable. | |
_visualInfo | X11 visual info structure. |
virtual void mimas::mesa_base::finish | ( | void | ) | [virtual] |
Finish output on the image.
This method allows finalising of the output without having to destruct this object immediately.
Only call after having finished rendering. This object has to be destructed afterwards.
Reimplemented in mimas::mesa_offscreen< T >, and mimas::mesa_onscreen.
virtual void mimas::mesa_base::ortho2D | ( | void | ) | const [pure virtual] |
Switch to two-dimensional drawing mode.
The coordinate system has the origin in the "top-left" corner of the image.
Implemented in mimas::mesa_offscreen< T >, and mimas::mesa_onscreen.
Switch to two-dimensional drawing mode with clipping.
The coordinate system has the origin in the "top-left" corner of the image.
Implemented in mimas::mesa_offscreen< T >, and mimas::mesa_onscreen.
void mimas::mesa_base::setColor | ( | const rgba< unsigned char > & | color | ) | const [inline] |
Set color.
color | Color-object. The alpha-component is ignored. |
Definition at line 82 of file mesa_base.h.
References mimas::rgba< T >::getBlue(), mimas::rgba< T >::getGreen(), and mimas::rgba< T >::getRed().
Here is the call graph for this function:
void mimas::mesa_base::setGray | ( | unsigned char | gray | ) | const [inline] |
Draw rectangle.
x1 | x-coordinate of upper-left corner of rectangle. | |
y1 | y-coordinate of upper-left corner of rectangle. | |
x2 | x-coordinate of lower-right corner of rectangle. | |
y2 | y-coordinate of lower-right corner of rectangle. |
void mimas::mesa_base::text | ( | const std::string & | s | ) | const |
Write text.
void mimas::mesa_base::glWrap | ( | bool | condition, | |
const char * | message | |||
) | throw (mimasexception) [protected] |
Wrapper for converting OpenGL error messages to exceptions.
The wrapper will generate an exception (using gluErrorString
), if the condition is not fullfilled.
condition | If the condition is false , an exception is thrown. | |
message | Textual description of context, which is prepended to the error-message. |
x11_display* mimas::mesa_base::display [protected] |
XVisualInfo* mimas::mesa_base::visualInfo [protected] |
bool mimas::mesa_base::finishBase [protected] |
bool mimas::mesa_base::existInstance [static, protected] |