mimas::mesa_offscreen< T > Class Template Reference

Mesa off-screen rendering. More...

#include <mesa_offscreen.h>

Inheritance diagram for mimas::mesa_offscreen< T >:

Inheritance graph
[legend]
Collaboration diagram for mimas::mesa_offscreen< T >:

Collaboration graph
[legend]
List of all members.

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

Detailed Description

template<typename T>
class mimas::mesa_offscreen< T >

Mesa off-screen rendering.

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
    
This disables hardware rendering.

If it works:

If it doesn't:

References:

Definition at line 58 of file mesa_offscreen.h.


Constructor & Destructor Documentation

template<typename T>
mimas::mesa_offscreen< T >::mesa_offscreen ( x11_display _display,
image< T > &  image,
bool  depthBuffer = false 
)

Constructor.

Parameters:
_display X11 display
image Image to draw on.
depthBuffer Boolean indicating, wether to use a depth-buffer.

template<typename T>
virtual mimas::mesa_offscreen< T >::~mesa_offscreen ( void   )  [virtual]

Destructor.

The destructor just calls the method finish() .

See also:
finish


Member Function Documentation

template<typename T>
virtual void mimas::mesa_offscreen< T >::finish ( void   )  [virtual]

Finish output on the image.

This method

Reimplemented from mimas::mesa_base.

template<typename T>
virtual void mimas::mesa_offscreen< T >::ortho2D ( int  x1,
int  y1,
int  x2,
int  y2 
) const [virtual]

Switch to two-dimensional drawing mode.

See also:
mesa_base::ortho2D

Implements mimas::mesa_base.

template<typename T>
virtual void mimas::mesa_offscreen< T >::ortho2D ( void   )  const [virtual]

Switch to two-dimensional drawing mode.

See also:
mesa_base::ortho2D

Implements mimas::mesa_base.

template<typename T>
GLenum mimas::mesa_offscreen< T >::getFormat ( void   )  const throw (mimasexception) [protected]

template<typename T>
void mimas::mesa_offscreen< T >::setupColorScale ( void   )  const [protected]


Member Data Documentation

template<typename T>
Pixmap mimas::mesa_offscreen< T >::pixmap [protected]

X11 pixmap.

Definition at line 92 of file mesa_offscreen.h.

template<typename T>
GLXPixmap mimas::mesa_offscreen< T >::glxPixmap [protected]

Corresponding GLX pixmap.

Definition at line 94 of file mesa_offscreen.h.

template<typename T>
GLXContext mimas::mesa_offscreen< T >::context [protected]

GLX context for off-screen rendering.

Definition at line 96 of file mesa_offscreen.h.

template<typename T>
void* mimas::mesa_offscreen< T >::data [protected]

Pointer to image-data to write back later.

Definition at line 98 of file mesa_offscreen.h.

template<typename T>
int mimas::mesa_offscreen< T >::width [protected]

Width of image.

Definition at line 104 of file mesa_offscreen.h.

template<typename T>
int mimas::mesa_offscreen< T >::height [protected]

Height of image.

Definition at line 106 of file mesa_offscreen.h.

template<typename T>
bool mimas::mesa_offscreen< T >::finishOffscreen [protected]

Definition at line 108 of file mesa_offscreen.h.


The documentation for this class was generated from the following file:
[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:35 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...