#include <mesa_offscreen.h>
Inheritance diagram for mimas::mesa_offscreen< T >:


Public Member Functions | |
| mesa_offscreen (x11_display *_display, image< T > &image, bool depthBuffer=false) | |
| Constructor. | |
| virtual | ~mesa_offscreen (void) |
| Destructor. | |
| virtual void | finish (void) |
| Finish output on the image. | |
| virtual void | ortho2D (int x1, int y1, int x2, int y2) const |
| Switch to two-dimensional drawing mode. | |
| virtual void | ortho2D (void) const |
| Switch to two-dimensional drawing mode. | |
Protected Member Functions | |
| GLenum | getFormat (void) const throw (mimasexception) |
| void | setupColorScale (void) const |
Protected Attributes | |
| Pixmap | pixmap |
| X11 pixmap. | |
| GLXPixmap | glxPixmap |
| Corresponding GLX pixmap. | |
| GLXContext | context |
| GLX context for off-screen rendering. | |
| void * | data |
| Pointer to image-data to write back later. | |
| int | width |
| Width of image. | |
| int | height |
| Height of image. | |
| bool | finishOffscreen |
Support for off-screen rendering using Mesa.
No stencil- and accumulation-buffer are allocated.
Do not forget to initialise glut at the beginning of your program:
glutInit( &argc, argv );
The following example uses off-screen rendering to display text:
#include <GL/glut.h> #include "mesa_offscreen.h" #include "mesa_onscreen.h" #include "image_mesaoutput.h" using namespace boost; using namespace std; using namespace mimas; image< rgba< unsigned char > > gaudy(void) { image< rgba< unsigned char > > image; image.init( 256, 256 ); for ( int k=0; k<=255; k++ ) for ( int j=0; j<=255; j++ ) image.pixel( k, j ) = rgba< unsigned char >( k, j, 255 - k ); return image; } void rotatedText( mesa_base &m, int angle, const string &text ) { m.rectangle( 0, 0, 255, 255 ); glPushMatrix(); glTranslated( 20, 200, 0 ); glScaled( 0.1, -0.1, 1.0 ); glRotatef( angle, 0, 0, 1 ); m.text( text ); glPopMatrix(); } int main( int argc, char *argv[] ) { int retVal = 0; // Initialise GLUT. glutInit( &argc, argv ); try { // Open X11 display. x11_display display; // Off-screen rendering on colour- and grey-images. // Create two image-output windows. image_mesaoutput< rgba< unsigned char > > window( &display ); // Create background images. image< rgba< unsigned char > > image( gaudy() ); // Do some off-screen rendering on it. { mesa_offscreen< rgba< unsigned char > > m( &display, image, false ); m.ortho2D(); const rgba< unsigned char > green( 0, 128, 0 ); m.setColor( green ); rotatedText( m, 30, "offscreen" ); }; window << image << mimas::pause(); } catch ( exception &e ) { cerr << e.what() << endl; retVal = 1; }; return retVal; }
If you experience problems, you may want to try:
export LIBGL_ALWAYS_INDIRECT=1
If it works:
If it doesn't:
References:
Definition at line 58 of file mesa_offscreen.h.
| mimas::mesa_offscreen< T >::mesa_offscreen | ( | x11_display * | _display, | |
| image< T > & | image, | |||
| bool | depthBuffer = false | |||
| ) |
Constructor.
| _display | X11 display | |
| image | Image to draw on. | |
| depthBuffer | Boolean indicating, wether to use a depth-buffer. |
| virtual mimas::mesa_offscreen< T >::~mesa_offscreen | ( | void | ) | [virtual] |
| virtual void mimas::mesa_offscreen< T >::finish | ( | void | ) | [virtual] |
Finish output on the image.
This method
glFinish() HAVE_OSMESA is not defined. mesa_base::finish . Reimplemented from mimas::mesa_base.
| virtual void mimas::mesa_offscreen< T >::ortho2D | ( | int | x1, | |
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) | const [virtual] |
| virtual void mimas::mesa_offscreen< T >::ortho2D | ( | void | ) | const [virtual] |
| GLenum mimas::mesa_offscreen< T >::getFormat | ( | void | ) | const throw (mimasexception) [protected] |
| void mimas::mesa_offscreen< T >::setupColorScale | ( | void | ) | const [protected] |
Pixmap mimas::mesa_offscreen< T >::pixmap [protected] |
GLXPixmap mimas::mesa_offscreen< T >::glxPixmap [protected] |
GLXContext mimas::mesa_offscreen< T >::context [protected] |
void* mimas::mesa_offscreen< T >::data [protected] |
int mimas::mesa_offscreen< T >::width [protected] |
int mimas::mesa_offscreen< T >::height [protected] |
bool mimas::mesa_offscreen< T >::finishOffscreen [protected] |
Definition at line 108 of file mesa_offscreen.h.