Back to index

nux  3.0.0
IOpenGLRectangleTexture.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef IOPENGLRECTANGLETEXTURE_H
00024 #define IOPENGLRECTANGLETEXTURE_H
00025 
00026 namespace nux
00027 {
00028 
00029   class IOpenGLBaseTexture;
00030   class IOpenGLRectangleTexture: public IOpenGLBaseTexture
00031   {
00032     NUX_DECLARE_OBJECT_TYPE(IOpenGLRectangleTexture, IOpenGLBaseTexture);
00033 
00034   public:
00035     virtual ~IOpenGLRectangleTexture();
00036 
00037     void GetSurfaceLevel(int Level, ObjectPtr<IOpenGLSurface>& surface);
00038     ObjectPtr<IOpenGLSurface> GetSurfaceLevel(int Level);
00039 
00040     int LockRect(
00041       int Level,
00042       SURFACE_LOCKED_RECT *pLockedRect,
00043       const SURFACE_RECT *pRect);
00044 
00045     int UnlockRect(
00046       int Level
00047     );
00048     unsigned int EnableGammaCorrection(bool b);
00049 
00050     int GetLevelDesc(
00051       int Level,
00052       SURFACE_DESC *pDesc
00053     )
00054     {
00055       nuxAssert(Level >= 0);
00056       nuxAssert(Level < _NumMipLevel);
00057 
00058       if ((Level < 0) || (Level > _NumMipLevel))
00059       {
00060         pDesc->Width    = 0;
00061         pDesc->Height   = 0;
00062         pDesc->PixelFormat = BITFMT_UNKNOWN;
00063         pDesc->Type     = _ResourceType;
00064       }
00065       else
00066       {
00067         pDesc->Width    = Max<unsigned int> (1, _Width >> Level);
00068         pDesc->Height   = Max<unsigned int> (1, _Height >> Level);
00069         pDesc->PixelFormat = _PixelFormat;
00070         pDesc->Type     = _ResourceType;
00071       }
00072 
00073       return OGL_OK;;
00074     }
00075 
00077 
00088     unsigned char* GetSurfaceData(int level, int &width, int &height, int &stride);
00089 
00090   private:
00091 
00092     // The Dummy boolean is used to create a skeletal frame for the default
00093     // render target texture and surface; Only GpuDevice uses it in its constructor.
00094     // Do not use it otherwise!!!
00095 
00096     IOpenGLRectangleTexture(
00097       unsigned int Width
00098       , unsigned int Height
00099       , unsigned int Levels
00100       , BitmapFormat PixelFormat, bool Dummy = false, NUX_FILE_LINE_PROTO);
00101 
00102     //    unsigned int        _Width;
00103     //    unsigned int        _Height;
00104     std::vector< ObjectPtr<IOpenGLSurface> > _SurfaceArray;
00105     friend class GpuDevice;
00106     friend class IOpenGLSurface;
00107   };
00108 
00109 }
00110 
00111 #endif // IOPENGLRECTANGLETEXTURE_H