| # HG changeset patch |
| # User David Reepmeyer <djreep81@gmail.com> |
| # Date 1516124750 21600 |
| # Branch v0-8 |
| # Node ID d8df60aa4ec9390457ae9beeef991bf2417311cc |
| # Parent 719f80b343e028f51f32ae9379ef77a96bc2bb3d |
| OgreTexture loading proper pixel format when loading image file |
| |
| diff --git a/cegui/include/CEGUI/RendererModules/Ogre/Texture.h b/cegui/include/CEGUI/RendererModules/Ogre/Texture.h |
| --- a/cegui/include/CEGUI/RendererModules/Ogre/Texture.h |
| +++ b/cegui/include/CEGUI/RendererModules/Ogre/Texture.h |
| @@ -88,7 +88,7 @@ |
| //! destructor. |
| virtual ~OgreTexture(); |
| //! construct an empty texture |
| - void createEmptyOgreTexture(); |
| + void createEmptyOgreTexture(PixelFormat pixel_format); |
| //! release the underlying Ogre texture. |
| void freeOgreTexture(); |
| //! updates cached scale value used to map pixels to texture co-ords. |
| diff --git a/cegui/src/RendererModules/Ogre/Texture.cpp b/cegui/src/RendererModules/Ogre/Texture.cpp |
| --- a/cegui/src/RendererModules/Ogre/Texture.cpp |
| +++ b/cegui/src/RendererModules/Ogre/Texture.cpp |
| @@ -79,7 +79,7 @@ |
| d_texelScaling(0, 0), |
| d_name(name) |
| { |
| - createEmptyOgreTexture(); |
| + createEmptyOgreTexture(Texture::PF_RGBA); |
| } |
| |
| //----------------------------------------------------------------------------// |
| @@ -91,7 +91,6 @@ |
| d_texelScaling(0, 0), |
| d_name(name) |
| { |
| - createEmptyOgreTexture(); |
| loadFromFile(filename, resourceGroup); |
| } |
| |
| @@ -103,7 +102,7 @@ |
| d_texelScaling(0, 0), |
| d_name(name) |
| { |
| - createEmptyOgreTexture(); |
| + createEmptyOgreTexture(Texture::PF_RGBA); |
| |
| // throw exception if no texture was able to be created |
| if (d_texture.isNull()) |
| @@ -214,6 +213,7 @@ |
| |
| const Ogre::PixelBox* pixelBox = new Ogre::PixelBox(buffer_size.d_width, buffer_size.d_height, |
| 1, toOgrePixelFormat(pixel_format), bufferCopy); |
| + createEmptyOgreTexture(pixel_format); |
| d_texture->freeInternalResources(); |
| d_texture->setWidth(buffer_size.d_width); |
| d_texture->setHeight(buffer_size.d_height); |
| @@ -242,7 +242,7 @@ |
| // than allow that to dictate poor choices in our own APIs, we choose to |
| // address the issue as close to the source of the problem as possible. |
| Ogre::PixelBox pb(area.getWidth(), area.getHeight(), |
| - 1, Ogre::PF_A8R8G8B8, const_cast<void*>(sourceData)); |
| + 1, d_texture->getFormat(), const_cast<void*>(sourceData)); |
| Ogre::Image::Box box(area.left(), area.top(), area.right(), area.bottom()); |
| d_texture->getBuffer()->blitFromMemory(pb, box); |
| } |
| @@ -254,7 +254,7 @@ |
| return; |
| |
| Ogre::PixelBox pb(d_size.d_width, d_size.d_height, |
| - 1, Ogre::PF_A8R8G8B8, targetData); |
| + 1, d_texture->getFormat(), targetData); |
| d_texture->getBuffer()->blitToMemory(pb); |
| } |
| |
| @@ -400,13 +400,13 @@ |
| } |
| |
| //----------------------------------------------------------------------------// |
| -void OgreTexture::createEmptyOgreTexture() |
| +void OgreTexture::createEmptyOgreTexture(Ogre::PixelFormat pixel_format) |
| { |
| // try to create a Ogre::Texture with given dimensions |
| d_texture = Ogre::TextureManager::getSingleton().createManual( |
| getUniqueName(), "General", Ogre::TEX_TYPE_2D, |
| 1, 1, 0, |
| - Ogre::PF_A8B8G8R8); |
| + toOgrePixelFormat(pixel_format)); |
| } |
| |
| |