2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_SOFTWARE_2_TEXTURE_H_INCLUDED
|
|
|
|
#define IRR_C_SOFTWARE_2_TEXTURE_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "SoftwareDriver2_compile_config.h"
|
|
|
|
|
|
|
|
#include "ITexture.h"
|
2020-11-10 19:49:39 +01:00
|
|
|
#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
|
|
|
|
#include "IVideoDriver.h"
|
|
|
|
#else
|
2019-12-12 17:32:41 +01:00
|
|
|
#include "IRenderTarget.h"
|
2020-11-10 19:49:39 +01:00
|
|
|
#endif
|
2019-12-12 17:32:41 +01:00
|
|
|
#include "CImage.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
|
|
|
|
class CBurningVideoDriver;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
interface for a Video Driver dependent Texture.
|
|
|
|
*/
|
2020-02-22 21:48:12 +01:00
|
|
|
struct CSoftwareTexture2_Bound
|
|
|
|
{
|
2022-05-01 00:57:17 +02:00
|
|
|
//[0.5 / width, 1 - 0.5 / width]
|
|
|
|
//int dim[2];
|
|
|
|
f32 mat[4];
|
|
|
|
|
|
|
|
u32 area; // width * height
|
2020-02-22 21:48:12 +01:00
|
|
|
};
|
|
|
|
|
2022-05-01 00:57:17 +02:00
|
|
|
#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
|
|
|
|
//! Enumeration describing the type of ITexture.
|
|
|
|
enum E_TEXTURE_TYPE
|
|
|
|
{
|
|
|
|
//! 2D texture.
|
|
|
|
ETT_2D,
|
|
|
|
|
|
|
|
//! Cubemap texture.
|
|
|
|
ETT_CUBEMAP
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-12-12 17:32:41 +01:00
|
|
|
class CSoftwareTexture2 : public ITexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
enum eTex2Flags
|
|
|
|
{
|
2020-02-23 03:23:10 +01:00
|
|
|
GEN_MIPMAP = 1, // has mipmaps
|
|
|
|
GEN_MIPMAP_AUTO = 2, // automatic mipmap generation
|
|
|
|
IS_RENDERTARGET = 4,
|
|
|
|
ALLOW_NPOT = 8, //allow non power of two
|
|
|
|
IMAGE_IS_LINEAR = 16,
|
|
|
|
TEXTURE_IS_LINEAR = 32,
|
2019-12-12 17:32:41 +01:00
|
|
|
};
|
2020-02-22 21:48:12 +01:00
|
|
|
CSoftwareTexture2(IImage* surface, const io::path& name, u32 flags /*eTex2Flags*/, CBurningVideoDriver* driver);
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CSoftwareTexture2();
|
|
|
|
|
2020-02-22 21:48:12 +01:00
|
|
|
u32 getMipmapLevel(s32 newLevel) const
|
|
|
|
{
|
|
|
|
if ( newLevel < 0 ) newLevel = 0;
|
2020-11-10 20:06:45 +01:00
|
|
|
else if ( newLevel >= (s32)array_size(MipMap)) newLevel = array_size(MipMap) - 1;
|
2020-02-22 21:48:12 +01:00
|
|
|
|
2022-05-01 00:57:17 +02:00
|
|
|
while ( newLevel > 0 && MipMap[newLevel] == 0 )
|
|
|
|
newLevel -= 1;
|
2020-02-22 21:48:12 +01:00
|
|
|
return newLevel;
|
|
|
|
}
|
|
|
|
|
2019-12-12 17:32:41 +01:00
|
|
|
//! lock function
|
2020-11-10 19:49:39 +01:00
|
|
|
#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
|
|
|
|
virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
|
|
|
|
#else
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel, u32 layer, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) IRR_OVERRIDE
|
2020-11-10 19:49:39 +01:00
|
|
|
#endif
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
if (Flags & GEN_MIPMAP)
|
|
|
|
{
|
2020-02-22 21:48:12 +01:00
|
|
|
//called from outside. must test
|
|
|
|
MipMapLOD = getMipmapLevel(mipmapLevel);
|
2019-12-12 17:32:41 +01:00
|
|
|
Size = MipMap[MipMapLOD]->getDimension();
|
|
|
|
Pitch = MipMap[MipMapLOD]->getPitch();
|
|
|
|
}
|
|
|
|
|
|
|
|
return MipMap[MipMapLOD]->getData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//! unlock function
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void unlock() IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
}
|
2020-02-22 21:48:12 +01:00
|
|
|
|
|
|
|
//! returns unoptimized surface (misleading name. burning can scale down originalimage)
|
2019-12-12 17:32:41 +01:00
|
|
|
virtual CImage* getImage() const
|
|
|
|
{
|
|
|
|
return MipMap[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
//! returns texture surface
|
|
|
|
virtual CImage* getTexture() const
|
|
|
|
{
|
|
|
|
return MipMap[MipMapLOD];
|
|
|
|
}
|
|
|
|
|
2020-02-22 21:48:12 +01:00
|
|
|
//precalculated dimx-1/dimx*0.5f
|
|
|
|
const CSoftwareTexture2_Bound& getTexBound() const
|
|
|
|
{
|
|
|
|
return TexBound[MipMapLOD];
|
|
|
|
}
|
2022-05-01 00:57:17 +02:00
|
|
|
const CSoftwareTexture2_Bound* getTexBound_index() const
|
|
|
|
{
|
|
|
|
return TexBound;
|
|
|
|
}
|
2020-02-22 21:48:12 +01:00
|
|
|
|
2020-11-10 19:49:39 +01:00
|
|
|
#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) IRR_OVERRIDE;
|
2020-11-10 19:49:39 +01:00
|
|
|
#else
|
|
|
|
virtual void regenerateMipMapLevels(void* data = 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
|
2022-05-01 00:57:17 +02:00
|
|
|
const core::dimension2d<u32>& getOriginalSize() const { return OriginalSize; }
|
|
|
|
const core::dimension2d<u32>& getSize() const { return Size; }
|
|
|
|
E_DRIVER_TYPE getDriverType() const { return DriverType; }
|
|
|
|
ECOLOR_FORMAT getColorFormat() const { return ColorFormat; }
|
|
|
|
ECOLOR_FORMAT getOriginalColorFormat() const { return OriginalColorFormat; }
|
2020-11-10 19:49:39 +01:00
|
|
|
u32 getPitch() const { return Pitch; };
|
|
|
|
bool hasMipMaps() const { return HasMipMaps; }
|
|
|
|
bool isRenderTarget() const { return IsRenderTarget; }
|
|
|
|
|
2022-05-01 00:57:17 +02:00
|
|
|
E_TEXTURE_TYPE getType() const { return Type; }
|
|
|
|
|
2020-11-10 19:49:39 +01:00
|
|
|
core::dimension2d<u32> OriginalSize;
|
|
|
|
core::dimension2d<u32> Size;
|
|
|
|
E_DRIVER_TYPE DriverType;
|
|
|
|
ECOLOR_FORMAT OriginalColorFormat;
|
|
|
|
ECOLOR_FORMAT ColorFormat;
|
|
|
|
u32 Pitch;
|
|
|
|
bool HasMipMaps;
|
|
|
|
bool IsRenderTarget;
|
2022-05-01 00:57:17 +02:00
|
|
|
E_TEXTURE_TYPE Type;
|
2020-11-10 19:49:39 +01:00
|
|
|
#endif
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
private:
|
2020-02-22 21:48:12 +01:00
|
|
|
void calcDerivative();
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2020-02-22 21:48:12 +01:00
|
|
|
//! controls MipmapSelection. relation between drawn area and image size
|
|
|
|
u32 MipMapLOD; // 0 .. original Texture pot -SOFTWARE_DRIVER_2_MIPMAPPING_MAX
|
|
|
|
u32 Flags; //eTex2Flags
|
|
|
|
CBurningVideoDriver* Driver;
|
|
|
|
|
|
|
|
CImage* MipMap[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
|
|
|
|
CSoftwareTexture2_Bound TexBound[SOFTWARE_DRIVER_2_MIPMAPPING_MAX];
|
2022-05-01 00:57:17 +02:00
|
|
|
|
|
|
|
//Helper pointer for regenerateMipMapLevels (do not store per texture)
|
|
|
|
static const IImage* original_mip0;
|
|
|
|
|
2019-12-12 17:32:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
interface for a Video Driver dependent render target.
|
|
|
|
*/
|
|
|
|
class CSoftwareRenderTarget2 : public IRenderTarget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CSoftwareRenderTarget2(CBurningVideoDriver* driver);
|
|
|
|
virtual ~CSoftwareRenderTarget2();
|
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setTextures(ITexture* const * textures, u32 numTextures, ITexture* depthStencil, const E_CUBE_SURFACE* cubeSurfaces, u32 numCubeSurfaces) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2020-11-10 19:49:39 +01:00
|
|
|
#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
|
2022-05-04 12:29:41 +02:00
|
|
|
public:
|
2020-11-10 19:49:39 +01:00
|
|
|
E_DRIVER_TYPE DriverType;
|
2022-05-01 00:57:17 +02:00
|
|
|
core::array<ITexture*> Textures;
|
|
|
|
ITexture* DepthStencil;
|
2020-11-10 19:49:39 +01:00
|
|
|
#endif
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CBurningVideoDriver* Driver;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace video
|
|
|
|
} // end namespace irr
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#endif // IRR_C_SOFTWARE_2_TEXTURE_H_INCLUDED
|