Commit a9bb0ccd authored by nadro's avatar nadro

- Added ETCF_ALLOW_MEMORY_COPY flag (this flag inform driver, if texture...

- Added ETCF_ALLOW_MEMORY_COPY flag (this flag inform driver, if texture should keep copy of image data).(this feature was available in ogl-es branch before).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5183 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 33e76dc7
......@@ -65,6 +65,12 @@ enum E_TEXTURE_CREATION_FLAG
/** BurningVideo can handle Non-Power-2 Textures in 2D (GUI), but not in 3D. */
ETCF_ALLOW_NON_POWER_2 = 0x00000040,
//! Allow the driver to keep a copy of the texture in memory
/** This makes calls to ITexture::lock a lot faster, but costs main memory.
Default is off, except for font-texture which always enable this flag.
Currently only used in combination with OpenGL drivers. */
ETCF_ALLOW_MEMORY_COPY = 0x00000080,
/** This flag is never used, it only forces the compiler to compile
these enumeration values to 32 bit. */
ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff
......
......@@ -85,16 +85,14 @@ bool CGUIFont::load(io::IXMLReader* xml, const io::path& directory)
while (i+1 > SpriteBank->getTextureCount())
SpriteBank->addTexture(0);
// disable mipmaps+filtering
bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
bool flags[3];
pushTextureCreationFlags(flags);
// load texture
io::path textureFullName = core::mergeFilename(directory, fn);
SpriteBank->setTexture(i, Driver->getTexture(textureFullName));
// set previous mip-map+filter state
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap);
popTextureCreationFlags(flags);
// couldn't load texture, abort.
if (!SpriteBank->getTexture(i))
......@@ -218,6 +216,23 @@ void CGUIFont::setMaxHeight()
}
void CGUIFont::pushTextureCreationFlags(bool(&flags)[3])
{
flags[0] = Driver->getTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2);
flags[1] = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
flags[2] = Driver->getTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY);
Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, true);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
Driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, true);
}
void CGUIFont::popTextureCreationFlags(bool(&flags)[3])
{
Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, flags[0]);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, flags[1]);
Driver->setTextureCreationFlag(video::ETCF_ALLOW_MEMORY_COPY, flags[2]);
}
//! loads a font file, native file needed, for texture parsing
bool CGUIFont::load(io::IReadFile* file)
......@@ -285,17 +300,12 @@ bool CGUIFont::loadTexture(video::IImage* image, const io::path& name)
if ( ret )
{
bool flag[2];
flag[0] = Driver->getTextureCreationFlag ( video::ETCF_ALLOW_NON_POWER_2 );
flag[1] = Driver->getTextureCreationFlag ( video::ETCF_CREATE_MIP_MAPS );
Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, true);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false );
bool flags[3];
pushTextureCreationFlags(flags);
SpriteBank->addTexture(Driver->addTexture(name, tmpImage));
Driver->setTextureCreationFlag(video::ETCF_ALLOW_NON_POWER_2, flag[0] );
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, flag[1] );
popTextureCreationFlags(flags);
}
if (deleteTmpImage)
tmpImage->drop();
......
......@@ -98,6 +98,9 @@ private:
s32 getAreaFromCharacter (const wchar_t c) const;
void setMaxHeight();
void pushTextureCreationFlags(bool(&flags)[3]);
void popTextureCreationFlags(bool(&flags)[3]);
core::array<SFontArea> Areas;
core::map<wchar_t, s32> CharacterMap;
video::IVideoDriver* Driver;
......
......@@ -54,6 +54,7 @@ public:
DriverType = Driver->getDriverType();
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
AutoGenerateMipMaps = Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE);
KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY);
getImageValues(image[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment