Skip to content

Commit

Permalink
Merge remote-tracking branch 'jordanmilne/443-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
zinnschlag committed Jan 5, 2013
2 parents 3ed77ca + 917bbc4 commit 20e624e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions libs/openengine/ogre/imagerotate.cpp
Expand Up @@ -16,6 +16,8 @@ void ImageRotate::rotate(const std::string& sourceImage, const std::string& dest
{
Root* root = Ogre::Root::getSingletonPtr();

std::string destImageRot = std::string(destImage) + std::string("_rot");

SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC);
Camera* camera = sceneMgr->createCamera("ImageRotateCamera");

Expand Down Expand Up @@ -48,16 +50,16 @@ void ImageRotate::rotate(const std::string& sourceImage, const std::string& dest
unsigned int width = sourceTexture->getWidth();
unsigned int height = sourceTexture->getHeight();

TexturePtr destTexture = TextureManager::getSingleton().createManual(
destImage,
TexturePtr destTextureRot = TextureManager::getSingleton().createManual(
destImageRot,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
width, height,
0,
PF_FLOAT16_RGBA,
TU_RENDERTARGET);

RenderTarget* rtt = destTexture->getBuffer()->getRenderTarget();
RenderTarget* rtt = destTextureRot->getBuffer()->getRenderTarget();
rtt->setAutoUpdated(false);
Viewport* vp = rtt->addViewport(camera);
vp->setOverlaysEnabled(false);
Expand All @@ -66,7 +68,20 @@ void ImageRotate::rotate(const std::string& sourceImage, const std::string& dest

rtt->update();

//copy the rotated image to a static texture
TexturePtr destTexture = TextureManager::getSingleton().createManual(
destImage,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
width, height,
0,
PF_FLOAT16_RGBA,
Ogre::TU_STATIC);

destTexture->getBuffer()->blit(destTextureRot->getBuffer());

// remove all the junk we've created
TextureManager::getSingleton().remove(destImageRot);
MaterialManager::getSingleton().remove("ImageRotateMaterial");
root->destroySceneManager(sceneMgr);
delete rect;
Expand Down
2 changes: 1 addition & 1 deletion libs/openengine/ogre/renderer.cpp
Expand Up @@ -226,7 +226,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
1, 1,
0,
Ogre::PF_A8R8G8B8,
Ogre::TU_DYNAMIC_WRITE_ONLY);
Ogre::TU_WRITE_ONLY);
}

void OgreRenderer::createScene(const std::string& camName, float fov, float nearClip)
Expand Down

0 comments on commit 20e624e

Please sign in to comment.