OgreTexture.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _Texture_H__
29 #define _Texture_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreHardwareBuffer.h"
33 #include "OgreResource.h"
34 #include "OgreImage.h"
35 #include "OgreHeaderPrefix.h"
36 
37 namespace Ogre {
38 
48  {
57  TU_AUTOMIPMAP = 0x100,
60  TU_RENDERTARGET = 0x200,
63 
64  };
65 
69  {
82  };
83 
87  {
89  MIP_UNLIMITED = 0x7FFFFFFF,
92  };
93 
103  class _OgreExport Texture : public Resource
104  {
105  public:
106  Texture(ResourceManager* creator, const String& name, ResourceHandle handle,
107  const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
108 
109  virtual ~Texture() {}
110 
113  virtual void setTextureType(TextureType ttype ) { mTextureType = ttype; }
114 
117  virtual TextureType getTextureType(void) const { return mTextureType; }
118 
121  virtual uint8 getNumMipmaps(void) const {return mNumMipmaps;}
122 
127  virtual void setNumMipmaps(uint8 num) {mNumRequestedMipmaps = mNumMipmaps = num;}
128 
133  virtual bool getMipmapsHardwareGenerated(void) const { return mMipmapsHardwareGenerated; }
134 
137  virtual float getGamma(void) const { return mGamma; }
138 
147  virtual void setGamma(float g) { mGamma = g; }
148 
167  virtual void setHardwareGammaEnabled(bool enabled) { mHwGamma = enabled; }
168 
172  virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
173 
181  virtual void setFSAA(uint fsaa, const String& fsaaHint) { mFSAA = fsaa; mFSAAHint = fsaaHint; }
182 
186  virtual uint getFSAA() const { return mFSAA; }
187 
190  virtual const String& getFSAAHint() const { return mFSAAHint; }
191 
194  virtual uint32 getHeight(void) const { return mHeight; }
195 
198  virtual uint32 getWidth(void) const { return mWidth; }
199 
202  virtual uint32 getDepth(void) const { return mDepth; }
203 
206  virtual uint32 getSrcHeight(void) const { return mSrcHeight; }
207 
210  virtual uint32 getSrcWidth(void) const { return mSrcWidth; }
211 
214  virtual uint32 getSrcDepth(void) const { return mSrcDepth; }
215 
218  virtual void setHeight(uint32 h) { mHeight = mSrcHeight = h; }
219 
222  virtual void setWidth(uint32 w) { mWidth = mSrcWidth = w; }
223 
227  virtual void setDepth(uint32 d) { mDepth = mSrcDepth = d; }
228 
231  virtual int getUsage() const
232  {
233  return mUsage;
234  }
235 
243  virtual void setUsage(int u) { mUsage = u; }
244 
256  virtual void createInternalResources(void);
257 
260  virtual void freeInternalResources(void);
261 
264  virtual void copyToTexture( TexturePtr& target );
265 
272  virtual void loadImage( const Image &img );
273 
284  virtual void loadRawData( DataStreamPtr& stream,
285  ushort uWidth, ushort uHeight, PixelFormat eFormat);
286 
292  virtual void _loadImages( const ConstImagePtrList& images );
293 
295  virtual PixelFormat getFormat() const
296  {
297  return mFormat;
298  }
299 
301  virtual PixelFormat getDesiredFormat(void) const
302  {
303  return mDesiredFormat;
304  }
305 
309  virtual PixelFormat getSrcFormat(void) const
310  {
311  return mSrcFormat;
312  }
313 
315  virtual void setFormat(PixelFormat pf);
316 
318  virtual bool hasAlpha(void) const;
319 
325  virtual void setDesiredIntegerBitDepth(ushort bits);
326 
329  virtual ushort getDesiredIntegerBitDepth(void) const;
330 
336  virtual void setDesiredFloatBitDepth(ushort bits);
337 
340  virtual ushort getDesiredFloatBitDepth(void) const;
341 
344  virtual void setDesiredBitDepths(ushort integerBits, ushort floatBits);
345 
348  virtual void setTreatLuminanceAsAlpha(bool asAlpha);
349 
352  virtual bool getTreatLuminanceAsAlpha(void) const;
353 
357  virtual size_t getNumFaces() const;
358 
371  virtual HardwarePixelBufferSharedPtr getBuffer(size_t face=0, size_t mipmap=0) = 0;
372 
373 
378  virtual void convertToImage(Image& destImage, bool includeMipMaps = false);
379 
385  virtual void getCustomAttribute(const String& name, void* pData) {}
386 
387 
388 
389  protected:
393 
397  float mGamma;
398  bool mHwGamma;
401 
404  int mUsage;
405 
407  uint32 mSrcWidth, mSrcHeight, mSrcDepth;
408 
410  unsigned short mDesiredIntegerBitDepth;
411  unsigned short mDesiredFloatBitDepth;
413 
415 
417  size_t calculateSize(void) const;
418 
419 
422  virtual void createInternalResourcesImpl(void) = 0;
423 
426  virtual void freeInternalResourcesImpl(void) = 0;
427 
429  void unloadImpl(void);
430 
434  String getSourceFileType() const;
435 
436  };
440 }
441 
442 #include "OgreHeaderSuffix.h"
443 
444 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:46