/* osgCompute - Copyright (C) 2008-2009 SVT Group
*                                                                     
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*                                                                     
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesse General Public License for more details.
*
* The full license is in LICENSE file included with this distribution.
*/

#ifndef OSGCUDA_TEXTURE3D
#define OSGCUDA_TEXTURE3D 1

#include <osg/Texture3D>
#include <osgCuda/Texture>

namespace osgCuda
{
    /**
    */
    class LIBRARY_EXPORT Texture3D : public Texture, public osg::Texture3D
    {
    public:
        Texture3D();

        META_Texture( osgCuda, Texture3D )

        virtual bool init();

        virtual void apply(osg::State& state) const;
        virtual void releaseGLObjects(osg::State* state=0) const;

        virtual osg::Image* getImagePtr();
        virtual const osg::Image* getImagePtr() const;

        virtual void clear();
    protected:
        virtual ~Texture3D();
        void clearLocal();

        virtual bool initDimension();

		virtual void syncModifiedCounter( const osgCompute::Context& context ) const;
        virtual bool allocPBO( TextureStream& stream ) const;
        virtual void syncPBO( TextureStream& stream ) const;
        virtual void syncTexture( TextureStream& stream ) const;

        virtual osgCompute::BufferStream* newStream( const osgCompute::Context& context ) const;
    private:
        // copy constructor and operator should not be called
        Texture3D( const Texture3D& , const osg::CopyOp& ) {}
        Texture3D& operator=(const Texture3D&) { return (*this); }
    };
}


#endif //OSGCUDA_TEXTURE3D
