Torque3D Documentation / _generateds / gfxGLTextureObject.h

gfxGLTextureObject.h

Engine/source/gfx/gl/gfxGLTextureObject.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _GFXGLTEXTUREOBJECT_H
 25#define _GFXGLTEXTUREOBJECT_H
 26
 27#include "gfx/gfxTextureObject.h"
 28#include "gfx/gl/tGL/tGL.h"
 29#include "gfx/gfxStateBlock.h"
 30
 31class GFXGLDevice;
 32
 33class GFXGLTextureObject : public GFXTextureObject 
 34{
 35public:
 36   GFXGLTextureObject(GFXDevice * aDevice, GFXTextureProfile *profile); 
 37   ~GFXGLTextureObject();
 38   
 39   void release();
 40   void reInit();
 41   
 42   inline GLuint getHandle() const { return mHandle; }
 43   inline GLenum getBinding() const { return mBinding; }
 44   inline GLuint getBuffer() const { return mBuffer; }
 45   
 46   inline bool isZombie() const { return mIsZombie; }
 47
 48   /// Binds the texture to the given texture unit
 49   /// and applies the current sampler state because GL tracks
 50   /// filtering and wrapper per object, while GFX tracks per sampler.
 51   void bind(U32 textureUnit);
 52   
 53   /// @return An array containing the texture data
 54   /// @note You are responsible for deleting the returned data! (Use delete[])
 55   U8* getTextureData( U32 mip = 0);
 56
 57   virtual F32 getMaxUCoord() const;
 58   virtual F32 getMaxVCoord() const;
 59   
 60   void reloadFromCache(); ///< Reloads texture from zombie cache, used by GFXGLTextureManager to resurrect the texture.
 61   
 62#ifdef TORQUE_DEBUG
 63   virtual void pureVirtualCrash() {}
 64#endif
 65
 66   /// Get/set data from texture (for dynamic textures and render targets)
 67   /// @attention DO NOT READ FROM THE RETURNED RECT! It is not guaranteed to work and may incur significant performance penalties.
 68   virtual GFXLockedRect* lock(U32 mipLevel = 0, RectI *inRect = NULL);
 69   virtual void unlock(U32 mipLevel = 0 );
 70
 71   virtual bool copyToBmp(GBitmap *); ///< Not implemented
 72   
 73   bool mIsNPoT2;
 74
 75   // GFXResource interface
 76   virtual void zombify();
 77   virtual void resurrect();
 78   virtual const String describeSelf() const;
 79
 80   void initSamplerState(const GFXSamplerStateDesc &ssd);
 81   
 82private:
 83   friend class GFXGLTextureManager;
 84   typedef GFXTextureObject Parent;
 85   /// Internal GL object
 86   GLuint mHandle;
 87   GLuint mBuffer;
 88   bool mNeedInitSamplerState;
 89   GFXSamplerStateDesc mSampler;
 90   GLenum mBinding;
 91   
 92   U32 mBytesPerTexel;
 93   GFXLockedRect mLockedRect;
 94   RectI mLockedRectRect;
 95
 96   /// Pointer to owner device
 97   GFXGLDevice* mGLDevice;
 98   
 99   bool mIsZombie;
100   U8* mZombieCache;
101   
102   void copyIntoCache();
103
104   //FrameAllocator
105   U32 mFrameAllocatorMark;
106#if TORQUE_DEBUG
107   U32 mFrameAllocatorMarkGuard;
108#endif
109   U8 *mFrameAllocatorPtr;
110};
111
112#endif
113