Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_RENDERSYSTEM_TEXTURE_H__
00009 #define __SP_RENDERSYSTEM_TEXTURE_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spDimension.hpp"
00014 #include "Base/spInputOutputString.hpp"
00015 #include "Base/spImageManagement.hpp"
00016 #include "Base/spImageBuffer.hpp"
00017 #include "Base/spBaseObject.hpp"
00018 #include "Base/spMath.hpp"
00019 #include "Base/spMaterialColor.hpp"
00020 #include "Base/spImageBufferUByte.hpp"
00021 #include "Base/spImageBufferFloat.hpp"
00022 #include "RenderSystem/spTextureFlags.hpp"
00023
00024
00025 namespace sp
00026 {
00027 namespace video
00028 {
00029
00030
00037 class SP_EXPORT Texture : public BaseObject
00038 {
00039
00040 public:
00041
00042 Texture();
00043 Texture(const STextureCreationFlags &CreationFlags);
00044 virtual ~Texture();
00045
00047 virtual bool valid() const;
00048
00050 virtual void saveBackup();
00052 virtual void loadBackup();
00054 virtual void clearBackup();
00055
00060 virtual void setRenderTarget(bool Enable);
00061
00070 virtual bool setDimension(const ETextureDimensions Type, s32 Depth = 1);
00071
00076 virtual void setCubeMapFace(const ECubeMapDirections Face);
00077
00079 virtual void setArrayLayer(u32 Layer);
00080
00085 virtual void addMultiRenderTarget(Texture* Tex);
00086
00088 virtual void removeMultiRenderTarget(Texture* Tex);
00089
00091 virtual void clearMultiRenderTarget();
00092
00098 virtual void setDepthBufferSource(Texture* DepthBufferSourceTexture);
00099
00101 virtual void setHardwareFormat(const EHWTextureFormats HardwareFormat);
00111 virtual void setMipMapping(bool MipMaps);
00112
00114 virtual bool shareImageBuffer();
00115
00117 virtual bool updateImageBuffer();
00118
00120 virtual bool updateImageBuffer(const dim::point2di &Pos, const dim::size2di &Size);
00121
00123 virtual bool setupImageBuffer(const void* NewImageBuffer);
00124
00126 virtual bool setupImageBuffer(const ImageBuffer* NewImageBuffer);
00127
00129 virtual bool setupImageBuffer(const ImageBuffer* SubImageBuffer, const dim::point2di &Position, const dim::size2di &Size);
00130
00132 virtual void generateMipMap();
00133
00134 virtual void bind(s32 Level = 0) const;
00135 virtual void unbind(s32 Level = 0) const;
00136
00138 virtual void addAnimFrame(Texture* AnimFrame);
00139 virtual void removeAnimFrame(Texture* AnimFrame);
00140
00142 virtual void setAnimation(bool Enable);
00143
00145 virtual void setAnimFrame(u32 Frame);
00146
00154 virtual void setFilter(const ETextureFilters Filter);
00155 virtual void setFilter(const ETextureFilters MagFilter, const ETextureFilters MinFilter);
00156 virtual void setMagFilter(const ETextureFilters Filter);
00157 virtual void setMinFilter(const ETextureFilters Filter);
00158
00166 virtual void setMipMapFilter(const ETextureMipMapFilters MipMapFilter);
00167
00173 virtual void setWrapMode(const ETextureWrapModes Wrap);
00174 virtual void setWrapMode(
00175 const ETextureWrapModes WrapU, const ETextureWrapModes WrapV, const ETextureWrapModes WrapW = TEXWRAP_REPEAT
00176 );
00177
00179 virtual void setMultiSamples(s32 Samples);
00180
00188 void setFormat(const EPixelFormats Format);
00189
00197 void setSize(const dim::size2di &Size);
00198
00206 void setColorKey(const color &Color, u8 Tolerance = 0);
00207 void setColorKey(const dim::point2di &Pos, u8 Alpha = 0, u8 Tolerance = 0);
00208 void setColorKeyAlpha(const EAlphaBlendingTypes Mode = BLENDING_BRIGHT);
00209 void setColorKeyMask(ImageBuffer* MaskImage, const EAlphaBlendingTypes Mode = BLENDING_BRIGHT);
00210
00218 void ensurePOT();
00219
00220
00221
00223 inline void setFilename(const io::stringc &Filename)
00224 {
00225 Filename_ = Filename;
00226 }
00228 inline io::stringc getFilename() const
00229 {
00230 return Filename_;
00231 }
00232
00234 inline EPixelFormats getFormat() const
00235 {
00236 return ImageBuffer_->getFormat();
00237 }
00239 inline dim::size2di getSize() const
00240 {
00241 return ImageBuffer_->getSize();
00242 }
00244 inline color getColorKey() const
00245 {
00246 return ImageBuffer_->getColorKey();
00247 }
00248
00250 inline bool getRenderTarget() const
00251 {
00252 return isRenderTarget_;
00253 }
00254
00256 inline ETextureDimensions getDimension() const
00257 {
00258 return DimensionType_;
00259 }
00260
00262 inline ECubeMapDirections getCubeMapFace() const
00263 {
00264 return CubeMapFace_;
00265 }
00267 inline u32 getArrayLayer() const
00268 {
00269 return ArrayLayer_;
00270 }
00271
00273 inline const std::vector<Texture*>& getMultiRenderTargets() const
00274 {
00275 return MultiRenderTargetList_;
00276 }
00277
00282 inline Texture* getDepthBufferSource() const
00283 {
00284 return DepthBufferSource_;
00285 }
00286
00288 inline EHWTextureFormats getHardwareFormat() const
00289 {
00290 return HWFormat_;
00291 }
00292
00294 virtual bool getMipMapping() const
00295 {
00296 return MipMaps_;
00297 }
00298
00300 inline std::vector<Texture*>& getAnimFrameList()
00301 {
00302 return AnimFrameList_;
00303 }
00304
00306 inline bool getAnimation() const
00307 {
00308 return isAnim_;
00309 }
00311 inline s32 getAnimFrameCount() const
00312 {
00313 return AnimFrameList_.size();
00314 }
00315
00317 inline void* getID() const
00318 {
00319 return ID_;
00320 }
00322 inline void* getOrigID() const
00323 {
00324 return OrigID_;
00325 }
00326
00338 inline ImageBuffer* getImageBuffer()
00339 {
00340 return ImageBuffer_;
00341 }
00342 inline const ImageBuffer* getImageBuffer() const
00343 {
00344 return ImageBuffer_;
00345 }
00346
00347 inline ImageBuffer* getImageBufferBackup()
00348 {
00349 return ImageBufferBackup_;
00350 }
00351 inline const ImageBuffer* getImageBufferBackup() const
00352 {
00353 return ImageBufferBackup_;
00354 }
00355
00357 inline ETextureFilters getMagFilter() const
00358 {
00359 return MagFilter_;
00360 }
00362 inline ETextureFilters getMinFilter() const
00363 {
00364 return MinFilter_;
00365 }
00367 inline ETextureMipMapFilters getMipMapFilter() const
00368 {
00369 return MipMapFilter_;
00370 }
00371
00373 inline dim::vector3d<ETextureWrapModes> getWrapMode() const
00374 {
00375 return WrapMode_;
00376 }
00377
00379 inline void setAnisotropicSamples(s32 Samples)
00380 {
00381 AnisotropicSamples_ = Samples;
00382 }
00384 inline s32 getAnisotropicSamples() const
00385 {
00386 return AnisotropicSamples_;
00387 }
00388
00390 inline s32 getMultiSamples() const
00391 {
00392 return MultiSamples_;
00393 }
00394
00395 protected:
00396
00397
00398
00399 virtual void updateMultiRenderTargets();
00400
00401
00402
00403
00404 void* OrigID_;
00405 void* ID_;
00406
00407
00408 io::stringc Filename_;
00409 EHWTextureFormats HWFormat_;
00410 ETextureDimensions DimensionType_;
00411 ETextureFilters MagFilter_, MinFilter_;
00412 ETextureMipMapFilters MipMapFilter_;
00413 dim::vector3d<ETextureWrapModes> WrapMode_;
00414 bool MipMaps_;
00415
00416
00417 s32 AnisotropicSamples_;
00418 s32 MultiSamples_;
00419 ECubeMapDirections CubeMapFace_;
00420 u32 ArrayLayer_;
00421
00422
00423 bool isRenderTarget_;
00424 std::vector<Texture*> MultiRenderTargetList_;
00425 Texture* DepthBufferSource_;
00426
00427
00428 bool isAnim_;
00429 std::vector<Texture*> AnimFrameList_;
00430
00436 ImageBuffer* ImageBuffer_;
00437
00443 ImageBuffer* ImageBufferBackup_;
00444
00445 private:
00446
00447
00448
00449 void createImageBuffer();
00450 void createImageBuffer(const STextureCreationFlags &CreationFlags);
00451
00452 };
00453
00454
00455 }
00456
00457 }
00458
00459
00460 #endif
00461
00462
00463
00464