MeVisLab Resolution Independence API
ml::OffscreenRenderer Class Reference

OpenInventor Scenes can be rendered to the OffscreenRender who outputs an MLImage. More...

#include <mlOffscreenRender.h>

Inheritance diagram for ml::OffscreenRenderer:

Public Types

enum  ImageType { IMG_RGB = 0 , IMG_RGBA , IMG_RGBA_FLOAT , NUM_IMAGE_TYPES }
 Macro for declaring methods for the runtime system, defined in mlRuntimeSubClass.h. More...
 
enum  TransparencyType {
  SCREEN_DOOR = SoGLRenderAction::SCREEN_DOOR , ADD = SoGLRenderAction::ADD , DELAYED_ADD = SoGLRenderAction::DELAYED_ADD , SORTED_OBJECT_ADD = SoGLRenderAction::SORTED_OBJECT_ADD ,
  BLEND = SoGLRenderAction::BLEND , DELAYED_BLEND = SoGLRenderAction::DELAYED_BLEND , SORTED_OBJECT_BLEND = SoGLRenderAction::SORTED_OBJECT_BLEND , NUM_TRANSPARENCY_TYPES
}
 
enum  BufferType { AUTO , PIXEL_BUFFER , NUM_BUFFER_TYPES }
 

Public Member Functions

 OffscreenRenderer (ImageType imgType=IMG_RGB, const Vector2 &size=Vector2(64., 64.), int numInputImages=0, int numOutputImages=1)
 Constructor.
 
 ~OffscreenRenderer () override
 Destructor:
 
void handleNotification (Field *) override
 Called when input changes.
 
void calculateOutputImageProperties (int outputIndex, PagedImage *outputImage) override
 Determine properties of output image.
 
void calculateOutputSubImage (SubImage *outSubImg, int outIndex, SubImage *inSubImgs) override
 Called when a page is calculated.
 
void activateAttachments () override
 Initialize buffer type.
 
void * takeMemoryImage ()
 Returns the current memory image and creates a new one. The ownership is passed to the caller.
 

Static Public Attributes

static const char * ImageTypeStrings [NUM_IMAGE_TYPES]
 Define strings for all image types. These can be used for enum fields.
 
static const char * TransparencyTypeStrings [NUM_TRANSPARENCY_TYPES]
 Define strings for all transparency types. These can be used for enum fields.
 
static const char * BufferTypeStrings [NUM_BUFFER_TYPES]
 Define strings for all image types. These can be used for enum fields.
 

Protected Member Functions

void _setMode ()
 Sets the mode of the pixel buffer according to _curImgType.
 
bool _createOffscreenBuffer ()
 
bool _createPBuffer (const SbVec2s &)
 Creates the pixel buffer.
 
bool _createFBO (const SbVec2s &)
 Creates the FBO.
 
void _resetOffscreenBuffer ()
 
bool _activateOffscreenBuffer ()
 
void _deactivateOffscreenBuffer ()
 
bool _renderToOutImage (bool &hasSceneAndUpdatedBuffer)
 Render the scene and write it to a main memory buffer. Returns true on success, false otherwise.
 
bool _render (bool &hasSceneAndUpdatedBuffer)
 Calls _renderToOutImage().
 
void _updateBufferType ()
 

Protected Attributes

BoolField * _supportedFld
 Field variables.
 
SoNodeField * _sceneGraphFld
 Root node of scene graph to be rendered offscreen.
 
EnumField * _imageTypeFld
 Specifies the image type of the output image.
 
EnumField * _transparencyTypeFld
 Specifies the image type of the output image.
 
EnumField * _bufferTypeFld
 Specifies the buffer type.
 
Vector2Field * _sizeFld
 Size of the output image.
 
FloatField * _pixelScaleFld
 Scale factor for pixel size.
 
ColorField * _bgColorFld
 Background color.
 
BoolField * _createStencilBufferFld
 Specifies whether to create a stencil buffer.
 
NotifyField * _updateFld
 Triggers update.
 
BoolField * _enableMultiSampling
 Enables multi sampling.
 
IntField * _multiSampling
 Sets number of samples.
 
bool _bufferUpToDate
 Member variables.
 
bool _useFBO
 
