1 // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
\r
6 #define __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
\r
8 #include "SoftwareDriver2_compile_config.h"
\r
10 #include "ITexture.h"
\r
11 #if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
\r
12 #include "IVideoDriver.h"
\r
14 #include "IRenderTarget.h"
\r
23 class CBurningVideoDriver;
\r
26 interface for a Video Driver dependent Texture.
\r
28 struct CSoftwareTexture2_Bound
\r
30 f32 w; // width - 0.5f;
\r
31 f32 h; // height- 0.5f;
\r
32 f32 cx; // texelcenter x 1.f/width*0.5f
\r
33 f32 cy; // texelcenter y 1.f/height*0.5f
\r
36 class CSoftwareTexture2 : public ITexture
\r
43 GEN_MIPMAP = 1, // has mipmaps
\r
44 GEN_MIPMAP_AUTO = 2, // automatic mipmap generation
\r
45 IS_RENDERTARGET = 4,
\r
46 ALLOW_NPOT = 8, //allow non power of two
\r
47 IMAGE_IS_LINEAR = 16,
\r
48 TEXTURE_IS_LINEAR = 32,
\r
50 CSoftwareTexture2(IImage* surface, const io::path& name, u32 flags /*eTex2Flags*/, CBurningVideoDriver* driver);
\r
53 virtual ~CSoftwareTexture2();
\r
55 u32 getMipmapLevel(s32 newLevel) const
\r
57 if ( newLevel < 0 ) newLevel = 0;
\r
58 else if ( newLevel >= (s32)array_size(MipMap)) newLevel = array_size(MipMap) - 1;
\r
60 while ( newLevel > 0 && MipMap[newLevel] == 0 ) newLevel -= 1;
\r
65 #if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
\r
66 virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
\r
68 virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel, u32 layer, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_
\r
71 if (Flags & GEN_MIPMAP)
\r
73 //called from outside. must test
\r
74 MipMapLOD = getMipmapLevel(mipmapLevel);
\r
75 Size = MipMap[MipMapLOD]->getDimension();
\r
76 Pitch = MipMap[MipMapLOD]->getPitch();
\r
79 return MipMap[MipMapLOD]->getData();
\r
83 virtual void unlock() _IRR_OVERRIDE_
\r
87 //! compare the area drawn with the area of the texture
\r
88 f32 getLODFactor( const f32 texArea ) const
\r
90 return MipMap0_Area[0]* MipMap0_Area[1] * 0.5f * texArea;
\r
91 //return MipMap[0]->getImageDataSizeInPixels () * texArea;
\r
95 const u32* getMipMap0_Area() const
\r
97 return MipMap0_Area;
\r
99 f32 get_lod_bias() const { return LodBIAS; }
\r
101 //! returns unoptimized surface (misleading name. burning can scale down originalimage)
\r
102 virtual CImage* getImage() const
\r
107 //! returns texture surface
\r
108 virtual CImage* getTexture() const
\r
110 return MipMap[MipMapLOD];
\r
113 //precalculated dimx-1/dimx*0.5f
\r
114 const CSoftwareTexture2_Bound& getTexBound() const
\r
116 return TexBound[MipMapLOD];
\r
119 #if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
\r
120 virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) _IRR_OVERRIDE_;
\r
122 virtual void regenerateMipMapLevels(void* data = 0);
\r
126 #if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
\r
127 const core::dimension2d<u32>& getOriginalSize() const { return OriginalSize; };
\r
128 const core::dimension2d<u32>& getSize() const { return Size; };
\r
129 E_DRIVER_TYPE getDriverType() const { return DriverType; };
\r
130 ECOLOR_FORMAT getColorFormat() const { return ColorFormat; };
\r
131 ECOLOR_FORMAT getOriginalColorFormat() const { return OriginalColorFormat; };
\r
132 u32 getPitch() const { return Pitch; };
\r
133 bool hasMipMaps() const { return HasMipMaps; }
\r
134 bool isRenderTarget() const { return IsRenderTarget; }
\r
136 core::dimension2d<u32> OriginalSize;
\r
137 core::dimension2d<u32> Size;
\r
138 E_DRIVER_TYPE DriverType;
\r
139 ECOLOR_FORMAT OriginalColorFormat;
\r
140 ECOLOR_FORMAT ColorFormat;
\r
143 bool IsRenderTarget;
\r
147 void calcDerivative();
\r
149 //! controls MipmapSelection. relation between drawn area and image size
\r
150 u32 MipMapLOD; // 0 .. original Texture pot -SOFTWARE_DRIVER_2_MIPMAPPING_MAX
\r
151 u32 Flags; //eTex2Flags
\r
152 CBurningVideoDriver* Driver;
\r
154 CImage* MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
\r
155 CSoftwareTexture2_Bound TexBound[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
\r
156 u32 MipMap0_Area[2];
\r
157 f32 LodBIAS; // Tweak mipmap selection
\r
161 interface for a Video Driver dependent render target.
\r
163 class CSoftwareRenderTarget2 : public IRenderTarget
\r
166 CSoftwareRenderTarget2(CBurningVideoDriver* driver);
\r
167 virtual ~CSoftwareRenderTarget2();
\r
169 virtual void setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces) _IRR_OVERRIDE_;
\r
171 #if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
\r
172 E_DRIVER_TYPE DriverType;
\r
173 core::array<ITexture*> Texture;
\r
177 CBurningVideoDriver* Driver;
\r
180 } // end namespace video
\r
181 } // end namespace irr
\r
183 #endif // __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
\r