Hi,

I really hate to bother you again with my FBO stuff... But
I again had to patch the code to fit it to my needs. My
problem was FBO rendering in fbo off mode on machines
without NPOT texture support. I have to allocate 2pot
textures for the fbo (storage size!) but I just have
to render (and thus to glCopy) just a portion of that
big texture. The current implementation does not consider
this special case, it just takes the storage size and
renders with a TiledCameraDecorator into the whole texture.
So I just added a flag (switchable through
"setFboOffIgnoreStorageSize") that stops this behaviour.
It just uses the window size for the rendering dimension.
Actually it would be nicer to set a separate dimenion that
specifies which region of the texture to update, but I'm
not sure if anybody besides me is interested in that :)
And considering that this is just for keeping it going on
outdated hardware.... *sigh*. Any comments are welcome.

Regards,

  Toni
Index: OSGFBOViewportBase.inl
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewportBase.inl,v
retrieving revision 1.2
diff -u -r1.2 OSGFBOViewportBase.inl
--- OSGFBOViewportBase.inl      28 Aug 2007 16:06:59 -0000      1.2
+++ OSGFBOViewportBase.inl      4 Sep 2007 17:47:53 -0000
@@ -201,6 +201,13 @@
     return &_sfIgnoreCameraDecorators;
 }
 
+//! Get the FBOViewport::_sfFboOffIgnoreStorageSize field.
+inline
+SFBool *FBOViewportBase::getSFFboOffIgnoreStorageSize(void)
+{
+    return &_sfFboOffIgnoreStorageSize;
+}
+
 
 //! Get the value of the FBOViewport::_sfEnabled field.
 inline
@@ -454,6 +461,27 @@
     _sfIgnoreCameraDecorators.setValue(value);
 }
 
+//! Get the value of the FBOViewport::_sfFboOffIgnoreStorageSize field.
+inline
+bool &FBOViewportBase::getFboOffIgnoreStorageSize(void)
+{
+    return _sfFboOffIgnoreStorageSize.getValue();
+}
+
+//! Get the value of the FBOViewport::_sfFboOffIgnoreStorageSize field.
+inline
+const bool &FBOViewportBase::getFboOffIgnoreStorageSize(void) const
+{
+    return _sfFboOffIgnoreStorageSize.getValue();
+}
+
+//! Set the value of the FBOViewport::_sfFboOffIgnoreStorageSize field.
+inline
+void FBOViewportBase::setFboOffIgnoreStorageSize(const bool &value)
+{
+    _sfFboOffIgnoreStorageSize.setValue(value);
+}
+
 
 //! Get the value of the \a index element the FBOViewport::_mfExcludeNodes 
field.
 inline
@@ -520,5 +548,5 @@
 
 OSG_END_NAMESPACE
 
-#define OSGFBOVIEWPORTBASE_INLINE_CVSID "@(#)$Id: OSGFBOViewportBase.inl,v 1.2 
2007/08/28 16:06:59 neumannc Exp $"
+#define OSGFBOVIEWPORTBASE_INLINE_CVSID "@(#)$Id: FCBaseTemplate_inl.h,v 1.20 
2002/12/04 14:22:22 dirk Exp $"
 
Index: OSGFBOViewportBase.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewportBase.h,v
retrieving revision 1.2
diff -u -r1.2 OSGFBOViewportBase.h
--- OSGFBOViewportBase.h        28 Aug 2007 16:06:59 -0000      1.2
+++ OSGFBOViewportBase.h        4 Sep 2007 17:47:53 -0000
@@ -82,6 +82,7 @@
 #include <OSGBoolFields.h> // Dirty type
 #include <OSGBoolFields.h> // ReadBuffer type
 #include <OSGBoolFields.h> // IgnoreCameraDecorators type
+#include <OSGBoolFields.h> // FboOffIgnoreStorageSize type
 
 #include <OSGFBOViewportFields.h>
 
