ITexture::lock interface changed.

- mipmapLevel is now the second parameter as it was in Irrlicht 1.8 (but currently not doing anything)
- layer moved to third parameter
- New parameter lockFlags which allows to disabled flipping the texture upside down for RTT's on OpenGL.
Sorry for any inconvenience this change causes, but as I had to break the interface now anyway I decided to make it backward compatible to Irrlicht 1.8. Anyone already using the new "layers" feature in trunk will have to move the layer parameter now. But the last interface change which replaced the mipmaplevel with another variable with very different meaning wasn't a solution.
Mipmap support can also likely be re-introduced. At least I still haven't seen a real reason why it shouldn't be possible to have that anymore.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5663 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2018-11-22 19:13:59 +00:00
parent 343924adb7
commit b584c39295
10 changed files with 43 additions and 21 deletions

View File

@ -94,6 +94,30 @@ enum E_TEXTURE_LOCK_MODE
ETLM_WRITE_ONLY
};
//! Additional bitflags for ITexture::lock() call
enum E_TEXTURE_LOCK_FLAGS
{
ETLF_NONE = 0,
//! Flip left-bottom origin rendertarget textures upside-down
/** Irrlicht usually has all textures with left-top as origin.
And for drivers with a left-bottom origin coordinate system (OpenGL)
Irrlicht modifies the texture-matrix in the fixed function pipeline to make
the textures show up correctly (shader coders have to handle upside down
textures themselves).
But rendertarget textures (RTT's) are written by drivers the way the
coordinate system of that driver works. So on OpenGL images tend to look
upside down (aka Y coordinate going up) on lock() when this flag isn't set.
When the flag is set it will flip such textures on lock() to make them look
like non-rtt textures (origin left-top). Note that this also means the texture
will be uploaded flipped on unlock. So mostly you want to have this flag set
when you want to look at the texture or save it, but unset if you want to
upload it again to the card.
If you disable this flag you get the memory just as it is on the graphic card.
For backward compatibility reasons this flag is enabled by default. */
ETLF_FLIP_Y_UP_RTT = 1
};
//! Where did the last IVideoDriver::getTexture call find this texture
enum E_TEXTURE_SOURCE
{
@ -151,11 +175,15 @@ public:
only mode or read from in write only mode.
Support for this feature depends on the driver, so don't rely on the
texture being write-protected when locking with read-only, etc.
\param mipmapLevel NOTE: Currently broken, sorry, we try if we can repair it for 1.9 release.
Number of the mipmapLevel to lock. 0 is main texture.
Non-existing levels will silently fail and return 0.
\param layer It determines which cubemap face or texture array layer should be locked.
\param lockFlags See E_TEXTURE_LOCK_FLAGS documentation.
\return Returns a pointer to the pixel data. The format of the pixel can
be determined by using getColorFormat(). 0 is returned, if
the texture cannot be locked. */
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 layer = 0) = 0;
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) = 0;
//! Unlock function. Must be called after a lock() to the texture.
/** One should avoid to call unlock more than once before another lock.

View File

@ -177,7 +177,7 @@ CD3D9Texture::~CD3D9Texture()
Device->Release();
}
void* CD3D9Texture::lock(E_TEXTURE_LOCK_MODE mode, u32 layer)
void* CD3D9Texture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel, u32 layer, E_TEXTURE_LOCK_FLAGS lockFlags)
{
if (LockData)
return LockData;

View File

@ -32,7 +32,7 @@ public:
virtual ~CD3D9Texture();
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 layer = 0) _IRR_OVERRIDE_;
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_;
virtual void unlock() _IRR_OVERRIDE_;

View File

@ -783,7 +783,7 @@ namespace video
{
SDummyTexture(const io::path& name, E_TEXTURE_TYPE type) : ITexture(name, type) {};
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 layer = 0) _IRR_OVERRIDE_ { return 0; }
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_ { return 0; }
virtual void unlock()_IRR_OVERRIDE_ {}
virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) _IRR_OVERRIDE_ {}
};

View File

@ -206,7 +206,7 @@ public:
Image[i]->drop();
}
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 layer = 0) _IRR_OVERRIDE_
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_
{
if (LockImage)
return LockImage->getData();
@ -248,7 +248,7 @@ public:
glGetTexImage(tmpTextureType, 0, PixelFormat, PixelType, tmpImage->getData());
if (IsRenderTarget)
if (IsRenderTarget && lockFlags == ETLF_FLIP_Y_UP_RTT)
{
const s32 pitch = tmpImage->getPitch();

View File

@ -76,7 +76,7 @@ CSoftwareTexture::~CSoftwareTexture()
//! lock function
void* CSoftwareTexture::lock(E_TEXTURE_LOCK_MODE mode, u32 layer)
void* CSoftwareTexture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel, u32 layer, E_TEXTURE_LOCK_FLAGS lockFlags)
{
return Image->getData();
}

View File

@ -30,7 +30,7 @@ public:
virtual ~CSoftwareTexture();
//! lock function
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 layer = 0) _IRR_OVERRIDE_;
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) _IRR_OVERRIDE_;
//! unlock function
virtual void unlock() _IRR_OVERRIDE_;

View File

@ -38,11 +38,11 @@ public:
virtual ~CSoftwareTexture2();
//! lock function
virtual void* lock(E_TEXTURE_LOCK_MODE mode, u32 level, u32 layer)
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 = level;
MipMapLOD = mipmapLevel;
Size = MipMap[MipMapLOD]->getDimension();
Pitch = MipMap[MipMapLOD]->getPitch();
}
@ -50,12 +50,6 @@ public:
return MipMap[MipMapLOD]->getData();
}
//! lock function
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 layer = 0) _IRR_OVERRIDE_
{
return lock(mode, 0, layer);
}
//! unlock function
virtual void unlock() _IRR_OVERRIDE_
{

View File

@ -49,7 +49,7 @@ int main(int argumentCount, char * arguments[])
#if 0
// To interactively debug a test, move it (temporarily) in here and enable the define to only run this test
// Otherwise debugging is slightly tricky as each test runs in it's own process.
TEST(renderTargetTexture);
TEST(textureFeatures);
#else
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
// Now the simple tests without device

View File

@ -1,4 +1,4 @@
Tests finished. 1 test of 1 passed.
Compiled as DEBUG
Test suite pass at GMT Tue Nov 7 00:42:08 2017
Tests finished. 1 test of 1 passed.
Compiled as DEBUG
Test suite pass at GMT Mon Nov 19 21:48:32 2018