nux-0.9.46
|
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 IOPENGLANIMATEDTEXTURE_H 00024 #define IOPENGLANIMATEDTEXTURE_H 00025 00026 namespace nux 00027 { 00028 00029 class IOpenGLBaseTexture; 00030 00031 // Note that for Animated texture, the Depth value is the number of frames. 00032 // The number of mipmap levels is always 1; 00033 class IOpenGLAnimatedTexture: public IOpenGLBaseTexture 00034 { 00035 NUX_DECLARE_OBJECT_TYPE (IOpenGLAnimatedTexture, IOpenGLBaseTexture); 00036 00037 public: 00038 virtual ~IOpenGLAnimatedTexture(); 00039 00040 void GetSurfaceFrame (int Frame, ObjectPtr<IOpenGLSurface>& surface); 00041 ObjectPtr<IOpenGLSurface> GetSurfaceFrame (int Level); 00042 00043 int LockRect ( 00044 int Frame, 00045 SURFACE_LOCKED_RECT *pLockedRect, 00046 const SURFACE_RECT *pRect); 00047 00048 int UnlockRect ( 00049 int Frame 00050 ); 00051 00052 int GetDepth (int MipLevel) const 00053 { 00054 return _Depth; 00055 } 00056 00057 int GetDesc (ANIMATEDTEXTURE_DESC *pDesc) 00058 { 00059 pDesc->Width = Max<int> (1, _Width); 00060 pDesc->Height = Max<int> (1, _Height); 00061 pDesc->Depth = _Depth; 00062 pDesc->PixelFormat = _PixelFormat; 00063 pDesc->Type = _ResourceType; 00064 return OGL_OK; 00065 } 00066 00067 void PresentFirstFrame(); 00068 void PresentNextFrame(); 00069 void PresentLastFrame(); 00070 int GetFrameTime(); 00071 t_u32 GetNumFrame(); 00072 void SetFrameTime (int Frame, int time_ms); 00073 00074 private: 00075 IOpenGLAnimatedTexture ( 00076 int Width 00077 , int Height 00078 , int Depth 00079 , BitmapFormat PixelFormat); 00080 00081 // unsigned int _Width; 00082 // unsigned int _Height; 00083 // unsigned int _Depth; 00084 //std::vector<IOpenGLSurface*> _VolumeArray; 00085 00086 int _CurrentFrame; 00087 std::vector< ObjectPtr<IOpenGLBaseTexture> > _FrameTextureArray; 00088 00089 std::vector< int > _FrameTimeArray; 00090 00091 friend class GpuDevice; 00092 friend class IOpenGLSurface; 00093 }; 00094 } 00095 00096 #endif // IOPENGLANIMATEDTEXTURE_H