SoGLRenderAction * _glRenderAction
 The GL render action needed to traverse the scene attached to this module.
 
SoRef< SoOffscreenViewerProxyNode_root
 SoSeparator node to use as root of the scene, so that the render state is reset after each rendering.
 
SoOffscreenViewerProxy_offscreenProxy
 Proxy node that can be queried during traversal.
 
SoPBuffer * _pBuffer
 The pBuffer object.
 
int _mode
 The mode of the pBuffer.
 
ImageType _curImgType
 The image type of the pBuffer. This is not necessarily identical to the value of _imageTypeFld!
 
SoGLFramebufferObject * _fbo
 The frame buffer object, is used instead of the pBuffer if available.
 
SoGLTexture * _colorTextureBuffer
 Pointer to the color buffer.
 
SoGLRenderbuffer * _depthRenderBuffer
 Pointer to the depth buffer.
 
bool _frameBufferCompletionTested
 Flag that indicates that the current color/depth/stencil buffer configuration has been checked and works.
 
GLuint _depthComponent
 The depth component actually used. May differ from requested, cause gfx card does not support it.
 
GLenum _colorFormat
 
SoGLFramebufferObject * _msaaFbo
 
SoGLRenderbuffer * _msaaColorBuffer
 
unsigned char * _memImage
 Pointer to memory allocated to hold the content of the offscreen buffer.
 
unsigned int _memImgBytes
 Number of bytes of the _memImage.
 
bool _fboSupportsNonPowerOfTwoDimensions
 
bool _pBufferSupportsNonPowerOfTwoDimensions
 

Detailed Description

OpenInventor Scenes can be rendered to the OffscreenRender who outputs an MLImage.

Definition at line 42 of file mlOffscreenRender.h.

Member Enumeration Documentation

◆ BufferType

Enumerator
AUTO 
PIXEL_BUFFER 
NUM_BUFFER_TYPES 

Definition at line 69 of file mlOffscreenRender.h.

◆ ImageType

Macro for declaring methods for the runtime system, defined in mlRuntimeSubClass.h.

Image types

Enumerator
IMG_RGB 
IMG_RGBA 
IMG_RGBA_FLOAT 
NUM_IMAGE_TYPES 

Definition at line 50 of file mlOffscreenRender.h.

◆ TransparencyType

Enumerator
SCREEN_DOOR 
ADD 
DELAYED_ADD 
SORTED_OBJECT_ADD 
BLEND 
DELAYED_BLEND 
SORTED_OBJECT_BLEND 
NUM_TRANSPARENCY_TYPES 

Definition at line 58 of file mlOffscreenRender.h.

Constructor & Destructor Documentation

◆ OffscreenRenderer()

ml::OffscreenRenderer::OffscreenRenderer ( ImageType imgType = IMG_RGB,
const Vector2 & size = Vector2(64., 64.),
int numInputImages = 0,
int numOutputImages = 1 )

Constructor.

◆ ~OffscreenRenderer()

ml::OffscreenRenderer::~OffscreenRenderer ( )
override

Destructor:

Member Function Documentation

◆ _activateOffscreenBuffer()

bool ml::OffscreenRenderer::_activateOffscreenBuffer ( )
protected

◆ _createFBO()

bool ml::OffscreenRenderer::_createFBO ( const SbVec2s & )
protected

Creates the FBO.

◆ _createOffscreenBuffer()

bool ml::OffscreenRenderer::_createOffscreenBuffer ( )
protected

◆ _createPBuffer()

bool ml::OffscreenRenderer::_createPBuffer ( const SbVec2s & )
protected

Creates the pixel buffer.

◆ _deactivateOffscreenBuffer()

void ml::OffscreenRenderer::_deactivateOffscreenBuffer ( )
protected

◆ _render()

bool ml::OffscreenRenderer::_render ( bool & hasSceneAndUpdatedBuffer)
protected

Calls _renderToOutImage().

If _renderToOutImage() fails, the buffer settings are changed (power of two buffer size, pbuffer instead of fbo) and _renderToOutImage() is tried again.

◆ _renderToOutImage()

bool ml::OffscreenRenderer::_renderToOutImage ( bool & hasSceneAndUpdatedBuffer)
protected

