Hi,
Marcus Lindblom wrote:
Antonio Bleile wrote:
Scrive Carsten Neumann <[EMAIL PROTECTED]>:
Hi Antonio,
Antonio Bleile wrote:
Hi,
is there any OSG background that clears the color-buffer without
clearing the depth? SolidBackground always seems to clear the
depth buffer as well...
you can use a PassiveBackground, with that you are in full control of
the clearing.
Mh.... Yes OpenGL-wise, but I want to do it with OpenSG. I really need
to clear the color buffer only. I'll patch the SolidBackground if you don't
mind...
A PolygonBackground with a custom material works too.
Way too complicated.... ;)
Here's a patch of the SolidBackground if you like. Calling
setClearDepth(false), clearing of depth gets disabled (default is true).
Cheers,
Toni
Index: OSGSolidBackground.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGSolidBackground.cpp,v
retrieving revision 1.7
diff -u -r1.7 OSGSolidBackground.cpp
--- OSGSolidBackground.cpp 20 Mar 2007 15:59:41 -0000 1.7
+++ OSGSolidBackground.cpp 4 Oct 2007 16:38:10 -0000
@@ -114,15 +114,17 @@
glClearDepth(getDepth());
Int32 bit = getClearStencilBit(); // 0x0
-
+
+ GLenum clearDepth = getClearDepth()?GL_DEPTH_BUFFER_BIT:0;
+
if (bit >= 0)
{
glClearStencil(bit);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | clearDepth | GL_STENCIL_BUFFER_BIT);
}
else
{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | clearDepth);
}
}
Index: OSGSolidBackground.fcd
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGSolidBackground.fcd,v
retrieving revision 1.4
diff -u -r1.4 OSGSolidBackground.fcd
--- OSGSolidBackground.fcd 20 Mar 2007 15:59:41 -0000 1.4
+++ OSGSolidBackground.fcd 4 Oct 2007 16:35:30 -0000
@@ -52,4 +52,14 @@
>
Depth value for clear, defaults to 1.
</Field>
+ <Field
+ name="clearDepth"
+ type="bool"
+ cardinality="single"
+ visibility="external"
+ defaultValue="true"
+ access="public"
+ >
+ Whether to clear the depth buffer or not
+ </Field>
</FieldContainer>
Index: OSGSolidBackgroundBase.cpp
===================================================================
RCS file:
/cvsroot/opensg/OpenSG/Source/System/Window/OSGSolidBackgroundBase.cpp,v
retrieving revision 1.11
diff -u -r1.11 OSGSolidBackgroundBase.cpp
--- OSGSolidBackgroundBase.cpp 20 Mar 2007 15:59:41 -0000 1.11
+++ OSGSolidBackgroundBase.cpp 4 Oct 2007 16:35:58 -0000
@@ -76,6 +76,9 @@
const OSG::BitVector SolidBackgroundBase::DepthFieldMask =
(TypeTraits<BitVector>::One << SolidBackgroundBase::DepthFieldId);
+const OSG::BitVector SolidBackgroundBase::ClearDepthFieldMask =
+ (TypeTraits<BitVector>::One << SolidBackgroundBase::ClearDepthFieldId);
+
const OSG::BitVector SolidBackgroundBase::MTInfluenceMask =
(Inherited::MTInfluenceMask) |
(static_cast<BitVector>(0x0) << Inherited::NextFieldId);
@@ -95,6 +98,9 @@
/*! \var Real32 SolidBackgroundBase::_sfDepth
Depth value for clear, defaults to 1.
*/
+/*! \var bool SolidBackgroundBase::_sfClearDepth
+ Whether to clear the depth buffer or not
+*/
//! SolidBackground description
@@ -119,7 +125,12 @@
"depth",
DepthFieldId, DepthFieldMask,
false,
- (FieldAccessMethod) &SolidBackgroundBase::getSFDepth)
+ (FieldAccessMethod) &SolidBackgroundBase::getSFDepth),
+ new FieldDescription(SFBool::getClassType(),
+ "clearDepth",
+ ClearDepthFieldId, ClearDepthFieldMask,
+ false,
+ (FieldAccessMethod) &SolidBackgroundBase::getSFClearDepth)
};
@@ -199,6 +210,7 @@
_sfClearStencilBit (Int32(-1)),
_sfAlpha (Real32(1.f)),
_sfDepth (Real32(1.f)),
+ _sfClearDepth (bool(true)),
Inherited()
{
}
@@ -212,6 +224,7 @@
_sfClearStencilBit (source._sfClearStencilBit ),
_sfAlpha (source._sfAlpha ),
_sfDepth (source._sfDepth ),
+ _sfClearDepth (source._sfClearDepth ),
Inherited (source)
{
}
@@ -248,6 +261,11 @@
returnValue += _sfDepth.getBinSize();
}
+ if(FieldBits::NoField != (ClearDepthFieldMask & whichField))
+ {
+ returnValue += _sfClearDepth.getBinSize();
+ }
+
return returnValue;
}
@@ -277,6 +295,11 @@
_sfDepth.copyToBin(pMem);
}
+ if(FieldBits::NoField != (ClearDepthFieldMask & whichField))
+ {
+ _sfClearDepth.copyToBin(pMem);
+ }
+
}
@@ -305,6 +328,11 @@
_sfDepth.copyFromBin(pMem);
}
+ if(FieldBits::NoField != (ClearDepthFieldMask & whichField))
+ {
+ _sfClearDepth.copyFromBin(pMem);
+ }
+
}
@@ -327,6 +355,9 @@
if(FieldBits::NoField != (DepthFieldMask & whichField))
_sfDepth.syncWith(pOther->_sfDepth);
+ if(FieldBits::NoField != (ClearDepthFieldMask & whichField))
+ _sfClearDepth.syncWith(pOther->_sfClearDepth);
+
}
#else
@@ -349,6 +380,9 @@
if(FieldBits::NoField != (DepthFieldMask & whichField))
_sfDepth.syncWith(pOther->_sfDepth);
+ if(FieldBits::NoField != (ClearDepthFieldMask & whichField))
+ _sfClearDepth.syncWith(pOther->_sfClearDepth);
+
}
Index: OSGSolidBackgroundBase.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGSolidBackgroundBase.h,v
retrieving revision 1.13
diff -u -r1.13 OSGSolidBackgroundBase.h
--- OSGSolidBackgroundBase.h 20 Mar 2007 15:59:41 -0000 1.13
+++ OSGSolidBackgroundBase.h 4 Oct 2007 16:35:58 -0000
@@ -71,6 +71,7 @@
#include <OSGInt32Fields.h> // ClearStencilBit type
#include <OSGReal32Fields.h> // Alpha type
#include <OSGReal32Fields.h> // Depth type
+#include <OSGBoolFields.h> // ClearDepth type
#include <OSGSolidBackgroundFields.h>
@@ -98,13 +99,15 @@
ClearStencilBitFieldId = ColorFieldId + 1,
AlphaFieldId = ClearStencilBitFieldId + 1,
DepthFieldId = AlphaFieldId + 1,
- NextFieldId = DepthFieldId + 1
+ ClearDepthFieldId = DepthFieldId + 1,
+ NextFieldId = ClearDepthFieldId + 1
};
static const OSG::BitVector ColorFieldMask;
static const OSG::BitVector ClearStencilBitFieldMask;
static const OSG::BitVector AlphaFieldMask;
static const OSG::BitVector DepthFieldMask;
+ static const OSG::BitVector ClearDepthFieldMask;
static const OSG::BitVector MTInfluenceMask;
@@ -135,6 +138,7 @@
SFInt32 *getSFClearStencilBit(void);
SFReal32 *getSFAlpha (void);
SFReal32 *getSFDepth (void);
+ SFBool *getSFClearDepth (void);
Color3f &getColor (void);
const Color3f &getColor (void) const;
@@ -144,6 +148,8 @@
const Real32 &getAlpha (void) const;
Real32 &getDepth (void);
const Real32 &getDepth (void) const;
+ bool &getClearDepth (void);
+ const bool &getClearDepth (void) const;
/*! \} */
/*---------------------------------------------------------------------*/
@@ -154,6 +160,7 @@
void setClearStencilBit( const Int32 &value );
void setAlpha ( const Real32 &value );
void setDepth ( const Real32 &value );
+ void setClearDepth ( const bool &value );
/*! \} */
/*---------------------------------------------------------------------*/
@@ -200,6 +207,7 @@
SFInt32 _sfClearStencilBit;
SFReal32 _sfAlpha;
SFReal32 _sfDepth;
+ SFBool _sfClearDepth;
/*! \} */
/*---------------------------------------------------------------------*/
Index: OSGSolidBackgroundBase.inl
===================================================================
RCS file:
/cvsroot/opensg/OpenSG/Source/System/Window/OSGSolidBackgroundBase.inl,v
retrieving revision 1.10
diff -u -r1.10 OSGSolidBackgroundBase.inl
--- OSGSolidBackgroundBase.inl 20 Mar 2007 15:59:41 -0000 1.10
+++ OSGSolidBackgroundBase.inl 4 Oct 2007 16:35:58 -0000
@@ -124,6 +124,13 @@
return &_sfDepth;
}
+//! Get the SolidBackground::_sfClearDepth field.
+inline
+SFBool *SolidBackgroundBase::getSFClearDepth(void)
+{
+ return &_sfClearDepth;
+}
+
//! Get the value of the SolidBackground::_sfColor field.
inline
@@ -209,6 +216,27 @@
_sfDepth.setValue(value);
}
+//! Get the value of the SolidBackground::_sfClearDepth field.
+inline
+bool &SolidBackgroundBase::getClearDepth(void)
+{
+ return _sfClearDepth.getValue();
+}
+
+//! Get the value of the SolidBackground::_sfClearDepth field.
+inline
+const bool &SolidBackgroundBase::getClearDepth(void) const
+{
+ return _sfClearDepth.getValue();
+}
+
+//! Set the value of the SolidBackground::_sfClearDepth field.
+inline
+void SolidBackgroundBase::setClearDepth(const bool &value)
+{
+ _sfClearDepth.setValue(value);
+}
+
OSG_END_NAMESPACE
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users