lobot::RenderBuffer Class Reference

An encapsulation of an OpenGL framebuffer object. More...

#include <Robots/LoBot/ui/LoRenderBuffer.H>

List of all members.

Public Member Functions

 RenderBuffer (int width, int height)
void setup ()
const unsigned char * pixels () const
int size () const
void to_screen ()
 Copy contents of off-screen buffer to on-screen buffer.
 ~RenderBuffer ()
 Clean-up.

int width () const
int height () const

Detailed Description

An encapsulation of an OpenGL framebuffer object.

This class implements an off-screen rendering buffer using OpenGL's FBO API. Instead of rendering directly to the OpenGL (on-screen) back buffer, the Robolocust main window first renders to this off-screen buffer and then copies the contents of the off-screen render buffer to the on-screen back buffer.

If available, this class will use the OpenGL blitting API to copy the off-screen buffer to the on-screen buffer so that this operation takes place within the GL driver via DMA. However, if blitting is not supported, then it will fall back to reading the pixels from the off-screen buffer into main memory and then drawing them to the back buffer.

Furthermore, this class takes care of the details of dealing with the OpenGL FBO API regardless of whether it is part of the GL core is available as an extension.

This somewhat indirect and convoluted architecture allows us to easily implement screen captures.

Definition at line 81 of file LoRenderBuffer.H.


Constructor & Destructor Documentation

lobot::RenderBuffer::RenderBuffer ( int  width,
int  height 
)

Initialization: when clients create an off-screen render buffer, they should specify its dimensions. Usually, these dimensions would equal those of the UI window.

Definition at line 413 of file LoRenderBuffer.C.

lobot::RenderBuffer::~RenderBuffer (  ) 

Clean-up.

Definition at line 457 of file LoRenderBuffer.C.


Member Function Documentation

const unsigned char * lobot::RenderBuffer::pixels (  )  const

Retrieve the off-screen buffer's pixels: clients can use this method after rendering is done to get the results of the rendering process that ended up in the off-screen buffer.

This function returns a pointer to the internal pixel data buffer. Clients should not store this pointer for later use, delete it, or write to the buffer it points to. Instead, they should only copy the contents of the data buffer returned by this function.

The size of the buffer will be W*H*4, where W and H are the width and height respectively of the off-screen buffer. These two parameters would have been specified by the client during instantiation of the lobot::RenderBuffer object.

The off-screen buffer's pixels are stored in the GL_BGRA format. The pixel data type is GL_UNSIGNED_BYTE.

NOTE: If the OpenGL driver is missing support for framebuffer objects, the pixel data returned by this function could be corrupt, i.e., contain random garbage. This would usually occur when the Robolocust window is wholly or partially obscured by another window.

Definition at line 432 of file LoRenderBuffer.C.

Referenced by lobot::MainWindow::save_screenshot().

void lobot::RenderBuffer::setup (  ) 

Setup off-screen rendering: before performing regular rendering, clients should call this method so that rendering can be redirected to the off-screen buffer.

Definition at line 423 of file LoRenderBuffer.C.

int lobot::RenderBuffer::size (  )  const [inline]

Helper function to return the size (in bytes) of the off-screen buffer's pixel data array.

Definition at line 142 of file LoRenderBuffer.H.

Referenced by lobot::MainWindow::save_screenshot().

void lobot::RenderBuffer::to_screen (  ) 

Copy contents of off-screen buffer to on-screen buffer.

Definition at line 452 of file LoRenderBuffer.C.

int lobot::RenderBuffer::width (  )  const [inline]

Helper functions to return the dimensions of the off-screen buffer.

NOTE: In general, a client should not really need to use these functions because they ought to already know this information and would have passed the width and height to the lobot::RenderBuffer constructor.

Definition at line 152 of file LoRenderBuffer.H.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:44:38 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3