30 #ifndef __FRAMEBUFFERTEXTUREGENERATOR_H__
31 #define __FRAMEBUFFERTEXTUREGENERATOR_H__
223 class H3DAPI_API UpdateMode :
public AutoUpdate < OnNewValueSField < SFString > > {
224 virtual void onNewValue(
const std::string& new_value );
229 Inst< RemoveChildren > _removeChildren = 0,
230 Inst< MFChild > _children = 0,
231 Inst< SFNode > _metadata = 0,
232 Inst< SFBound > _bound = 0,
233 Inst< SFVec3f > _bboxCenter = 0,
234 Inst< SFVec3f > _bboxSize = 0,
235 Inst< MFString > _generateColorTextures = 0,
236 Inst< SFBool > _generateDepthTexture = 0,
237 Inst< MFTexturePropertiesNode > _colorTextureProperties = 0,
238 Inst< SFTexturePropertiesNode > _depthTextureProperties = 0,
239 Inst< MFGeneratedTextureNode > _colorTextures = 0,
240 Inst< SFGeneratedTextureNode > _colorTexture = 0,
241 Inst< SFGeneratedTextureNode > _depthTexture = 0,
242 Inst< SFString > _depthBufferType = 0,
243 Inst< SFString > _outputTextureType = 0,
244 Inst< SFInt32 > _samples = 0,
245 Inst< UpdateMode > _update = 0,
246 Inst< SFInt32 > _framesBeforeStop = 0,
247 Inst< SFViewpointNode > _viewpoint = 0,
248 Inst< SFNavigationInfo > _navigationInfo = 0,
249 Inst< SFBackgroundNode > _background = 0,
250 Inst< SFInt32 > _width = 0,
251 Inst< SFInt32 > _height = 0,
252 Inst< SFInt32 > _widthInUse = 0,
253 Inst< SFInt32 > _heightInUse = 0,
254 Inst< SFBool > _useStereo = 0,
255 Inst< SFString > _depthBufferStorage = 0,
256 Inst< SFFrameBufferTextureGeneratorNode > _externalFBODepthBuffer = 0,
257 Inst< MFString > _colorBufferStorages = 0,
258 Inst< MFFrameBufferTextureGeneratorNode > _externalFBOColorBuffers = 0,
259 Inst< SFBool > _useNavigation = 0,
260 Inst< SFInt32 > _projectionWidth = 0,
261 Inst< SFInt32 > _projectionHeight = 0,
262 Inst< SFBool > _useSpecifiedClearColor = 0,
263 Inst< SFColorRGBA > _clearColor = 0,
264 Inst< SFBool > _useDSA = 0,
265 Inst< SFBool > _splitScene = 0,
266 Inst< SFBool > _useScissor = 0,
267 Inst< SFInt32 > _scissorBoxX = 0,
268 Inst< SFInt32 > _scissorBoxY = 0,
269 Inst< SFInt32 > _scissorBoxWidth = 0,
270 Inst< SFInt32 > _scissorBoxHeight = 0,
271 Inst< MFColorRGBA > _clearColors = 0,
272 Inst< SFInt32 > _nrLayers = 0,
273 Inst< SFBool > _generateStencilMask = 0,
274 Inst< SFBool > _applyStencilMask = 0,
275 Inst< SFBool > _useInverseMasking = 0);
281 virtual void render();
287 virtual void initialize();
290 bool haveStencilBuffer();
304 void setRenderCallback( RenderCallbackFunc func,
void *args = NULL );
687 if( !fbo_initialized ) initializeFBO();
692 return fbo_initialized;
709 return depthTexture->getValue();
721 return colorTextures->getValue();
728 always_use_existing_viewport = use;
734 return always_use_existing_viewport;
739 static std::set< FrameBufferTextureGenerator * >
fbo_nodes;
744 GLenum stringToInternalFormat(
const string &format_string );
747 GLenum stringToInternalDepthFormat(
const string &s );
750 GLenum stringToDepthFormat(
const string &s );
753 GLenum stringToDepthType(
const string &s );
757 bool checkFBOCompleteness();
760 void initializeFBO();
763 void createOutputTextures ();
766 void setupScissor(
bool needSinglePassStereo,
float* viewports_size,
int desired_fbo_width,
int desired_fbo_height );
775 void preProcessFBO(
int srcX,
int srcY,
int w,
int h,
int depth);
784 void blitDepthBuffer(GLenum src, GLenum dst,
int srcX,
int srcY,
int w,
int h);
795 void blitColorBuffer(GLenum src, GLenum dst,
796 int srcX,
int srcY,
int w,
int h,
int src_index,
int dst_index);
805 void blitFBOBuffers(GLenum src, GLenum dst,
806 int srcX,
int srcY,
int w,
int h );
825 bool parseColorBufferStorage( std::string color_buffer_storage, std::string& style,
int& index );
828 void _check_gl_error(
const char *file,
int line);
839 void clearColorBuffer(GLenum src,
int x,
int y,
int _width,
int _height,
840 GLfloat* value, GLint index );
850 void clearBuffers(GLenum src,
int x,
int y,
int _width,
int _height, GLbitfield mask);
856 virtual void update();
867 virtual void update();
955 for( vector<bool>::iterator it = value.begin(); it!= value.end(); ++it) {
976 bool use_depth_stencil;
978 vector<GLfloat> clear_color_value;
Contains different templates to modify field behaviour.
Contains the Field class.
Header file for GeneratedTexture.
Contains the MFColorRGBA field class.
Contains the MFString field class.
Header file for NavigationInfo, X3D scene-graph node.
Contains the SFColorRGBA field class.
Header file for ShadowCaster.
Contains the TypedField template class.
Header file for X3DBackgroundNode, X3D scene-graph node.
Header file for X3DGroupingNode, X3D scene-graph node.
Header file for X3DViewpointNode, X3D scene-graph node.
Specialized field class used to get the number of samples that can and will be used.
Definition: FrameBufferTextureGenerator.h:865
Specialized field class used to check if multi sample support is needed.
Definition: FrameBufferTextureGenerator.h:854
A field used to reset the waning printed flag.
Definition: FrameBufferTextureGenerator.h:944
virtual void update()
Make the field up to date given that an event has occured.
Definition: FrameBufferTextureGenerator.h:946
A field to reset multiple warning printed flags.
Definition: FrameBufferTextureGenerator.h:952
virtual void update()
Make the field up to date given that an event has occured.
Definition: FrameBufferTextureGenerator.h:954
The FrameBufferTextureGenerator node provides a mean to render a sub-scene into a texture instead of ...
Definition: FrameBufferTextureGenerator.h:209
bool last_resize_success
True if the last call to resizeBuffers from render() was true.
Definition: FrameBufferTextureGenerator.h:920
H3DSingleTextureNode * getDepthTexture()
Return the depth texture of current FrameBufferTextureGenerator.
Definition: FrameBufferTextureGenerator.h:708
static std::set< FrameBufferTextureGenerator * > fbo_nodes
The FrameBufferTextureGenerator that are currently in use in the application.
Definition: FrameBufferTextureGenerator.h:739
bool always_use_existing_viewport
If set to true the currently set up viewport when the render() function is called will be used for th...
Definition: FrameBufferTextureGenerator.h:931
H3DInt32 buffers_depth
The current depth(in pixels) of output textures and buffers.
Definition: FrameBufferTextureGenerator.h:903
H3DUniquePtr< SFBool > splitScene
An option to tell FBTG to split the children scene and render each shape into separate render target.
Definition: FrameBufferTextureGenerator.h:642
H3DUniquePtr< MFFrameBufferTextureGeneratorNode > externalFBOColorBuffers
Specifies the external FrameBufferTextureGenerator to be used for FBO_COPY_x and FBO_SHARE_x option o...
Definition: FrameBufferTextureGenerator.h:343
H3DUniquePtr< SFInt32 > scissorBoxWidth
scissor box width, will be used when useScissor is true When this value is negative,...
Definition: FrameBufferTextureGenerator.h:546
H3DUniquePtr< SFInt32 > framesBeforeStop
The frameBeforeStop is check when SPECIFIED_FRAME_ONLY is set and to provide the info about how many ...
Definition: FrameBufferTextureGenerator.h:476
H3DUniquePtr< SFBool > useInverseMasking
An option to change the regular stencil masking behavior.
Definition: FrameBufferTextureGenerator.h:665
RenderCallbackFunc render_func
The render callback function, if any.
Definition: FrameBufferTextureGenerator.h:923
GLuint multi_samples_fbo_id
The OpenGL fbo used for multi sample rendering.
Definition: FrameBufferTextureGenerator.h:892
H3DUniquePtr< SFGeneratedTextureNode > depthTexture
The texture node generated from depth buffers if specified in generateDepthTexture.
Definition: FrameBufferTextureGenerator.h:402
H3DUniquePtr< ResetPrintedFlags > colorInitWarningPrinted
Field used to control the warning printing of storage init C++ only field.
Definition: FrameBufferTextureGenerator.h:972
H3DUniquePtr< UpdateMode > update
The update field allows the user to request a regeneration of the texture.
Definition: FrameBufferTextureGenerator.h:468
H3DUniquePtr< SFViewpointNode > viewpoint
The X3DViewpointNode to use when rendering the scene.
Definition: FrameBufferTextureGenerator.h:483
H3DUniquePtr< SFInt32 > projectionHeight
Specify the height used to determine the local viewpoint's projection matrix if not specified the win...
Definition: FrameBufferTextureGenerator.h:580
H3DUniquePtr< MFString > colorBufferStorages
Defines what should be used as the color buffers for current FBO before rendering the sub-scene child...
Definition: FrameBufferTextureGenerator.h:337
H3DUniquePtr< MFColorRGBA > clearColors
Specified clearColors when there are more than one color output, use clearColors instead of clearColo...
Definition: FrameBufferTextureGenerator.h:622
H3DUniquePtr< SFInt32 > samples
The samples field determines how many samples to use for each pixel value in the textures.
Definition: FrameBufferTextureGenerator.h:444
AutoRef< ShadowCaster > shadow_caster
Reference to shadow caster used to cast shadows for shapes in scene graph in this FrameBufferTextureG...
Definition: FrameBufferTextureGenerator.h:935
H3DUniquePtr< SFString > depthBufferType
The depthBufferType field determines the precision and type of the depth buffer.
Definition: FrameBufferTextureGenerator.h:418
H3DInt32 buffers_height
The current width(in pixels) of output textures and buffers.
Definition: FrameBufferTextureGenerator.h:898
H3DUniquePtr< SFInt32 > nrLayers
The number of layers to a 3D texture or texture array output.
Definition: FrameBufferTextureGenerator.h:677
H3DUniquePtr< SFInt32 > widthInUse
It contains the actual width value used at realtime.
Definition: FrameBufferTextureGenerator.h:561
bool alwaysUseExistingViewpoint()
Returns the current value of alwaysUseExistingViewpoint.
Definition: FrameBufferTextureGenerator.h:733
H3DUniquePtr< SFBool > useStereo
An option to enable the use of same stereo setting as current window by default,it will be set to fal...
Definition: FrameBufferTextureGenerator.h:588
void ensureInitialized()
The ensureInitialized function makes sure that the output textures of the FrameBufferTextureGenerator...
Definition: FrameBufferTextureGenerator.h:686
bool isFBOInitialized()
Returns true if the fbo used by the node has been initialized,.
Definition: FrameBufferTextureGenerator.h:691
GLuint fbo_id
The id of the frame buffer object used to generate textures.
Definition: FrameBufferTextureGenerator.h:906
H3DUniquePtr< SFColorRGBA > clearColor
Specified clearColor used when useSpecifiedClearColor is true.
Definition: FrameBufferTextureGenerator.h:614
AutoRef< X3DGroupingNode > child_to_render
A group node container to gather all child node in MFChild field, used to gathering bound information...
Definition: FrameBufferTextureGenerator.h:939
H3DUniquePtr< ResetPrintedFlag > colorMismatchWarningPrinted
Field used to control the warning printing of size mismatch C++ only field.
Definition: FrameBufferTextureGenerator.h:968
H3DUniquePtr< SFNavigationInfo > navigationInfo
The NavigationInfo to be used when rendering the scene.
Definition: FrameBufferTextureGenerator.h:493
H3DUniquePtr< SFInt32 > height
The height of the output textures in pixels.
Definition: FrameBufferTextureGenerator.h:514
GLuint depth_id
The id of the depth buffer used with the fbo.
Definition: FrameBufferTextureGenerator.h:910
H3DUniquePtr< SFInt32 > scissorBoxHeight
scissor box height, will be used when useScissor is true When this value is negative,...
Definition: FrameBufferTextureGenerator.h:556
H3DUniquePtr< SFInt32 > width
The width of the output textures in pixels.
Definition: FrameBufferTextureGenerator.h:507
H3DUniquePtr< SFBool > useSpecifiedClearColor
An option to bypass the background no matter it is local or current active.
Definition: FrameBufferTextureGenerator.h:608
H3DUniquePtr< MFString > generateColorTextures
Defines the color buffer textures to generate and their type.
Definition: FrameBufferTextureGenerator.h:366
std::vector< GLenum > draw_buffers
Array containing [GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT .
Definition: FrameBufferTextureGenerator.h:917
GLuint getDepthId()
Returns the OpenGL depth id attached to fbo_id only valid if isFBOInitialized is true/.
Definition: FrameBufferTextureGenerator.h:703
H3DUniquePtr< ResetPrintedFlag > depthWarningPrinted
Field that control the depth warning output C++ field only.
Definition: FrameBufferTextureGenerator.h:964
vector< GLuint > color_ids
The OpenGL texture ids for all textures generated in the colorTextures field.
Definition: FrameBufferTextureGenerator.h:881
H3DUniquePtr< SFBool > useNavigation
An option to enable the use of user navigation which is used by the current window.
Definition: FrameBufferTextureGenerator.h:597
H3DUniquePtr< SFTexturePropertiesNode > depthTextureProperties
The TextureProperties to apply to the generated depth texture.
Definition: FrameBufferTextureGenerator.h:387
H3DUniquePtr< SFBool > useScissor
True to use scissor box to limit the rendering.
Definition: FrameBufferTextureGenerator.h:520
H3DUniquePtr< SFBool > generateDepthTexture
Determines if a depth texture should be generated or not.
Definition: FrameBufferTextureGenerator.h:373
vector< GLuint > getColorIds()
Returns the OpenGL color ids attached to fbo_id only valid if isFBOInitialized is true/.
Definition: FrameBufferTextureGenerator.h:714
H3DUniquePtr< GetNrSamples > getNrSamples
Specialized field used to get number of samples.
Definition: FrameBufferTextureGenerator.h:872
NodeVector getColorTextures()
Returns the colorTextures of current FrameBufferTextureGenerator only valid if isFBOInitialized is tr...
Definition: FrameBufferTextureGenerator.h:720
H3DUniquePtr< SFBool > generateStencilMask
An option to generate a stencil mask from this FBTG node, it will create a stencil mask of stencil va...
Definition: FrameBufferTextureGenerator.h:651
H3DUniquePtr< SFFrameBufferTextureGeneratorNode > externalFBODepthBuffer
Specifies the external FrameBufferTextureGenerator to be used for FBO_COPY and FBO_SHARE option of De...
Definition: FrameBufferTextureGenerator.h:323
vector< GLuint > multi_samples_color_ids
The OpenGL multi samples render buffer for color buffers when using multi sample rendering.
Definition: FrameBufferTextureGenerator.h:889
void * render_func_data
The specified callback function user data, if any.
Definition: FrameBufferTextureGenerator.h:926
H3DInt32 buffers_width
The current width(in pixels) of output textures and buffers.
Definition: FrameBufferTextureGenerator.h:895
int last_samples
previous sample value
Definition: FrameBufferTextureGenerator.h:878
GLuint getFBOId()
Returns the OpenGL fbo id used by the FrameBufferTextureGenerator.
Definition: FrameBufferTextureGenerator.h:697
GLuint stencil_id
The id of the render buffer used as stencil buffer with the fbo.
Definition: FrameBufferTextureGenerator.h:913
bool fbo_initialized
Flag used to determine if initializeFBO has been called or not.
Definition: FrameBufferTextureGenerator.h:875
H3DUniquePtr< MFGeneratedTextureNode > colorTextures
The texture nodes generated from color buffers specified in generateColorTextures.
Definition: FrameBufferTextureGenerator.h:392
H3DUniquePtr< SFInt32 > scissorBoxY
scissor box bottom limit, will be used when useScissor is true When this value is negative,...
Definition: FrameBufferTextureGenerator.h:536
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: FrameBufferTextureGenerator.h:680
H3DUniquePtr< SFInt32 > heightInUse
It contains the actual height value for this node used at realtime.
Definition: FrameBufferTextureGenerator.h:566
H3DUniquePtr< SFBackgroundNode > background
The X3DBackgroundNode to use when rendering the scene.
Definition: FrameBufferTextureGenerator.h:500
H3DUniquePtr< SFBool > useDSA
Controls whether the FrameBufferTextureGenerator should use direct state access features or not.
Definition: FrameBufferTextureGenerator.h:629
H3DUniquePtr< SFInt32 > projectionWidth
Specify the width used to determine the local viewpoint's projection matrix if not specified the wind...
Definition: FrameBufferTextureGenerator.h:573
H3DUniquePtr< SFInt32 > scissorBoxX
scissor box left limit, will be used when useScissor is true When this value is negative,...
Definition: FrameBufferTextureGenerator.h:528
GLuint multi_samples_depth_id
The OpenGL multi samples render buffer for depth buffer when using multi sample rendering.
Definition: FrameBufferTextureGenerator.h:885
H3DUniquePtr< SFBool > applyStencilMask
An option to let current FBTG apply the stencil masking, this option expect the stencil mask is provi...
Definition: FrameBufferTextureGenerator.h:658
void setAlwaysUseExistingViewport(bool use)
If set to true the currently set up viewport when the render() function is called will be used for th...
Definition: FrameBufferTextureGenerator.h:727
H3DUniquePtr< SFString > depthBufferStorage
Defines what should be used as the depth buffer for current FBO before rendering the sub-scene childr...
Definition: FrameBufferTextureGenerator.h:317
H3DUniquePtr< NeedMultiSample > needMultiSample
Specialized field used to check if multi sample support is needed.
Definition: FrameBufferTextureGenerator.h:861
H3DUniquePtr< MFTexturePropertiesNode > colorTextureProperties
The TextureProperties to apply to each generated color texture.
Definition: FrameBufferTextureGenerator.h:381
H3DUniquePtr< SFString > outputTextureType
The outputTextureType field determines the output type of the generated textures.
Definition: FrameBufferTextureGenerator.h:435
H3DUniquePtr< SFGeneratedTextureNode > colorTexture
The texture node generated from first color buffer specified in generateColorTextures.
Definition: FrameBufferTextureGenerator.h:397
This abstract node type is the base type for all texture nodes that is defined by a single texture.
Definition: H3DSingleTextureNode.h:45
The SFInt32 field contains one 32-bit integer.
Definition: SFInt32.h:41
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
Template to make sure that the Nodes that are added to a MFNode are of a specified Node type.
Definition: MFNode.h:221
Template to make sure that the Node that is set in a SFNode is of a specified Node type.
Definition: SFNode.h:97
This abstract node type indicates that concrete node types derived from it contain children nodes and...
Definition: X3DGroupingNode.h:53
H3D API namespace.
Definition: Anchor.h:38
The AutoUpdate field is a template to force the BaseField to update itself as soon as an event is rec...
Definition: FieldTemplates.h:130
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194