LCOV - code coverage report
Current view: top level - eq/util - frameBufferObject.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 0 9 0.0 %
Date: 2016-07-30 05:04:55 Functions: 0 8 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2015, Cedric Stalder <cedric.stalder@gmail.com>
       3             :  *                          Stefan Eilemann <eile@equalizergraphics.com>
       4             :  *                          Daniel Nachbaur <danielnachbaur@gmail.com>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQUTIL_FRAMEBUFFEROBJECT_H
      21             : #define EQUTIL_FRAMEBUFFEROBJECT_H
      22             : 
      23             : #include <eq/util/texture.h> // member
      24             : #include <eq/util/types.h>
      25             : 
      26             : #include <vector>
      27             : 
      28             : namespace eq
      29             : {
      30             : namespace util
      31             : {
      32             : /** A C++ class to abstract OpenGL frame buffer objects */
      33             : class FrameBufferObject
      34             : {
      35             : public:
      36             :     /**
      37             :      * Construct a new Frame Buffer Object. The first color texture is
      38             :      * automatically created.
      39             :      * @version 1.0
      40             :      */
      41             :     EQ_API FrameBufferObject( const GLEWContext* const glewContext,
      42             :                               const unsigned textureTarget = 0x84F5
      43             :                               /*GL_TEXTURE_RECTANGLE_ARB*/ );
      44             : 
      45             :     /** Destruct the Frame Buffer Object. @version 1.0 */
      46             :     EQ_API ~FrameBufferObject();
      47             : 
      48             :     /**
      49             :      * Add one color texture to the FBO.
      50             :      *
      51             :      * The maximum number of textures per FBO is 16. Added color textures will
      52             :      * have the same format as the existing texture(s). This method has to be
      53             :      * called on an uninitialized FBO.
      54             :      *
      55             :      * @return false if color texture can't be added, otherwise true.
      56             :      * @version 1.0
      57             :      */
      58             :     EQ_API bool addColorTexture();
      59             : 
      60             :     /**
      61             :      * Initialize the Frame Buffer Object.
      62             :      *
      63             :      * On successful initialization, the FBO is bound.
      64             :      *
      65             :      * @param width the initial width of the rendering buffer.
      66             :      * @param height the initial height of the rendering buffer.
      67             :      * @param colorFormat The internal color texture format, e.g., GL_RGBA.
      68             :      * @param depthSize The bit depth of the depth attachment.
      69             :      * @param stencilSize The bit depth of the stencil attachment.
      70             :      * @param samplesSize The number of multisamples.
      71             :      * @return ERROR_NONE on success, Error code on failure.
      72             :      * @sa resize()
      73             :      * @version 1.0
      74             :      */
      75             :     EQ_API Error init( const int32_t width, const int32_t height,
      76             :                        const unsigned colorFormat, const int32_t depthSize,
      77             :                        const int32_t stencilSize,
      78             :                        const int32_t samplesSize = 1 );
      79             : 
      80             :     /** De-initialize the Frame Buffer Object. @version 1.0 */
      81             :     EQ_API void exit();
      82             : 
      83             :     /**
      84             :      * Bind to the Frame Buffer Object.
      85             :      *
      86             :      * The FBO becomes the read and/or draw buffer of the current context,
      87             :      * depending on the given target.
      88             :      * @param target the framebuffer target to bind, default read and draw
      89             :      * @version 1.0
      90             :      */
      91             :     EQ_API void bind( const uint32_t target = 0x8D40 /*GL_FRAMEBUFFER_EXT*/ );
      92             : 
      93             :     /**
      94             :      * Unbind any Frame Buffer Object and use the default drawable for the
      95             :      * current context.
      96             :      * @param target the framebuffer target to unbind, default read and draw
      97             :      * @version 1.0
      98             :      */
      99             :     EQ_API void unbind( const uint32_t target = 0x8D40 /*GL_FRAMEBUFFER_EXT*/ );
     100             : 
     101             :     /**
     102             :      * Resize the FBO.
     103             :      *
     104             :      * The FBO has to be initialized and bound. It is not changed if the size
     105             :      * does not change.
     106             :      *
     107             :      * @return true on success, false on error.
     108             :      * @return ERROR_NONE on success, Error code on failure.
     109             :      * @version 1.0
     110             :      */
     111             :     EQ_API Error resize( const int32_t width, const int32_t height );
     112             : 
     113             :     /** @return the current width. @version 1.0 */
     114           0 :     int32_t getWidth() const
     115           0 :         { LBASSERT( !_colors.empty( )); return _colors.front()->getWidth();}
     116             : 
     117             :     /** @return the current height. @version 1.0 */
     118           0 :     int32_t getHeight() const
     119           0 :         { LBASSERT( !_colors.empty()); return _colors.front()->getHeight();}
     120             : 
     121             :     /** @return the vector of color textures. @version 1.0 */
     122           0 :     const Textures& getColorTextures() const { return _colors; }
     123             : 
     124             :     /** @return the depth texture. @version 1.0 */
     125           0 :     const Texture& getDepthTexture() const { return _depth; }
     126             : 
     127             :     /** @return the GLEW context. @version 1.0 */
     128           0 :     const GLEWContext* glewGetContext() const { return _glewContext; }
     129             : 
     130             :     /** @return true if the fbo is valid. @version 1.0 */
     131           0 :     bool isValid() const { return _valid; }
     132             : 
     133             : private:
     134             :     unsigned _fboID; //!< the FBO GL name
     135             : 
     136             :     Textures _colors; //!< Multiple color textures
     137             :     Texture _depth;
     138             : 
     139             :     const GLEWContext* const _glewContext;
     140             : 
     141             :     bool _valid;
     142             : 
     143           0 :     LB_TS_VAR( _thread );
     144             : 
     145             :     /** Check the result after changes to an FBO and set the _valid flag. */
     146             :     Error _checkStatus();
     147             : };
     148             : }
     149             : }
     150             : 
     151             : #endif // EQUTIL_FRAMEBUFFEROBJECT_H

Generated by: LCOV version 1.11