Overview | Modules | Class Hierarchy | Classes | Members

Public Member Functions | Static Public Member Functions
tlp::GlOffscreenRenderer Class Reference

Render a scene in an image or in a texture. More...

`#include <GlOffscreenRenderer.h>`

Collaboration diagram for tlp::GlOffscreenRenderer:
[legend]

List of all members.

## Public Member Functions

- ~GlOffscreenRenderer ()
- void setViewPortSize (const unsigned int viewPortWidth, const unsigned int viewPortHeight)
    Define the viewport size.
- unsigned int getViewportWidth ()
- unsigned int getViewportHeight ()
- bool frameBufferOk () const
- GlScene * getScene ()
- void setZoomFactor (double zoomFactor)
- void setCameraCenter (const Coord &cameraCenter)
- void setSceneBackgroundColor (const Color &color)
- void addGlEntityToScene (GlSimpleEntity *entity)
    Add an entity to the scene. The scene become the owner of the object.
- void addGraphCompositeToScene (GlGraphComposite *graphComposite)
    Add a graph composite to the scene. The scene become the owner of the object.
- void addGraphToScene (Graph *graph)
    Add a graph to the scene. Just create a new GraphComposite and call GlGraphComposite.
- void clearScene ()
    Delete all the elements of the scene and clear it.
- void renderScene (const bool centerScene=true, const bool antialiased=false)
    Render the scene in a buffer. You need to call this function before getting the result with getImage or getGlTexture.
- QImage getImage ()
    Generate a QImage from the scene. You need to call the renderScene function before this function.
- GLuint getGLTexture (const bool generateMipMaps=false)
    Generate an open gl texture from the scene. You need to call the renderScene function before this function.

## Static Public Member Functions

- static GlOffscreenRenderer * getInstance ()
    Get the renderer instance.

## Detailed Description

Render a scene in an image or in a texture.

Here is an example to render a graph in a QImage to use it as preview.

     //Get the renderer
     glOffscreenRenderer *glOffscreenRenderer = GlOffscreenRenderer::getInstance();
     //Define the viewport size. Needed to initialize the offscreen rederer.
     glOffscreenRenderer->setViewPortSize(200,200);
     //Erase old elements
     glOffscreenRenderer->clearScene();
     //Change the background color of the scene to white
     glOffscreenRenderer->setSceneBackgroundColor(Color(255,255,255,255));
     //Add the graph to render.
     glOffscreenRenderer->addGraphToScene(graph);
     //Center and render the scene.
     glOffscreenRenderer->renderScene(true);
     //Get the result
     QImage preview = glOffscreenRenderer->getImage();

## Constructor & Destructor Documentation

tlp::GlOffscreenRenderer::~GlOffscreenRenderer | ( |  | ) |

## Member Function Documentation

void tlp::GlOffscreenRenderer::addGlEntityToScene | ( | GlSimpleEntity * | entity | ) |

Add an entity to the scene. The scene become the owner of the object.

void tlp::GlOffscreenRenderer::addGraphCompositeToScene | ( | GlGraphComposite * | graphComposite | ) |

Add a graph composite to the scene. The scene become the owner of the object.

void tlp::GlOffscreenRenderer::addGraphToScene | ( | Graph * | graph | ) |

Add a graph to the scene. Just create a new GraphComposite and call GlGraphComposite.

void tlp::GlOffscreenRenderer::clearScene | ( |  | ) |

Delete all the elements of the scene and clear it.

bool tlp::GlOffscreenRenderer::frameBufferOk | ( |  | ) | const`[inline]`

GLuint tlp::GlOffscreenRenderer::getGLTexture | ( | const bool | generateMipMaps = `false` | ) |

Generate an open gl texture from the scene. You need to call the renderScene function before this function.

QImage tlp::GlOffscreenRenderer::getImage | ( |  | ) |

Generate a QImage from the scene. You need to call the renderScene function before this function.

static GlOffscreenRenderer* tlp::GlOffscreenRenderer::getInstance | ( |  | ) | `[static]`

Get the renderer instance.

GlScene* tlp::GlOffscreenRenderer::getScene | ( |  | ) | `[inline]`

unsigned int tlp::GlOffscreenRenderer::getViewportHeight | ( |  | ) |

unsigned int tlp::GlOffscreenRenderer::getViewportWidth | ( |  | ) |

void tlp::GlOffscreenRenderer::renderScene | ( | const bool | centerScene = `true`,
|  | const bool | antialiased = `false`
| ) |  |

Render the scene in a buffer. You need to call this function before getting the result with getImage or getGlTexture.

void tlp::GlOffscreenRenderer::setCameraCenter | ( | const Coord & | cameraCenter | ) | `[inline]`

void tlp::GlOffscreenRenderer::setSceneBackgroundColor | ( | const Color & | color | ) |

void tlp::GlOffscreenRenderer::setViewPortSize | ( | const unsigned int | viewPortWidth,
|  | const unsigned int | viewPortHeight
| ) |  |

Define the viewport size.

void tlp::GlOffscreenRenderer::setZoomFactor | ( | double | zoomFactor | ) | `[inline]`

Tulip Software by LaBRI Visualization Team 2001 - 2012