Make dump glyph page possible for new texture format
Also implement read-only lock, please use reload() for writing
This commit is contained in:
@@ -312,7 +312,20 @@ void FontWithFace::updateCharactersList()
|
||||
*/
|
||||
void FontWithFace::dumpGlyphPage(const std::string& name)
|
||||
{
|
||||
// Todo for new texture format
|
||||
for (unsigned int i = 0; i < m_spritebank->getTextureCount(); i++)
|
||||
{
|
||||
video::ITexture* tex = m_spritebank->getTexture(i);
|
||||
core::dimension2d<u32> size = tex->getSize();
|
||||
video::ECOLOR_FORMAT col_format = tex->getColorFormat();
|
||||
void* data = tex->lock();
|
||||
video::IImage* image = irr_driver->getVideoDriver()
|
||||
->createImageFromData(col_format, size, data,
|
||||
true/*ownForeignMemory*/);
|
||||
tex->unlock();
|
||||
irr_driver->getVideoDriver()->writeImageToFile(image, std::string
|
||||
(name + "_" + StringUtils::toString(i) + ".png").c_str());
|
||||
image->drop();
|
||||
}
|
||||
} // dumpGlyphPage
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -425,3 +425,22 @@ bool STKTexture::hasMipMaps() const
|
||||
return false;
|
||||
#endif // !SERVER_ONLY
|
||||
} // hasMipMaps
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void* STKTexture::lock(video::E_TEXTURE_LOCK_MODE mode, u32 mipmap_level)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
if (m_texture_image)
|
||||
return m_texture_image->lock();
|
||||
|
||||
uint8_t* pixels = new uint8_t[m_size.Width * m_size.Height * 4]();
|
||||
GLint tmp_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &tmp_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_texture_name);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
|
||||
glBindTexture(GL_TEXTURE_2D, tmp_texture);
|
||||
return pixels;
|
||||
#else
|
||||
return NULL;
|
||||
#endif // !SERVER_ONLY
|
||||
} // lock
|
||||
|
||||
@@ -69,12 +69,7 @@ public:
|
||||
virtual ~STKTexture();
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void* lock(video::E_TEXTURE_LOCK_MODE mode =
|
||||
video::ETLM_READ_WRITE, u32 mipmap_level = 0)
|
||||
{
|
||||
if (m_texture_image)
|
||||
return m_texture_image->lock();
|
||||
return NULL;
|
||||
}
|
||||
video::ETLM_READ_WRITE, u32 mipmap_level = 0);
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void unlock()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user