mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-04 09:10:27 +02:00
- BurningVideo: 0.50
- 10 year anniversary update - Lighting model reworked. moved to eyespace like openGL. [Specular Highlights, Fog, Sphere/Reflection Map] - increased internal s4DVertex to support 4 Textures and 4 Colors [switchable] - Textures are handled as sRGB during Mipmap Generation. More accurate, less visual disruption - 2D is drawn as 3D like hardware drivers. [switchable]. enables viewport scaling, material2D - Texture Spatial Resolution Limiting working. [lower memory consumption,SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE] - SuperTuxKart 8.0.1 playable git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6086 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
@ -21,6 +21,14 @@ class CBurningVideoDriver;
|
||||
/*!
|
||||
interface for a Video Driver dependent Texture.
|
||||
*/
|
||||
struct CSoftwareTexture2_Bound
|
||||
{
|
||||
f32 w; // width - 0.5f;
|
||||
f32 h; // height- 0.5f;
|
||||
f32 cx; // texelcenter x 1.f/width*0.5f
|
||||
f32 cy; // texelcenter y 1.f/height*0.5f
|
||||
};
|
||||
|
||||
class CSoftwareTexture2 : public ITexture
|
||||
{
|
||||
public:
|
||||
@ -28,21 +36,33 @@ public:
|
||||
//! constructor
|
||||
enum eTex2Flags
|
||||
{
|
||||
GEN_MIPMAP = 1,
|
||||
IS_RENDERTARGET = 2,
|
||||
NP2_SIZE = 4,
|
||||
GEN_MIPMAP = 1,
|
||||
IS_RENDERTARGET = 2,
|
||||
ALLOW_NPOT = 4, //allow non power of two
|
||||
IMAGE_IS_LINEAR = 8,
|
||||
TEXTURE_IS_LINEAR = 16,
|
||||
};
|
||||
CSoftwareTexture2(IImage* surface, const io::path& name, u32 flags);
|
||||
CSoftwareTexture2(IImage* surface, const io::path& name, u32 flags /*eTex2Flags*/, CBurningVideoDriver* driver);
|
||||
|
||||
//! destructor
|
||||
virtual ~CSoftwareTexture2();
|
||||
|
||||
u32 getMipmapLevel(s32 newLevel) const
|
||||
{
|
||||
if ( newLevel < 0 ) newLevel = 0;
|
||||
else if ( newLevel >= SOFTWARE_DRIVER_2_MIPMAPPING_MAX ) newLevel = SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1;
|
||||
|
||||
while ( newLevel > 0 && MipMap[newLevel] == 0 ) newLevel -= 1;
|
||||
return newLevel;
|
||||
}
|
||||
|
||||
//! lock function
|
||||
virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel, u32 layer, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_
|
||||
{
|
||||
if (Flags & GEN_MIPMAP)
|
||||
{
|
||||
MipMapLOD = mipmapLevel;
|
||||
//called from outside. must test
|
||||
MipMapLOD = getMipmapLevel(mipmapLevel);
|
||||
Size = MipMap[MipMapLOD]->getDimension();
|
||||
Pitch = MipMap[MipMapLOD]->getPitch();
|
||||
}
|
||||
@ -55,14 +75,19 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
//! Returns the size of the largest mipmap.
|
||||
//! compare the area drawn with the area of the texture
|
||||
f32 getLODFactor( const f32 texArea ) const
|
||||
{
|
||||
return OrigImageDataSizeInPixels * texArea;
|
||||
return MipMap0_Area[0]* MipMap0_Area[1] * 0.5f * texArea;
|
||||
//return MipMap[0]->getImageDataSizeInPixels () * texArea;
|
||||
}
|
||||
|
||||
//! returns unoptimized surface
|
||||
const u32* getMipMap0_Area() const
|
||||
{
|
||||
return MipMap0_Area;
|
||||
}
|
||||
|
||||
//! returns unoptimized surface (misleading name. burning can scale down originalimage)
|
||||
virtual CImage* getImage() const
|
||||
{
|
||||
return MipMap[0];
|
||||
@ -74,16 +99,26 @@ public:
|
||||
return MipMap[MipMapLOD];
|
||||
}
|
||||
|
||||
//precalculated dimx-1/dimx*0.5f
|
||||
const CSoftwareTexture2_Bound& getTexBound() const
|
||||
{
|
||||
return TexBound[MipMapLOD];
|
||||
}
|
||||
|
||||
virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
f32 OrigImageDataSizeInPixels;
|
||||
void calcDerivative();
|
||||
|
||||
CImage * MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
|
||||
|
||||
u32 MipMapLOD;
|
||||
u32 Flags;
|
||||
//! controls MipmapSelection. relation between drawn area and image size
|
||||
u32 MipMapLOD; // 0 .. original Texture pot -SOFTWARE_DRIVER_2_MIPMAPPING_MAX
|
||||
u32 Flags; //eTex2Flags
|
||||
ECOLOR_FORMAT OriginalFormat;
|
||||
CBurningVideoDriver* Driver;
|
||||
|
||||
CImage* MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
|
||||
CSoftwareTexture2_Bound TexBound[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
|
||||
u32 MipMap0_Area[2];
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -103,9 +138,9 @@ protected:
|
||||
CBurningVideoDriver* Driver;
|
||||
};
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
#endif // __C_SOFTWARE_2_TEXTURE_H_INCLUDED__
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user