Hi Wojtek,
On Wed, Nov 18, 2009 at 8:44 PM, Wojciech Lewandowski
<[email protected]> wrote:
> I will check the code tomorrow at the company where I have my latest
> changes. As I remember I later send another patch which among distupatble
> bitmasks also contained few important changes in logic in RenderStage.cpp.
> Have you seen and merged this one as well?
I have merged just the submission from the beginning of this thread.
This submission contained changes to RenderStage.cpp. I had to pick
my way through the changes as the GLES/GL3 port required changes to
RenderStage as well.
Here's an svn diff of what I have applied:
> svn diff
Index: include/osg/DisplaySettings
===================================================================
--- include/osg/DisplaySettings (revision 10765)
+++ include/osg/DisplaySettings (working copy)
@@ -206,6 +206,47 @@
void setMaxBufferObjectPoolSize(unsigned int size) {
_maxBufferObjectPoolSize = size; }
unsigned int getMaxBufferObjectPoolSize() const { return
_maxBufferObjectPoolSize; }
+ /**
+ Methods used to set and get defaults for Cameras implicit
buffer attachments.
+ For more info: See description of
Camera::setImplicitBufferAttachment method
+
+ DisplaySettings implicit buffer attachment selection
defaults to: DEPTH and COLOR
+ for both primary (Render) FBO and seconday Multisample
(Resolve) FBO
+ ie: IMPLICT_DEPTH_BUFFER_ATTACHMENT |
IMPLICIT_COLOR_BUFFER_ATTACHMENT
+ **/
+ enum ImplicitBufferAttachment
+ {
+ IMPLICIT_DEPTH_BUFFER_ATTACHMENT = (1 << 0),
+ IMPLICIT_STENCIL_BUFFER_ATTACHMENT = (1 << 1),
+ IMPLICIT_COLOR_BUFFER_ATTACHMENT = (1 << 2),
+ DEFAULT_IMPLICIT_BUFFER_ATTACHMENT =
IMPLICIT_COLOR_BUFFER_ATTACHMENT | IMPLICIT_DEPTH_BUFFER_ATTACHMENT
+ };
+
+ typedef int ImplicitBufferAttachmentMask;
+
+ void setImplicitBufferAttachmentMask(ImplicitBufferAttachmentMask
renderMask = DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT,
ImplicitBufferAttachmentMask resolveMask =
DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT )
+ {
+ _implicitBufferAttachmentRenderMask = renderMask;
+ _implicitBufferAttachmentResolveMask = resolveMask;
+ }
+
+ void setImplicitBufferAttachmentRenderMask(ImplicitBufferAttachmentMask
implicitBufferAttachmentRenderMask)
+ {
+ _implicitBufferAttachmentRenderMask =
implicitBufferAttachmentRenderMask;
+ }
+
+ void
setImplicitBufferAttachmentResolveMask(ImplicitBufferAttachmentMask
implicitBufferAttachmentResolveMask)
+ {
+ _implicitBufferAttachmentResolveMask =
implicitBufferAttachmentResolveMask;
+ }
+
+ /** Get mask selecting default implict buffer attachments for
Cameras primary FBOs. */
+ ImplicitBufferAttachmentMask
getImplicitBufferAttachmentRenderMask() const { return
_implicitBufferAttachmentRenderMask; }
+
+ /** Get mask selecting default implict buffer attachments for
Cameras secondary MULTISAMPLE FBOs. */
+ ImplicitBufferAttachmentMask
getImplicitBufferAttachmentResolveMask() const { return
_implicitBufferAttachmentResolveMask;}
+
+
/** Set the hint of which OpenGL version to attempt to create
a graphics context for.*/
void setGLContextVersion(const std::string& version) {
_glContextVersion = version; }
@@ -267,6 +308,9 @@
unsigned int _maxTexturePoolSize;
unsigned int _maxBufferObjectPoolSize;
+
+ ImplicitBufferAttachmentMask
_implicitBufferAttachmentRenderMask;
+ ImplicitBufferAttachmentMask
_implicitBufferAttachmentResolveMask;
std::string _glContextVersion;
unsigned int _glContextFlags;
Index: include/osg/Camera
===================================================================
--- include/osg/Camera (revision 10765)
+++ include/osg/Camera (working copy)
@@ -399,6 +399,96 @@
const BufferAttachmentMap& getBufferAttachmentMap() const {
return _bufferAttachmentMap; }
+ /** Explicit control over implicit allocation of buffers when
using FBO.
+ Implicit buffers are automatically substituted when user
have not attached such buffer.
+
+ Camera may set up two FBOs: primary Render FBO and secondary
Resolve FBO for multisample usage.
+ So in practive we have two masks defined for the Camera:
+ implicitBufferAttachmentRenderMask
+ implicitBufferAttachmentResolveMask
+ They can be set together by setImplicitBufferAttachmentMask
method, or separately
+ by setImplicitBufferAttachmentRenderMask and
setImplicitBufferAttachmentResolveMask.
+
+ Camera defaults are USE_DISPLAY_SETTINGS_MASK which means
that by default
+ Camera chooses to substitue buffer attachments as defined by
DisplaySettings.
+
+ Usually DisplaySettings implicit buffer attachment selection
defaults to: DEPTH and COLOR
+ for both primary (Render) FBO and seconday Multisample
(Resolve) FBO
+ ie: IMPLICT_DEPTH_BUFFER_ATTACHMENT |
IMPLICIT_COLOR_BUFFER_ATTACHMENT
+
+ If these masks are not changed and user did not attach depth
buffer and/or color buffer
+ to Camera, then OSG implicitly substitues these buffers.
+ By default it does not implicitly allocate a stencil buffer.
+ Use implicti buffer attachment masks to override default
behavior:
+ to turn off DEPTH or COLOR buffer substitution or to enforce
STENCIL buffer substitution.
+
+ Note that both values are ignored if not using FBO.
+ Note that the second mask value is ignored if not using
MSFBO.
+ */
+ enum ImplicitBufferAttachment
+ {
+ IMPLICIT_DEPTH_BUFFER_ATTACHMENT =
DisplaySettings::IMPLICIT_DEPTH_BUFFER_ATTACHMENT,
+ IMPLICIT_STENCIL_BUFFER_ATTACHMENT =
DisplaySettings::IMPLICIT_STENCIL_BUFFER_ATTACHMENT,
+ IMPLICIT_COLOR_BUFFER_ATTACHMENT =
DisplaySettings::IMPLICIT_COLOR_BUFFER_ATTACHMENT,
+ USE_DISPLAY_SETTINGS_MASK = (~0)
+ };
+
+ typedef int ImplicitBufferAttachmentMask;
+
+ void setImplicitBufferAttachmentMask(ImplicitBufferAttachmentMask
renderMask = DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT,
ImplicitBufferAttachmentMask resolveMask =
DisplaySettings::DEFAULT_IMPLICIT_BUFFER_ATTACHMENT)
+ {
+ _implicitBufferAttachmentRenderMask = renderMask;
+ _implicitBufferAttachmentResolveMask = resolveMask;
+ }
+
+ void setImplicitBufferAttachmentRenderMask(ImplicitBufferAttachmentMask
implicitBufferAttachmentRenderMask)
+ {
+ _implicitBufferAttachmentRenderMask =
implicitBufferAttachmentRenderMask;
+ }
+
+ void
setImplicitBufferAttachmentResolveMask(ImplicitBufferAttachmentMask
implicitBufferAttachmentResolveMask)
+ {
+ _implicitBufferAttachmentResolveMask =
implicitBufferAttachmentResolveMask;
+ }
+
+ /**
+ Get mask selecting implict buffer attachments for Camera
primary FBO
+ if effectiveMask parameter is set, method follows
USE_DISPLAY_SETTINGS_MASK dependence and returns effective mask
+ if effectiveMask parameter is reset, method returns nominal
mask set by the Camera
+ */
+ ImplicitBufferAttachmentMask
getImplicitBufferAttachmentRenderMask(bool effectiveMask = false)
const
+ {
+ if( effectiveMask && _implicitBufferAttachmentRenderMask
== USE_DISPLAY_SETTINGS_MASK )
+ {
+ const DisplaySettings * ds = getDisplaySettings();
+ if ( !ds ) ds = DisplaySettings::instance();
+ return ds->getImplicitBufferAttachmentRenderMask();
+ }
+ else
+ {
+ return _implicitBufferAttachmentRenderMask;
+ }
+ }
+
+ /**
+ Get mask selecting implict buffer attachments for Camera
secondary MULTISAMPLE FBO
+ if effectiveMask parameter is set, method follows
USE_DISPLAY_SETTINGS_MASK dependence and returns effective mask
+ if effectiveMask parameter is reset, method returns nominal
mask set by the Camera
+ */
+ ImplicitBufferAttachmentMask
getImplicitBufferAttachmentResolveMask(bool effectiveMask = false)
const
+ {
+ if( effectiveMask && _implicitBufferAttachmentResolveMask
== USE_DISPLAY_SETTINGS_MASK )
+ {
+ const DisplaySettings * ds = getDisplaySettings();
+ if ( !ds ) ds = DisplaySettings::instance();
+ return ds->getImplicitBufferAttachmentRenderMask();
+ }
+ else
+ {
+ return _implicitBufferAttachmentResolveMask;
+ }
+ }
+
/** Create a operation thread for this camera.*/
void createCameraThread();
@@ -559,6 +649,8 @@
RenderTargetImplementation
_renderTargetImplementation;
RenderTargetImplementation _renderTargetFallback;
BufferAttachmentMap _bufferAttachmentMap;
+ ImplicitBufferAttachmentMask
_implicitBufferAttachmentRenderMask;
+ ImplicitBufferAttachmentMask
_implicitBufferAttachmentResolveMask;
ref_ptr<OperationThread> _cameraThread;
Index: src/osgUtil/RenderStage.cpp
===================================================================
--- src/osgUtil/RenderStage.cpp (revision 10765)
+++ src/osgUtil/RenderStage.cpp (working copy)
@@ -25,9 +25,6 @@
#include <osgUtil/RenderStage>
-#define FORCE_COLOR_ATTACHMENT 1
-#define FORCE_DEPTH_ATTACHMENT 1
-
using namespace osg;
using namespace osgUtil;
@@ -349,6 +346,12 @@
unsigned samples = 0;
unsigned colorSamples = 0;
+ // This is not a cut and paste error. Set BOTH local
masks
+ // to the value of the Camera's use render buffers mask.
+ // We'll change this if and only if we decide we're doing
MSFBO.
+ unsigned int renderBuffersMask =
_camera->getImplicitBufferAttachmentRenderMask(true);
+ unsigned int resolveBuffersMask =
_camera->getImplicitBufferAttachmentRenderMask(true);
+
if (fbo_ext->isMultisampleSupported())
{
for(osg::Camera::BufferAttachmentMap::iterator itr =
bufferAttachments.begin();
@@ -370,9 +373,13 @@
if (samples)
{
fbo_multisample = new osg::FrameBufferObject;
+
+ // Use the value of the Camera's use resolve
buffers mask as the
+ // resolve mask.
+ resolveBuffersMask =
_camera->getImplicitBufferAttachmentResolveMask(true);
}
}
-
+
for(osg::Camera::BufferAttachmentMap::iterator itr =
bufferAttachments.begin();
itr != bufferAttachments.end();
++itr)
@@ -430,33 +437,63 @@
}
-#if FORCE_DEPTH_ATTACHMENT
if (!depthAttached)
- {
- fbo->setAttachment(osg::Camera::DEPTH_BUFFER,
osg::FrameBufferAttachment(new osg::RenderBuffer(width, height,
GL_DEPTH_COMPONENT24)));
- if (fbo_multisample.valid())
+ {
+ // If doing MSFBO (and therefore need two FBOs, one
for multisampled rendering and one for
+ // final resolve), then configure "fbo" as the
resolve FBO, and When done
+ // configuring, swap it into "_resolveFbo" (see line
554). But, if not
+ // using MSFBO, then "fbo" is just the render fbo.
+ // If using MSFBO, then resolveBuffersMask
+ // is the value set by the app for the resolve
buffers. But if not using
+ // MSFBO, then resolveBuffersMask is the value set by
the app for render
+ // buffers. In both cases, resolveBuffersMask is used
to configure "fbo".
+ if( resolveBuffersMask &
osg::Camera::IMPLICIT_DEPTH_BUFFER_ATTACHMENT )
{
+ fbo->setAttachment(osg::Camera::DEPTH_BUFFER,
osg::FrameBufferAttachment(new osg::RenderBuffer(width, height,
GL_DEPTH_COMPONENT24)));
+ depthAttached = true;
+ }
+ if (fbo_multisample.valid() &&
+ ( renderBuffersMask &
osg::Camera::IMPLICIT_DEPTH_BUFFER_ATTACHMENT ) )
+ {
fbo_multisample->setAttachment(osg::Camera::DEPTH_BUFFER,
osg::FrameBufferAttachment(new
osg::RenderBuffer(width,
height, GL_DEPTH_COMPONENT24, samples,
colorSamples)));
+ depthAttached = true;
}
- depthAttached = true;
}
-#endif
+ if (!stencilAttached)
+ {
+ if( resolveBuffersMask &
osg::Camera::IMPLICIT_STENCIL_BUFFER_ATTACHMENT )
+ {
+ fbo->setAttachment(osg::Camera::STENCIL_BUFFER,
osg::FrameBufferAttachment(new osg::RenderBuffer(width, height,
GL_STENCIL_INDEX8_EXT)));
+ stencilAttached = true;
+ }
+ if (fbo_multisample.valid() &&
+ ( renderBuffersMask &
osg::Camera::IMPLICIT_STENCIL_BUFFER_ATTACHMENT ) )
+ {
+
fbo_multisample->setAttachment(osg::Camera::STENCIL_BUFFER,
+ osg::FrameBufferAttachment(new
osg::RenderBuffer(width,
+ height, GL_STENCIL_INDEX8_EXT, samples,
colorSamples)));
+ stencilAttached = true;
+ }
+ }
-#if FORCE_COLOR_ATTACHMENT
if (!colorAttached)
{
- fbo->setAttachment(osg::Camera::COLOR_BUFFER,
osg::FrameBufferAttachment(new osg::RenderBuffer(width, height,
GL_RGB)));
- if (fbo_multisample.valid())
+ if( resolveBuffersMask &
osg::Camera::IMPLICIT_COLOR_BUFFER_ATTACHMENT )
{
+ fbo->setAttachment(osg::Camera::COLOR_BUFFER,
osg::FrameBufferAttachment(new osg::RenderBuffer(width, height,
GL_RGB)));
+ colorAttached = true;
+ }
+ if (fbo_multisample.valid() &&
+ ( renderBuffersMask &
osg::Camera::IMPLICIT_COLOR_BUFFER_ATTACHMENT ) )
+ {
fbo_multisample->setAttachment(osg::Camera::COLOR_BUFFER,
osg::FrameBufferAttachment(new
osg::RenderBuffer(width,
height, GL_RGB, samples, colorSamples)));
+ colorAttached = true;
}
- colorAttached = true;
}
-#endif
fbo->apply(state);
@@ -904,29 +941,12 @@
if (fbo_supported && _resolveFbo.valid() &&
fbo_ext->glBlitFramebuffer)
{
- GLbitfield blitMask = 0;
+ // OpenGL 3.1 spec says: "If a buffer is specified in mask
and does not
+ // exist in both the read and draw framebuffers, the
corresponding bit
+ // is silently ignored." So there is no need to iterate over
buffer
+ // attachments to determine the value of mask; just blit all.
+ const GLbitfield blitMask( GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
- //find which buffer types should be copied
- for (FrameBufferObject::AttachmentMap::const_iterator
- it = _resolveFbo->getAttachmentMap().begin(),
- end =_resolveFbo->getAttachmentMap().end(); it != end;
++it)
- {
- switch (it->first)
- {
- case Camera::DEPTH_BUFFER:
- blitMask |= GL_DEPTH_BUFFER_BIT;
- break;
- case Camera::STENCIL_BUFFER:
- blitMask |= GL_STENCIL_BUFFER_BIT;
- break;
- case Camera::PACKED_DEPTH_STENCIL_BUFFER:
- blitMask |= GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT;
- default:
- blitMask |= GL_COLOR_BUFFER_BIT;
- break;
- }
- }
-
// Bind the resolve framebuffer to blit into.
_fbo->apply(state, FrameBufferObject::READ_FRAMEBUFFER);
_resolveFbo->apply(state,
FrameBufferObject::DRAW_FRAMEBUFFER);
Index: src/osg/DisplaySettings.cpp
===================================================================
--- src/osg/DisplaySettings.cpp (revision 10765)
+++ src/osg/DisplaySettings.cpp (working copy)
@@ -84,6 +84,9 @@
_maxTexturePoolSize = vs._maxTexturePoolSize;
_maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize;
+ _implicitBufferAttachmentRenderMask =
vs._implicitBufferAttachmentRenderMask;
+ _implicitBufferAttachmentResolveMask =
vs._implicitBufferAttachmentResolveMask;
+
_glContextVersion = vs._glContextVersion;
_glContextFlags = vs._glContextFlags;
_glContextProfileMask = vs._glContextProfileMask;
@@ -113,6 +116,10 @@
if (vs._maxTexturePoolSize>_maxTexturePoolSize)
_maxTexturePoolSize = vs._maxTexturePoolSize;
if (vs._maxBufferObjectPoolSize>_maxBufferObjectPoolSize)
_maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize;
+
+ // these are bit masks so merging them is like logical or
+ _implicitBufferAttachmentRenderMask |=
vs._implicitBufferAttachmentRenderMask;
+ _implicitBufferAttachmentResolveMask |=
vs._implicitBufferAttachmentResolveMask;
}
void DisplaySettings::setDefaults()
@@ -161,6 +168,8 @@
_maxTexturePoolSize = 0;
_maxBufferObjectPoolSize = 0;
+ _implicitBufferAttachmentRenderMask =
DEFAULT_IMPLICIT_BUFFER_ATTACHMENT;
+ _implicitBufferAttachmentResolveMask =
DEFAULT_IMPLICIT_BUFFER_ATTACHMENT;
_glContextVersion = "1.0";
_glContextFlags = 0;
_glContextProfileMask = 0;
@@ -206,9 +215,11 @@
static ApplicationUsageProxy
DisplaySetting_e18(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_TEXTURE_POOL_SIZE
<int>","Set the hint size of texture pool to manage.");
static ApplicationUsageProxy
DisplaySetting_e19(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_BUFFER_OBJECT_POOL_SIZE
<int>","Set the hint size of vertex buffer object pool to manage.");
static ApplicationUsageProxy
DisplaySetting_e20(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_FBO_POOL_SIZE
<int>","Set the hint size of frame buffer object pool to manage.");
-static ApplicationUsageProxy
DisplaySetting_e21(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_VERSION
<major.minor>","Set the hint for the GL version to create contexts
for.");
-static ApplicationUsageProxy
DisplaySetting_e22(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_FLAGS
<uint>","Set the hint for the GL context flags to use when creating
contexts.");
-static ApplicationUsageProxy
DisplaySetting_e23(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_PROFILE_MASK
<uint>","Set the hint for the GL context profile mask to use when
creating contexts.");
+static ApplicationUsageProxy
DisplaySetting_e21(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_IMPLICIT_BUFFER_ATTACHMENT_RENDER_MASK","OFF
| DEFAULT | [~]COLOR | [~]DEPTH | [~]STENCIL. Substitute missing
buffer attachments for render FBO");
+static ApplicationUsageProxy
DisplaySetting_e22(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_IMPLICIT_BUFFER_ATTACHMENT_RESOLVE_MASK","OFF
| DEFAULT | [~]COLOR | [~]DEPTH | [~]STENCIL. Substitute missing
buffer attachments for resolve FBO");
+static ApplicationUsageProxy
DisplaySetting_e23(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_VERSION
<major.minor>","Set the hint for the GL version to create contexts
for.");
+static ApplicationUsageProxy
DisplaySetting_e24(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_FLAGS
<uint>","Set the hint for the GL context flags to use when creating
contexts.");
+static ApplicationUsageProxy
DisplaySetting_e25(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_PROFILE_MASK
<uint>","Set the hint for the GL context profile mask to use when
creating contexts.");
void DisplaySettings::readEnvironmentalVariables()
{
@@ -416,6 +427,40 @@
_maxBufferObjectPoolSize = atoi(ptr);
}
+
+ { // Read implicit buffer attachments combinations for both
render and resolve mask
+ const char * variable[] = {
+ "OSG_IMPLICIT_BUFFER_ATTACHMENT_RENDER_MASK",
+ "OSG_IMPLICIT_BUFFER_ATTACHMENT_RESOLVE_MASK",
+ };
+
+ int * mask[] = {
+ &_implicitBufferAttachmentRenderMask,
+ &_implicitBufferAttachmentResolveMask,
+ };
+
+ for( unsigned int n = 0; n < sizeof( variable ) / sizeof(
variable[0] ); n++ )
+ {
+ const char* env = getenv( variable[n] );
+ if ( !env ) continue;
+ std::string str(env);
+
+ if(str.find("OFF")!=std::string::npos) *mask[n] = 0;
+
+ if(str.find("~DEFAULT")!=std::string::npos) *mask[n] ^=
DEFAULT_IMPLICIT_BUFFER_ATTACHMENT;
+ else if(str.find("DEFAULT")!=std::string::npos) *mask[n]
|= DEFAULT_IMPLICIT_BUFFER_ATTACHMENT;
+
+ if(str.find("~COLOR")!=std::string::npos) *mask[n] ^=
IMPLICIT_COLOR_BUFFER_ATTACHMENT;
+ else if(str.find("COLOR")!=std::string::npos) *mask[n] |=
IMPLICIT_COLOR_BUFFER_ATTACHMENT;
+
+ if(str.find("~DEPTH")!=std::string::npos) *mask[n] ^=
IMPLICIT_DEPTH_BUFFER_ATTACHMENT;
+ else if(str.find("DEPTH")!=std::string::npos) *mask[n] |=
(int)IMPLICIT_DEPTH_BUFFER_ATTACHMENT;
+
+ if(str.find("~STENCIL")!=std::string::npos) *mask[n] ^=
(int)IMPLICIT_STENCIL_BUFFER_ATTACHMENT;
+ else if(str.find("STENCIL")!=std::string::npos) *mask[n]
|= (int)IMPLICIT_STENCIL_BUFFER_ATTACHMENT;
+ }
+ }
+
if( (ptr = getenv("OSG_GL_VERSION")) != 0 || (ptr =
getenv("OSG_GL_CONTEXT_VERSION")) != 0)
{
_glContextVersion = ptr;
@@ -449,6 +494,8 @@
arguments.getApplicationUsage()->addCommandLineOption("--samples
<num>","Request a multisample visual");
arguments.getApplicationUsage()->addCommandLineOption("--cc","Request
use of compile contexts and threads");
arguments.getApplicationUsage()->addCommandLineOption("--serialize-draw
<mode>","OFF | ON - set the serialization of draw dispatch");
+
arguments.getApplicationUsage()->addCommandLineOption("--implicit-buffer-attachment-render-mask","OFF
| DEFAULT | [~]COLOR | [~]DEPTH | [~]STENCIL. Substitute missing
buffer attachments for render FBO");
+
arguments.getApplicationUsage()->addCommandLineOption("--implicit-buffer-attachment-resolve-mask","OFF
| DEFAULT | [~]COLOR | [~]DEPTH | [~]STENCIL. Substitute missing
buffer attachments for resolve FBO");
arguments.getApplicationUsage()->addCommandLineOption("--gl-version
<major.minor>","Set the hint of which GL version to use when creating
graphics contexts.");
arguments.getApplicationUsage()->addCommandLineOption("--gl-flags
<mask>","Set the hint of which GL flags projfile mask to use when
creating graphics contexts.");
arguments.getApplicationUsage()->addCommandLineOption("--gl-profile-mask
<mask>","Set the hint of which GL context profile mask to use when
creating graphics contexts.");
@@ -523,6 +570,38 @@
while(arguments.read("--texture-pool-size",_maxTexturePoolSize))
{}
while(arguments.read("--buffer-object-pool-size",_maxBufferObjectPoolSize))
{}
+ { // Read implicit buffer attachments combinations for both
render and resolve mask
+ const char* option[] = {
+ "--implicit-buffer-attachment-render-mask",
+ "--implicit-buffer-attachment-resolve-mask",
+ };
+
+ int * mask[] = {
+ &_implicitBufferAttachmentRenderMask,
+ &_implicitBufferAttachmentResolveMask,
+ };
+
+ for( unsigned int n = 0; n < sizeof( option ) / sizeof(
option[0]); n++ )
+ {
+ while(arguments.read( option[n],str))
+ {
+ if(str.find("OFF")!=std::string::npos) *mask[n] = 0;
+
+ if(str.find("~DEFAULT")!=std::string::npos) *mask[n]
^= DEFAULT_IMPLICIT_BUFFER_ATTACHMENT;
+ else if(str.find("DEFAULT")!=std::string::npos)
*mask[n] |= DEFAULT_IMPLICIT_BUFFER_ATTACHMENT;
+
+ if(str.find("~COLOR")!=std::string::npos) *mask[n] ^=
IMPLICIT_COLOR_BUFFER_ATTACHMENT;
+ else if(str.find("COLOR")!=std::string::npos)
*mask[n] |= IMPLICIT_COLOR_BUFFER_ATTACHMENT;
+
+ if(str.find("~DEPTH")!=std::string::npos) *mask[n] ^=
IMPLICIT_DEPTH_BUFFER_ATTACHMENT;
+ else if(str.find("DEPTH")!=std::string::npos)
*mask[n] |= IMPLICIT_DEPTH_BUFFER_ATTACHMENT;
+
+ if(str.find("~STENCIL")!=std::string::npos) *mask[n]
^= IMPLICIT_STENCIL_BUFFER_ATTACHMENT;
+ else if(str.find("STENCIL")!=std::string::npos)
*mask[n] |= IMPLICIT_STENCIL_BUFFER_ATTACHMENT;
+ }
+ }
+ }
+
while (arguments.read("--gl-version", _glContextVersion)) {}
while (arguments.read("--gl-flags", _glContextFlags)) {}
while (arguments.read("--gl-profile-mask",
_glContextProfileMask)) {}
Index: src/osg/Camera.cpp
===================================================================
--- src/osg/Camera.cpp (revision 10765)
+++ src/osg/Camera.cpp (working copy)
@@ -31,7 +31,9 @@
_drawBuffer(GL_NONE),
_readBuffer(GL_NONE),
_renderTargetImplementation(FRAME_BUFFER),
- _renderTargetFallback(FRAME_BUFFER)
+ _renderTargetFallback(FRAME_BUFFER),
+ _implicitBufferAttachmentRenderMask( USE_DISPLAY_SETTINGS_MASK ),
+ _implicitBufferAttachmentResolveMask( USE_DISPLAY_SETTINGS_MASK )
{
setStateSet(new StateSet);
}
@@ -60,6 +62,8 @@
_renderTargetImplementation(camera._renderTargetImplementation),
_renderTargetFallback(camera._renderTargetFallback),
_bufferAttachmentMap(camera._bufferAttachmentMap),
+
_implicitBufferAttachmentRenderMask(camera._implicitBufferAttachmentRenderMask),
+
_implicitBufferAttachmentResolveMask(camera._implicitBufferAttachmentResolveMask),
_initialDrawCallback(camera._initialDrawCallback),
_preDrawCallback(camera._preDrawCallback),
_postDrawCallback(camera._postDrawCallback),
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org