Render the scene and write it to a main memory buffer. Returns true on success, false otherwise.

◆ _resetOffscreenBuffer()

void ml::OffscreenRenderer::_resetOffscreenBuffer ( )
protected

◆ _setMode()

void ml::OffscreenRenderer::_setMode ( )
protected

Sets the mode of the pixel buffer according to _curImgType.

◆ _updateBufferType()

void ml::OffscreenRenderer::_updateBufferType ( )
protected

◆ activateAttachments()

void ml::OffscreenRenderer::activateAttachments ( )
override

Initialize buffer type.

◆ calculateOutputImageProperties()

void ml::OffscreenRenderer::calculateOutputImageProperties ( int outputIndex,
PagedImage * outputImage )
override

Determine properties of output image.

◆ calculateOutputSubImage()

void ml::OffscreenRenderer::calculateOutputSubImage ( SubImage * outSubImg,
int outIndex,
SubImage * inSubImgs )
override

Called when a page is calculated.

◆ handleNotification()

void ml::OffscreenRenderer::handleNotification ( Field * )
override

Called when input changes.

◆ takeMemoryImage()

void * ml::OffscreenRenderer::takeMemoryImage ( )

Returns the current memory image and creates a new one. The ownership is passed to the caller.

Member Data Documentation

◆ _bgColorFld

ColorField* ml::OffscreenRenderer::_bgColorFld
protected

Background color.

Definition at line 126 of file mlOffscreenRender.h.

◆ _bufferTypeFld

EnumField* ml::OffscreenRenderer::_bufferTypeFld
protected

Specifies the buffer type.

Definition at line 118 of file mlOffscreenRender.h.

◆ _bufferUpToDate

bool ml::OffscreenRenderer::_bufferUpToDate
protected

Member variables.

Definition at line 140 of file mlOffscreenRender.h.

◆ _colorFormat

GLenum ml::OffscreenRenderer::_colorFormat
protected

Definition at line 170 of file mlOffscreenRender.h.

◆ _colorTextureBuffer

SoGLTexture* ml::OffscreenRenderer::_colorTextureBuffer
protected

Pointer to the color buffer.

Definition at line 163 of file mlOffscreenRender.h.

◆ _createStencilBufferFld

BoolField* ml::OffscreenRenderer::_createStencilBufferFld
protected

Specifies whether to create a stencil buffer.

Definition at line 128 of file mlOffscreenRender.h.

◆ _curImgType

ImageType ml::OffscreenRenderer::_curImgType
protected

The image type of the pBuffer. This is not necessarily identical to the value of _imageTypeFld!

Definition at line 158 of file mlOffscreenRender.h.

◆ _depthComponent

GLuint ml::OffscreenRenderer::_depthComponent
protected

The depth component actually used. May differ from requested, cause gfx card does not support it.

Definition at line 169 of file mlOffscreenRender.h.

◆ _depthRenderBuffer

SoGLRenderbuffer* ml::OffscreenRenderer::_depthRenderBuffer
protected

Pointer to the depth buffer.

Definition at line 165 of file mlOffscreenRender.h.

◆ _enableMultiSampling

BoolField* ml::OffscreenRenderer::_enableMultiSampling
protected

Enables multi sampling.

Definition at line 132 of file mlOffscreenRender.h.

◆ _fbo

SoGLFramebufferObject* ml::OffscreenRenderer::_fbo
protected

The frame buffer object, is used instead of the pBuffer if available.

Definition at line 161 of file mlOffscreenRender.h.

◆ _fboSupportsNonPowerOfTwoDimensions

bool ml::OffscreenRenderer::_fboSupportsNonPowerOfTwoDimensions
protected

Definition at line 180 of file mlOffscreenRender.h.

◆ _frameBufferCompletionTested

bool ml::OffscreenRenderer::_frameBufferCompletionTested
protected

Flag that indicates that the current color/depth/stencil buffer configuration has been checked and works.

Definition at line 167 of file mlOffscreenRender.h.

◆ _glRenderAction

SoGLRenderAction* ml::OffscreenRenderer::_glRenderAction
protected

The GL render action needed to traverse the scene attached to this module.