@@ -105,22 +106,23 @@
 
     enum
     {
-        EnabledFieldId                = Inherited::NextFieldId,
-        ExcludeNodesFieldId           = EnabledFieldId                + 1,
-        RenderNodesFieldId            = ExcludeNodesFieldId           + 1,
-        TexturesFieldId               = RenderNodesFieldId            + 1,
-        FboOnFieldId                  = TexturesFieldId               + 1,
-        StorageWidthFieldId           = FboOnFieldId                  + 1,
-        StorageHeightFieldId          = StorageWidthFieldId           + 1,
-        GenCubemapsFieldId            = StorageHeightFieldId          + 1,
-        GenDepthmapsFieldId           = GenCubemapsFieldId            + 1,
-        FrameBufferIndexFieldId       = GenDepthmapsFieldId           + 1,
-        DepthBufferIndexFieldId       = FrameBufferIndexFieldId       + 1,
-        StencilBufferIndexFieldId     = DepthBufferIndexFieldId       + 1,
-        DirtyFieldId                  = StencilBufferIndexFieldId     + 1,
-        ReadBufferFieldId             = DirtyFieldId                  + 1,
-        IgnoreCameraDecoratorsFieldId = ReadBufferFieldId             + 1,
-        NextFieldId                   = IgnoreCameraDecoratorsFieldId + 1
+        EnabledFieldId                 = Inherited::NextFieldId,
+        ExcludeNodesFieldId            = EnabledFieldId                 + 1,
+        RenderNodesFieldId             = ExcludeNodesFieldId            + 1,
+        TexturesFieldId                = RenderNodesFieldId             + 1,
+        FboOnFieldId                   = TexturesFieldId                + 1,
+        StorageWidthFieldId            = FboOnFieldId                   + 1,
+        StorageHeightFieldId           = StorageWidthFieldId            + 1,
+        GenCubemapsFieldId             = StorageHeightFieldId           + 1,
+        GenDepthmapsFieldId            = GenCubemapsFieldId             + 1,
+        FrameBufferIndexFieldId        = GenDepthmapsFieldId            + 1,
+        DepthBufferIndexFieldId        = FrameBufferIndexFieldId        + 1,
+        StencilBufferIndexFieldId      = DepthBufferIndexFieldId        + 1,
+        DirtyFieldId                   = StencilBufferIndexFieldId      + 1,
+        ReadBufferFieldId              = DirtyFieldId                   + 1,
+        IgnoreCameraDecoratorsFieldId  = ReadBufferFieldId              + 1,
+        FboOffIgnoreStorageSizeFieldId = IgnoreCameraDecoratorsFieldId  + 1,
+        NextFieldId                    = FboOffIgnoreStorageSizeFieldId + 1
     };
 
     static const OSG::BitVector EnabledFieldMask;
@@ -138,6 +140,7 @@
     static const OSG::BitVector DirtyFieldMask;
     static const OSG::BitVector ReadBufferFieldMask;
     static const OSG::BitVector IgnoreCameraDecoratorsFieldMask;
+    static const OSG::BitVector FboOffIgnoreStorageSizeFieldMask;
 
 
     static const OSG::BitVector MTInfluenceMask;
@@ -176,6 +179,7 @@
            SFBool              *getSFDirty          (void);
            SFBool              *getSFReadBuffer     (void);
            SFBool              *getSFIgnoreCameraDecorators(void);
+           SFBool              *getSFFboOffIgnoreStorageSize(void);
 
            bool                &getEnabled        (void);
      const bool                &getEnabled        (void) const;
@@ -195,6 +199,8 @@
      const bool                &getReadBuffer     (void) const;
            bool                &getIgnoreCameraDecorators(void);
      const bool                &getIgnoreCameraDecorators(void) const;
+           bool                &getFboOffIgnoreStorageSize(void);
+     const bool                &getFboOffIgnoreStorageSize(void) const;
            NodePtr             &getExcludeNodes   (const UInt32 index);
            MFNodePtr           &getExcludeNodes   (void);
      const MFNodePtr           &getExcludeNodes   (void) const;
@@ -219,6 +225,7 @@
      void setDirty          ( const bool &value );
      void setReadBuffer     ( const bool &value );
      void setIgnoreCameraDecorators( const bool &value );
+     void setFboOffIgnoreStorageSize( const bool &value );
 
     /*! \}                                                                 */
     /*---------------------------------------------------------------------*/
@@ -276,6 +283,7 @@
     SFBool              _sfDirty;
     SFBool              _sfReadBuffer;
     SFBool              _sfIgnoreCameraDecorators;
+    SFBool              _sfFboOffIgnoreStorageSize;
 
     /*! \}                                                                 */
     /*---------------------------------------------------------------------*/
@@ -378,6 +386,6 @@
 
 OSG_END_NAMESPACE
 
-#define OSGFBOVIEWPORTBASE_HEADER_CVSID "@(#)$Id: OSGFBOViewportBase.h,v 1.2 
2007/08/28 16:06:59 neumannc Exp $"
+#define OSGFBOVIEWPORTBASE_HEADER_CVSID "@(#)$Id: FCBaseTemplate_h.h,v 1.40 
2005/07/20 00:10:14 vossg Exp $"
 
 #endif /* _OSGFBOVIEWPORTBASE_H_ */
