00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00015 #include "nvsgcommon.h"
00016
00017 #include "nvutil/RCObject.h"
00018 #include "nvsg/DAL.h"
00019
00020 namespace nvsg
00021 {
00022
00023
00025
00030 class Texture : public nvutil::RCObject
00031 , public DALHost
00032 {
00033 public:
00035 typedef enum
00036 {
00037 TFT_UNKNOWN = -1
00038 , TFT_DDS
00039 , TFT_JPG
00040 , TFT_TGA
00041 , TFT_BMP
00042 , TFT_TIF
00043 , TFT_RGB
00044 , TFT_GIF
00045 , TFT_PNG
00046 , TFT_HDR
00047
00048 } eTexFileType;
00049
00050 public:
00052 NVSG_API static const Texture * create( const std::string &fileName
00053 , bool flipImage = true
00054 );
00055
00057
00058 NVSG_API int getComponents( unsigned int image = 0
00059 , unsigned int mipmap = 0
00060 ) const;
00061
00063
00064 NVSG_API int getType( unsigned int image = 0
00065 , unsigned int mipmap = 0
00066 ) const;
00067
00069
00070 NVSG_API int getDepth( unsigned int image = 0
00071 , unsigned int mipmap = 0
00072 ) const;
00073
00075
00076 NVSG_API int getFormat( unsigned int image = 0
00077 , unsigned int mipmap = 0
00078 ) const;
00080
00081 std::string getFileName( void ) const;
00082
00084
00086 unsigned int getHandle( void ) const;
00087
00089
00090 NVSG_API int getHeight( unsigned int image = 0
00091 , unsigned int mipmap = 0
00092 ) const;
00093
00095
00096 unsigned int getNumberOfImages( void ) const;
00097
00099
00100 NVSG_API unsigned int getNumberOfMipmaps( unsigned int image = 0
00101 ) const;
00102
00104
00105 NVSG_API const void * getPixels( unsigned int image = 0
00106 , unsigned int mipmap = 0
00107 ) const;
00108
00110
00111 NVSG_API int getSize( unsigned int image = 0
00112 , unsigned int mipmap = 0
00113 ) const;
00114
00116
00118 NVSG_API unsigned long getTarget( void ) const;
00119
00121
00122 NVSG_API int getWidth( unsigned int image = 0
00123 , unsigned int mipmap = 0
00124 ) const;
00125
00127
00128 NVSG_API bool isCubeMap( void ) const;
00129
00131
00132 NVSG_API bool isFloatingPoint( void ) const;
00133
00135
00136 NVSG_API bool isTexFileType( eTexFileType tft
00137 ) const;
00138
00140
00141 NVSG_API bool load( void ) const;
00142
00144 NVSG_API void scale( unsigned int image = 0
00145
00146
00147 , unsigned int width = 128
00148 , unsigned int height = 128
00149 , unsigned int depth = 1
00150 ) const;
00151
00153 NVSG_API void setHandle( unsigned int handle
00154 ) const;
00155
00157
00158 NVSG_API void setTarget( unsigned long target
00159 ) const;
00160
00162 NVSG_API void unload( void ) const;
00163
00164 protected:
00166
00167 NVSG_API Texture( const std::string& fileName, bool flipImage = true );
00168
00170 NVSG_API virtual ~Texture( void );
00171
00172 protected:
00173 mutable bool m_cube;
00174 std::string m_fileName;
00175 bool m_flipImage;
00176 mutable unsigned int m_handle;
00177 mutable unsigned int m_imageID;
00178 mutable unsigned int m_numImages;
00179 mutable unsigned long m_target;
00180 mutable eTexFileType m_texFileType;
00181
00182 private:
00183
00184 Texture( const Texture& rhs );
00185 };
00186
00187 inline std::string Texture::getFileName( void ) const
00188 {
00189 __TRACE();
00190 return( m_fileName );
00191 }
00192 inline unsigned int Texture::getHandle( void ) const
00193 {
00194 __TRACE();
00195 return( m_handle );
00196 }
00197
00198 inline bool Texture::isCubeMap() const
00199 {
00200 __TRACE();
00201 return m_cube;
00202 }
00203
00204 inline bool Texture::isTexFileType( eTexFileType tft ) const
00205 {
00206 __TRACE();
00207 return( m_texFileType == tft );
00208 }
00209
00210 inline unsigned int Texture::getNumberOfImages( void ) const
00211 {
00212 __TRACE();
00213 return m_numImages;
00214 }
00215
00216 inline void Texture::setHandle( unsigned int handle ) const
00217 {
00218 __TRACE();
00219 m_handle = handle;
00220 }
00221
00222 inline void Texture::setTarget( unsigned long target ) const
00223 {
00224 __TRACE();
00225 m_target = target;
00226 }
00227
00228 inline unsigned long Texture::getTarget( void ) const
00229 {
00230 __TRACE();
00231 return( m_target );
00232 }
00233
00234 }