Refactor osgMyGUI::OSGTexture to store width/height inside the object

pull/178/head
scrawl 8 years ago
parent d8505e4f48
commit 8fc7942d64

@ -16,6 +16,8 @@ namespace osgMyGUI
, mFormat(MyGUI::PixelFormat::Unknow) , mFormat(MyGUI::PixelFormat::Unknow)
, mUsage(MyGUI::TextureUsage::Default) , mUsage(MyGUI::TextureUsage::Default)
, mNumElemBytes(0) , mNumElemBytes(0)
, mWidth(0)
, mHeight(0)
{ {
} }
@ -25,6 +27,8 @@ namespace osgMyGUI
, mFormat(MyGUI::PixelFormat::Unknow) , mFormat(MyGUI::PixelFormat::Unknow)
, mUsage(MyGUI::TextureUsage::Default) , mUsage(MyGUI::TextureUsage::Default)
, mNumElemBytes(0) , mNumElemBytes(0)
, mWidth(texture->getTextureWidth())
, mHeight(texture->getTextureHeight())
{ {
} }
@ -63,6 +67,9 @@ namespace osgMyGUI
mTexture->setSourceFormat(glfmt); mTexture->setSourceFormat(glfmt);
mTexture->setSourceType(GL_UNSIGNED_BYTE); mTexture->setSourceType(GL_UNSIGNED_BYTE);
mWidth = width;
mHeight = height;
mTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR); mTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
mTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR); mTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); mTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
@ -79,6 +86,8 @@ namespace osgMyGUI
mFormat = MyGUI::PixelFormat::Unknow; mFormat = MyGUI::PixelFormat::Unknow;
mUsage = MyGUI::TextureUsage::Default; mUsage = MyGUI::TextureUsage::Default;
mNumElemBytes = 0; mNumElemBytes = 0;
mWidth = 0;
mHeight = 0;
} }
void OSGTexture::loadFromFile(const std::string &fname) void OSGTexture::loadFromFile(const std::string &fname)
@ -95,6 +104,9 @@ namespace osgMyGUI
// disable mip-maps // disable mip-maps
mTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); mTexture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
mWidth = image->s();
mHeight = image->t();
// FIXME // FIXME
mFormat = MyGUI::PixelFormat::R8G8B8; mFormat = MyGUI::PixelFormat::R8G8B8;
mUsage = MyGUI::TextureUsage::Static | MyGUI::TextureUsage::Write; mUsage = MyGUI::TextureUsage::Static | MyGUI::TextureUsage::Write;
@ -108,16 +120,12 @@ namespace osgMyGUI
int OSGTexture::getWidth() int OSGTexture::getWidth()
{ {
if(!mTexture.valid()) return mWidth;
return 0;
return mTexture->getTextureWidth();
} }
int OSGTexture::getHeight() int OSGTexture::getHeight()
{ {
if(!mTexture.valid()) return mHeight;
return 0;
return mTexture->getTextureHeight();
} }
void *OSGTexture::lock(MyGUI::TextureUsage /*access*/) void *OSGTexture::lock(MyGUI::TextureUsage /*access*/)

@ -29,6 +29,9 @@ namespace osgMyGUI
MyGUI::TextureUsage mUsage; MyGUI::TextureUsage mUsage;
size_t mNumElemBytes; size_t mNumElemBytes;
int mWidth;
int mHeight;
public: public:
OSGTexture(const std::string &name, Resource::ImageManager* imageManager); OSGTexture(const std::string &name, Resource::ImageManager* imageManager);
OSGTexture(osg::Texture2D* texture); OSGTexture(osg::Texture2D* texture);

Loading…
Cancel
Save