Index: OSGFBOViewportBase.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewportBase.cpp,v
retrieving revision 1.2
diff -u -r1.2 OSGFBOViewportBase.cpp
--- OSGFBOViewportBase.cpp      28 Aug 2007 16:06:59 -0000      1.2
+++ OSGFBOViewportBase.cpp      4 Sep 2007 17:47:53 -0000
@@ -109,6 +109,9 @@
 const OSG::BitVector  FBOViewportBase::IgnoreCameraDecoratorsFieldMask = 
     (TypeTraits<BitVector>::One << 
FBOViewportBase::IgnoreCameraDecoratorsFieldId);
 
+const OSG::BitVector  FBOViewportBase::FboOffIgnoreStorageSizeFieldMask = 
+    (TypeTraits<BitVector>::One << 
FBOViewportBase::FboOffIgnoreStorageSizeFieldId);
+
 const OSG::BitVector FBOViewportBase::MTInfluenceMask = 
     (Inherited::MTInfluenceMask) | 
     (static_cast<BitVector>(0x0) << Inherited::NextFieldId); 
@@ -161,6 +164,9 @@
 /*! \var bool            FBOViewportBase::_sfIgnoreCameraDecorators
     whether the render method should ignore CameraDecorators or not
 */
+/*! \var bool            FBOViewportBase::_sfFboOffIgnoreStorageSize
+    whether to ignore storage size in Fbo off mode and just consider window 
size
+*/
 
 //! FBOViewport description
 
@@ -240,7 +246,12 @@
                      "ignoreCameraDecorators", 
                      IgnoreCameraDecoratorsFieldId, 
IgnoreCameraDecoratorsFieldMask,
                      false,
-                     (FieldAccessMethod) 
&FBOViewportBase::getSFIgnoreCameraDecorators)
+                     (FieldAccessMethod) 
&FBOViewportBase::getSFIgnoreCameraDecorators),
+    new FieldDescription(SFBool::getClassType(), 
+                     "fboOffIgnoreStorageSize", 
+                     FboOffIgnoreStorageSizeFieldId, 
FboOffIgnoreStorageSizeFieldMask,
+                     false,
+                     (FieldAccessMethod) 
&FBOViewportBase::getSFFboOffIgnoreStorageSize)
 };
 
 
@@ -334,6 +345,7 @@
     _sfDirty                  (bool(true)), 
     _sfReadBuffer             (bool(false)), 
     _sfIgnoreCameraDecorators (bool(true)), 
+    _sfFboOffIgnoreStorageSize(bool(false)), 
     Inherited() 
 {
 }
@@ -358,6 +370,7 @@
     _sfDirty                  (source._sfDirty                  ), 
     _sfReadBuffer             (source._sfReadBuffer             ), 
     _sfIgnoreCameraDecorators (source._sfIgnoreCameraDecorators ), 
+    _sfFboOffIgnoreStorageSize(source._sfFboOffIgnoreStorageSize), 
     Inherited                 (source)
 {
 }
@@ -449,6 +462,11 @@
         returnValue += _sfIgnoreCameraDecorators.getBinSize();
     }
 
+    if(FieldBits::NoField != (FboOffIgnoreStorageSizeFieldMask & whichField))
+    {
+        returnValue += _sfFboOffIgnoreStorageSize.getBinSize();
+    }
+
 
     return returnValue;
 }
@@ -533,6 +551,11 @@
         _sfIgnoreCameraDecorators.copyToBin(pMem);
     }
 
+    if(FieldBits::NoField != (FboOffIgnoreStorageSizeFieldMask & whichField))
+    {
+        _sfFboOffIgnoreStorageSize.copyToBin(pMem);
+    }
+
 
 }
 
@@ -616,6 +639,11 @@
         _sfIgnoreCameraDecorators.copyFromBin(pMem);
     }
 
+    if(FieldBits::NoField != (FboOffIgnoreStorageSizeFieldMask & whichField))
+    {
+        _sfFboOffIgnoreStorageSize.copyFromBin(pMem);
+    }
+
 
 }
 
@@ -671,6 +699,9 @@
     if(FieldBits::NoField != (IgnoreCameraDecoratorsFieldMask & whichField))
         _sfIgnoreCameraDecorators.syncWith(pOther->_sfIgnoreCameraDecorators);
 
+    if(FieldBits::NoField != (FboOffIgnoreStorageSizeFieldMask & whichField))
+        
_sfFboOffIgnoreStorageSize.syncWith(pOther->_sfFboOffIgnoreStorageSize);
+
 
 }
 #else
