Texture3D.h 7.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
/*
 *	(c) LSIIT, UMR CNRS/UdS
 *	Authors: F. Larue.
 *
 *	See licence.txt for additional information.
 */


#ifndef __GPU__TEXTURE3D_H__
#define __GPU__TEXTURE3D_H__




#include "GPUdefs.h"
#include "InstantiatedObject.h"
#include <map>
#include <vector>
#include "Texture2D.h"


/*
 *
 *  CLASS DECLARATION.
 *
 */

namespace GPU
{
    class Texture3D : public InstantiatedObject, public Texture
    {
        /********************\
        | Member variable(s) |
        \********************/
    private:
        unsigned int        m_Width;
        unsigned int        m_Height;
        unsigned int        m_Depth;

        /*****************************\
        | Constructor(s) / destructor |
        \*****************************/
    public:
        inline              Texture3D() : InstantiatedObject(), Texture(GL_TEXTURE_3D), m_Width(0), m_Height(0), m_Depth(0) {}
        inline              ~Texture3D()                                    { Release(); }

        /********************\
        | Member function(s) |
        \********************/
    protected:
        bool                Allocate();
        bool                Unallocate();

    public:
        bool                Create();
        inline bool         Create( GLenum internalFormat,
                                    GLsizei width,
                                    GLsizei height,
                                    GLsizei depth,
                                    GLint border,
                                    GLenum format,
                                    GLenum type,
                                    const GLvoid* data )    { GLenum f[] = {internalFormat,GL_NONE}; return Create(f,width,height,depth,border,format,type,data); }
        bool                Create( GLenum internalFormats[],
                                    GLsizei width,
                                    GLsizei height,
                                    GLsizei depth,
                                    GLint border,
                                    GLenum format,
                                    GLenum type,
                                    const GLvoid* data );
        inline bool         Create( GLenum internalFormat,
                                    GLsizei width,
                                    GLsizei height,
                                    GLsizei depth,
                                    GLenum format,
                                    GLenum type,
                                    const GLvoid* data )    { return Create(internalFormat,width,height,depth,0,format,type,data); }
        inline bool         Create( GLenum internalFormats[],
                                    GLsizei width,
                                    GLsizei height,
                                    GLsizei depth,
                                    GLenum format,
                                    GLenum type,
                                    const GLvoid* data )    { return Create(internalFormats,width,height,depth,0,format,type,data); }
        inline bool         Create( GLenum internalFormat,
                                    GLsizei width,
                                    GLsizei height,
                                    GLsizei depth )         { return Create(internalFormat,width,height,depth,0,GL_RGB,GL_INT,NULL); }
        inline bool         Create( GLenum internalFormats[],
                                    GLsizei width,
                                    GLsizei height,
                                    GLsizei depth )         { return Create(internalFormats,width,height,depth,0,GL_RGB,GL_INT,NULL); };

        inline bool         Load( GLenum internalFormat,
                                  GLsizei width,
                                  GLsizei height,
                                  GLsizei depth,
                                  GLint border,
                                  GLenum format,
                                  GLenum type,
                                  const GLvoid* data,
                                  GLint level = 0 )         { GLenum f[] = {internalFormat,GL_NONE}; return Load(f,width,height,depth,border,format,type,data,level); }
        bool                Load( GLenum internalFormats[],
                                  GLsizei width,
                                  GLsizei height,
                                  GLsizei depth,
                                  GLint border,
                                  GLenum format,
                                  GLenum type,
                                  const GLvoid* data,
                                  GLint level = 0 );
        inline bool         Load( GLenum internalFormat,
                                  GLsizei width,
                                  GLsizei height,
                                  GLsizei depth,
                                  GLenum format,
                                  GLenum type,
                                  const GLvoid* data,
                                  GLint level = 0 )         { return Load(internalFormat,width,height,depth,0,format,type,data,level); }
        inline bool         Load( GLenum internalFormats[],
                                  GLsizei width,
                                  GLsizei height,
                                  GLsizei depth,
                                  GLenum format,
                                  GLenum type,
                                  const GLvoid* data,
                                  GLint level = 0 )         { return Load(internalFormats,width,height,depth,0,format,type,data,level); }
        inline bool         Load( GLenum internalFormat,
                                  GLsizei width,
                                  GLsizei height,
                                  GLsizei depth,
                                  GLint level = 0 )         { return Load(internalFormat,width,height,depth,0,GL_RGB,GL_INT,NULL,level); }
        inline bool         Load( GLenum internalFormats[],
                                  GLsizei width,
                                  GLsizei height,
                                  GLsizei depth,
                                  GLint level = 0 )         { return Load(internalFormats,width,height,depth,0,GL_RGB,GL_INT,NULL,level); }

        bool                LoadSlice( GLsizei sliceDepth,
                                       GLenum format,
                                       GLenum type,
                                       const GLvoid* data,
                                       GLint level = 0 );

        inline unsigned int Width() const                                       { return m_Width; }
        inline unsigned int Height() const                                      { return m_Height; }
        inline unsigned int Depth() const                                       { return m_Depth; }
        //unsigned int        RealWidth() const;
        //unsigned int        RealHeight() const;
        //unsigned int        RealDepth() const;

#if 0
        bool                DumpTo( void *buffer,
                                    const GLenum format,
                                    const GLenum type,
                                    const GLint level = 0 ) const;
        bool                DumpTo( void *buffer,
                                    const unsigned int x,
                                    const unsigned int y,
                                    const unsigned int w,
                                    const unsigned int h,
                                    const GLenum format,
                                    const GLenum type,
                                    const GLint level = 0 ) const;

        GPU::Texture3D      Clone() const;
#endif
    };
};




#endif //__GPU__TEXTURE3D_H__