Skip to content

Commit

Permalink
GRAPHICS: Add TextureManager::getInvisible()
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 21, 2014
1 parent 0330701 commit 02266eb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/graphics/textureman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ Ogre::TexturePtr TextureManager::get(const Common::UString &name) {
return texture;
}

Ogre::TexturePtr TextureManager::getInvisible() {
if (!Common::isMainThread()) {
Events::MainThreadFunctor<Ogre::TexturePtr> functor(boost::bind(&TextureManager::getInvisible, this));

return RequestMan.callInMainThread(functor);
}

Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName("xoreos/invisible");
if (!texture.isNull())
return texture;

return createInvisible();
}

ImageDecoder *TextureManager::createImage(const Common::UString &name) {
// Get the image resource
::Aurora::FileType type;
Expand Down Expand Up @@ -336,6 +350,21 @@ void TextureManager::convert(Ogre::TexturePtr &texture, const ImageDecoder &imag
}
}

Ogre::TexturePtr TextureManager::createInvisible() {
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual("xoreos/invisible", "General",
Ogre::TEX_TYPE_2D, 1, 1, 1, Ogre::PF_BYTE_BGRA, Ogre::TU_STATIC_WRITE_ONLY);

Ogre::HardwarePixelBufferSharedPtr buffer = texture->getBuffer(0, 0);
buffer->lock(Ogre::HardwareBuffer::HBL_WRITE_ONLY);
const Ogre::PixelBox &pb = buffer->getCurrentLock();

memset(pb.data, 0, Ogre::PixelUtil::getMemorySize(pb.getWidth(), pb.getHeight(), pb.getDepth(), pb.format));

buffer->unlock();

return texture;
}

bool TextureManager::dumpTGA(const Common::UString &name, const Common::UString &fileName) {
ImageDecoder *image = 0;

Expand Down
4 changes: 4 additions & 0 deletions src/graphics/textureman.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class TextureManager : public Common::Singleton<TextureManager> {
/** Get/Load a texture. */
Ogre::TexturePtr get(const Common::UString &name);

Ogre::TexturePtr getInvisible();

/** Get the properties of a texture. */
const TextureProperties &getProperties(const Common::UString &name);
/** Get the properties of a texture. */
Expand All @@ -99,6 +101,8 @@ class TextureManager : public Common::Singleton<TextureManager> {
Ogre::TexturePtr create(const Common::UString &name);
Ogre::TexturePtr create(const Common::UString &name, const ImageDecoder &image);

Ogre::TexturePtr createInvisible();

ImageDecoder *createImage(const Common::UString &name);

void convert(Ogre::TexturePtr &texture, const ImageDecoder &image, int mipMaps);
Expand Down

0 comments on commit 02266eb

Please sign in to comment.