@@ -717,6 +748,9 @@
     if(FieldBits::NoField != (IgnoreCameraDecoratorsFieldMask & whichField))
         _sfIgnoreCameraDecorators.syncWith(pOther->_sfIgnoreCameraDecorators);
 
+    if(FieldBits::NoField != (FboOffIgnoreStorageSizeFieldMask & whichField))
+        
_sfFboOffIgnoreStorageSize.syncWith(pOther->_sfFboOffIgnoreStorageSize);
+
 
     if(FieldBits::NoField != (ExcludeNodesFieldMask & whichField))
         _mfExcludeNodes.syncWith(pOther->_mfExcludeNodes, sInfo);
@@ -778,7 +812,7 @@
 
 namespace
 {
-    static Char8 cvsid_cpp       [] = "@(#)$Id: OSGFBOViewportBase.cpp,v 1.2 
2007/08/28 16:06:59 neumannc Exp $";
+    static Char8 cvsid_cpp       [] = "@(#)$Id: FCBaseTemplate_cpp.h,v 1.47 
2006/03/17 17:03:19 pdaehne Exp $";
     static Char8 cvsid_hpp       [] = OSGFBOVIEWPORTBASE_HEADER_CVSID;
     static Char8 cvsid_inl       [] = OSGFBOVIEWPORTBASE_INLINE_CVSID;
 
Index: OSGFBOViewport.fcd
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewport.fcd,v
retrieving revision 1.2
diff -u -r1.2 OSGFBOViewport.fcd
--- OSGFBOViewport.fcd  28 Aug 2007 16:06:59 -0000      1.2
+++ OSGFBOViewport.fcd  4 Sep 2007 17:47:36 -0000
@@ -150,4 +150,14 @@
        >
        whether the render method should ignore CameraDecorators or not
        </Field>
+       <Field
+               name="fboOffIgnoreStorageSize"
+               type="bool"
+               cardinality="single"
+               visibility="external"
+               defaultValue="false"
+               access="public"
+       >
+       whether to ignore storage size in Fbo off mode and just consider window 
size
+       </Field>
 </FieldContainer>
Index: OSGFBOViewport.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewport.cpp,v
retrieving revision 1.13
diff -u -r1.13 OSGFBOViewport.cpp
--- OSGFBOViewport.cpp  4 Sep 2007 14:50:34 -0000       1.13
+++ OSGFBOViewport.cpp  4 Sep 2007 17:51:02 -0000
@@ -837,21 +837,32 @@
                 endEditCP(tiledeco);
                 
                 action->setCamera(tiledeco.getCPtr());
-                
-                for (y1=0; y1 < imgHeight; y1 += winHeight)
+               
+                int totalWidth  = imgWidth; // just behave as before
+                int totalHeight = imgHeight;
+
+                if( getFboOffIgnoreStorageSize() ){
+                    // in this case make sure that the loop below just copies
+                    // the window size content into the attached textures.
+                    // That's useful for boards without NPot extensions
+                    totalWidth  = winWidth;
+                    totalHeight = winHeight;
+                }
+
+                for (y1=0; y1 < totalHeight; y1 += winHeight)
                 {
-                    y2 = osgMin((float)(y1+winHeight-1), (float)(imgHeight-1));
+                    y2 = osgMin((float)(y1+winHeight-1), 
(float)(totalHeight-1));
                     th = y2 - y1 + 1;
                     
-                    for (x1=0; x1 < imgWidth; x1 += winWidth)
+                    for (x1=0; x1 < totalWidth; x1 += winWidth)
                     {
-                        x2 = osgMin((float)(x1+winWidth-1), 
(float)(imgWidth-1));
+                        x2 = osgMin((float)(x1+winWidth-1), 
(float)(totalWidth-1));
                         tw = x2 - x1 + 1;
                         
                         // set tile size to maximal renderable size
                         beginEditCP(tiledeco);
-                            tiledeco->setSize(  x1/(float)imgWidth,     
y1/(float)imgHeight,
-                                            (x2+1)/(float)imgWidth, 
(y2+1)/(float)imgHeight);
+                            tiledeco->setSize(  x1/(float)totalWidth,     
y1/(float)totalHeight,
+                                            (x2+1)/(float)totalWidth, 
(y2+1)/(float)totalHeight);
                         endEditCP(tiledeco);
                         
                         beginEditCP(getPtr(), LeftFieldMask | RightFieldMask |
-------------------------------------------------------------------------
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

Reply via email to