changed: gcc8 base update
[opensg.git] / Source / System / Window / Background / OSGFBOBackground.cpp
blobe216362b686f46abc23b461e8bdfed5ddad7fbf3
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <stdlib.h>
44 #include <stdio.h>
46 #include "OSGConfig.h"
48 #include "OSGGL.h"
49 #include "OSGGLFuncProtos.h"
51 #include "OSGFieldContainer.h"
52 #include "OSGNode.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"
61 OSG_BEGIN_NAMESPACE
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 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::FBOBackground
80 \ingroup GrpSystemWindowBackgrounds
82 A FBO background, see \ref PageSystemWindowBackgroundFBO for a
83 description.
86 /***************************************************************************\
87 * Class methods *
88 \***************************************************************************/
90 /*-------------------------------------------------------------------------*\
91 - private -
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 /***************************************************************************\
118 * Instance methods *
119 \***************************************************************************/
121 FBOBackground::FBOBackground(void) :
122 Inherited()
126 FBOBackground::FBOBackground(const FBOBackground &source) :
127 Inherited(source)
131 FBOBackground::~FBOBackground(void)
135 void FBOBackground::changed(ConstFieldMaskArg whichField,
136 UInt32 origin,
137 BitVector details)
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,
153 win );
155 OSGGETGLFUNCBYID_GL3( glBlitFramebuffer,
156 osgGlBlitFramebuffer,
157 _uiFuncBlitFramebuffer,
158 win );
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),
178 GL_NEAREST);
180 if(pEnv->getActiveFBO() != 0)
182 osgGlBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
183 win->getGLObjectId(pEnv->getActiveFBO()));
185 else
187 osgGlBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
188 0 );
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;
201 OSG_END_NAMESPACE