Definition at line 144 of file mlOffscreenRender.h.

◆ _imageTypeFld

EnumField* ml::OffscreenRenderer::_imageTypeFld
protected

Specifies the image type of the output image.

Definition at line 114 of file mlOffscreenRender.h.

◆ _memImage

unsigned char* ml::OffscreenRenderer::_memImage
protected

Pointer to memory allocated to hold the content of the offscreen buffer.

Definition at line 176 of file mlOffscreenRender.h.

◆ _memImgBytes

unsigned int ml::OffscreenRenderer::_memImgBytes
protected

Number of bytes of the _memImage.

Definition at line 178 of file mlOffscreenRender.h.

◆ _mode

int ml::OffscreenRenderer::_mode
protected

The mode of the pBuffer.

Definition at line 156 of file mlOffscreenRender.h.

◆ _msaaColorBuffer

SoGLRenderbuffer* ml::OffscreenRenderer::_msaaColorBuffer
protected

Definition at line 173 of file mlOffscreenRender.h.

◆ _msaaFbo

SoGLFramebufferObject* ml::OffscreenRenderer::_msaaFbo
protected

Definition at line 172 of file mlOffscreenRender.h.

◆ _multiSampling

IntField* ml::OffscreenRenderer::_multiSampling
protected

Sets number of samples.

Definition at line 134 of file mlOffscreenRender.h.

◆ _offscreenProxy

SoOffscreenViewerProxy* ml::OffscreenRenderer::_offscreenProxy
protected

Proxy node that can be queried during traversal.

Definition at line 151 of file mlOffscreenRender.h.

◆ _pBuffer

SoPBuffer* ml::OffscreenRenderer::_pBuffer
protected

The pBuffer object.

Definition at line 154 of file mlOffscreenRender.h.

◆ _pBufferSupportsNonPowerOfTwoDimensions

bool ml::OffscreenRenderer::_pBufferSupportsNonPowerOfTwoDimensions
protected

Definition at line 181 of file mlOffscreenRender.h.

◆ _root

SoRef<SoOffscreenViewerProxyNode> ml::OffscreenRenderer::_root
protected

SoSeparator node to use as root of the scene, so that the render state is reset after each rendering.

Definition at line 148 of file mlOffscreenRender.h.

◆ _sceneGraphFld

SoNodeField* ml::OffscreenRenderer::_sceneGraphFld
protected

Root node of scene graph to be rendered offscreen.

Definition at line 112 of file mlOffscreenRender.h.

◆ _sizeFld

Vector2Field* ml::OffscreenRenderer::_sizeFld
protected

Size of the output image.

Definition at line 121 of file mlOffscreenRender.h.

◆ _supportedFld

BoolField* ml::OffscreenRenderer::_supportedFld
protected

Field variables.

A boolean that tells if the offscreen renderer is supported on the current system

Definition at line 110 of file mlOffscreenRender.h.

◆ _transparencyTypeFld

EnumField* ml::OffscreenRenderer::_transparencyTypeFld
protected

Specifies the image type of the output image.

Definition at line 116 of file mlOffscreenRender.h.

◆ _updateFld

NotifyField* ml::OffscreenRenderer::_updateFld
protected

Triggers update.

Definition at line 130 of file mlOffscreenRender.h.

◆ _useFBO

bool ml::OffscreenRenderer::_useFBO
protected

Definition at line 141 of file mlOffscreenRender.h.

◆ BufferTypeStrings

const char* ml::OffscreenRenderer::BufferTypeStrings[NUM_BUFFER_TYPES]
static

Define strings for all image types. These can be used for enum fields.

Definition at line 82 of file mlOffscreenRender.h.

◆ ImageTypeStrings

const char* ml::OffscreenRenderer::ImageTypeStrings[NUM_IMAGE_TYPES]
static

Define strings for all image types. These can be used for enum fields.

Definition at line 76 of file mlOffscreenRender.h.

◆ TransparencyTypeStrings

const char* ml::OffscreenRenderer::TransparencyTypeStrings[NUM_TRANSPARENCY_TYPES]
static

Define strings for all transparency types. These can be used for enum fields.

Definition at line 79 of file mlOffscreenRender.h.


The documentation for this class was generated from the following file: