1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
49 #include "OSGGLFuncProtos.h"
51 #include "OSGFieldContainer.h"
53 #include "OSGAction.h"
54 #include "OSGViewport.h"
55 #include "OSGCamera.h"
56 #include "OSGWindow.h"
57 #include "OSGBackground.h"
58 #include "OSGFBOBackground.h"
59 #include "OSGFrameBufferObject.h"
63 UInt32
FBOBackground::_uiFramebufferObjectExt
=
64 Window::invalidExtensionID
;
66 UInt32
FBOBackground::_uiFramebufferBlitExt
=
67 Window::invalidExtensionID
;
69 UInt32
FBOBackground::_uiFuncBindFramebuffer
=
70 Window::invalidFunctionID
;
72 UInt32
FBOBackground::_uiFuncBlitFramebuffer
=
73 Window::invalidFunctionID
;
75 /***************************************************************************\
77 \***************************************************************************/
79 /*! \class OSG::FBOBackground
80 \ingroup GrpSystemWindowBackgrounds
82 A FBO background, see \ref PageSystemWindowBackgroundFBO for a
86 /***************************************************************************\
88 \***************************************************************************/
90 /*-------------------------------------------------------------------------*\
92 \*-------------------------------------------------------------------------*/
94 void FBOBackground::initMethod (InitPhase ePhase
)
96 Inherited::initMethod(ePhase
);
98 if(ePhase
== TypeObject::SystemPost
)
100 _uiFramebufferObjectExt
=
101 Window::registerExtension("GL_EXT_framebuffer_object");
102 _uiFramebufferBlitExt
=
103 Window::registerExtension("GL_EXT_framebuffer_blit");
105 _uiFuncBindFramebuffer
=
106 Window::registerFunction (
107 OSG_DLSYM_UNDERSCORE
"glBindFramebufferEXT",
108 _uiFramebufferObjectExt
);
110 _uiFuncBlitFramebuffer
=
111 Window::registerFunction (
112 OSG_DLSYM_UNDERSCORE
"glBlitFramebufferEXT",
113 _uiFramebufferBlitExt
);
117 /***************************************************************************\
119 \***************************************************************************/
121 FBOBackground::FBOBackground(void) :
126 FBOBackground::FBOBackground(const FBOBackground
&source
) :
131 FBOBackground::~FBOBackground(void)
135 void FBOBackground::changed(ConstFieldMaskArg whichField
,
139 Inherited::changed(whichField
, origin
, details
);
142 /*-------------------------- your_category---------------------------------*/
144 void FBOBackground::clear(DrawEnv
*pEnv
)
146 if(_sfFrameBufferObject
.getValue() != NULL
)
148 Window
*win
= pEnv
->getWindow();
150 OSGGETGLFUNCBYID_GL3_ES( glBindFramebuffer
,
151 osgGlBindFramebuffer
,
152 _uiFuncBindFramebuffer
,
155 OSGGETGLFUNCBYID_GL3( glBlitFramebuffer
,
156 osgGlBlitFramebuffer
,
157 _uiFuncBlitFramebuffer
,
160 osgGlBindFramebuffer(
161 GL_READ_FRAMEBUFFER_EXT
,
162 win
->getGLObjectId(_sfFrameBufferObject
.getValue()->getGLId()));
164 osgGlBlitFramebuffer(
167 _sfFrameBufferObject
.getValue()->getWidth (),
168 _sfFrameBufferObject
.getValue()->getHeight(),
170 pEnv
->getPixelLeft (),
171 pEnv
->getPixelBottom(),
172 pEnv
->getPixelRight () + 1,
173 pEnv
->getPixelTop () + 1,
175 (GL_COLOR_BUFFER_BIT
|
176 GL_DEPTH_BUFFER_BIT
|
177 GL_STENCIL_BUFFER_BIT
),
180 if(pEnv
->getActiveFBO() != 0)
182 osgGlBindFramebuffer(GL_READ_FRAMEBUFFER_EXT
,
183 win
->getGLObjectId(pEnv
->getActiveFBO()));
187 osgGlBindFramebuffer(GL_READ_FRAMEBUFFER_EXT
,
193 /*------------------------------- dump ----------------------------------*/
195 void FBOBackground::dump( UInt32
OSG_CHECK_ARG(uiIndent
),
196 const BitVector
OSG_CHECK_ARG(bvFlags
)) const
198 SLOG
<< "Dump FBOBackground NI" << std::endl
;