Ogre texture to CEGUI texture

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

Ogre texture to CEGUI texture

Postby Lastmerlin » Sun Mar 01, 2009 17:31

I want to convert an Ogre::TexturePtr to a CEGUI::Texture.

There are several Code examples around, but I get an error for each one ^^

This is how I create the Ogre Texture:

Code: Select all

Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "minimap_tex",
         Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
   512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET );


Now three attempts for the CEGUI Texture:
1. based on Ogre wiki
http://www.ogre3d.org/wiki/index.php/File_DialogBuild.cpp

Code: Select all

CEGUI::OgreCEGUITexture* ceguiTex = (CEGUI::OgreCEGUITexture*) CEGUI::System::getSingleton().getRenderer()->createTexture();
ceguiTex->setOgreTexture(texture);


2. Based on Ogre tutorial
http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_7

Code: Select all

CEGUI::OgreCEGUITexture* ceguiTex = (CEGUI::OgreCEGUITexture*) CEGUI::System::getSingleton().getRenderer()->createTexture((CEGUI::utf8*)"minimap_tex");


3. Based on some forum thread here

Code: Select all

CEGUI::OgreCEGUITexture* ceguiTex = (CEGUI::OgreCEGUITexture*) CEGUI::System::getSingleton().getRenderer()->createTexture(texture);


The first one gives a linking error
undefined reference to `CEGUI::OgreCEGUITexture::setOgreTexture(Ogre::TexturePtr&)'

while the latter two give the compile time error that I am calling createTexture with wrong arguments. I guess the first attempt is closest to the solution.

Concerning the linker error: I am already using these libs:
pkg-config --libs CEGUI-OGRE
-lCEGUIOgreRenderer -lOgreMain -lCEGUIBase

whats missing ?

Thank you very much :)

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sun Mar 01, 2009 19:14

Hi,

I'm not sure why you get the undefined reference error, it seems strange. This probably means the solution is staring us in the face :lol:

In order to use the 'other' approach, you basically require either to cast the renderer returned from CEGUI::System to the CEGUI::OgreCEGUIRenderer (which is only to require the Ogre specific renderer header; it contains a default for the resourceGroup second parameter), or specify the second parameter explicitly yourself as, probably "General".

So:

Code: Select all

CEGUI::OgreCEGUITexture* ceguiTex = (CEGUI::OgreCEGUITexture*)((OgreCEGUIRenderer*)CEGUI::System::getSingleton().getRenderer())->createTexture((CEGUI::utf8*)"minimap_tex");

or

Code: Select all

CEGUI::OgreCEGUITexture* ceguiTex = (CEGUI::OgreCEGUITexture*)CEGUI::System::getSingleton().getRenderer()->createTexture((CEGUI::utf8*)"minimap_tex", "General");


HTH

CE

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

Postby Lastmerlin » Mon Mar 02, 2009 21:01

Thanks, code is compiling now - although not doing what it is intended to do so far :lol:
I hope to get that fixed on my own

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Postby Van » Mon Mar 02, 2009 23:39

CEGUI: 0.6.2
Ogre: 1.6.2


Here is how we do it

Code: Select all


   // Create an Ogre Render To Texture process.
   Ogre::TexturePtr mTexturePtr = Ogre::TextureManager::getSingleton().createManual(
      "Hangar/Ship/Display/RTT",
      Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
      Ogre::TEX_TYPE_2D,
      512, 512,
      0,
      Ogre::PF_B8G8R8A8,   // <<< Note we use an ALPHA channel for transparency.
      Ogre::TU_RENDERTARGET );
     
   Ogre::RenderTarget *mRTT = mTexturePtr->getBuffer()->getRenderTarget();


... Some code for Ogre to create cameras and stuff ...

   // Create CEGUI texture from the Ogre RTT
   CEGUI::Texture *mTexture = mGlobalResource->CEGUIRenderer->createTexture( "Hangar/Ship/Display/RTT" );

   // Create CEGUI Imageset
   CEGUI::Imageset *mRTTImageSet = CEGUI::ImagesetManager::getSingleton().createImageset( "Hangar/Ship/Display/ImageSet", mTexture );
   
   // Define a CEGUI Image
   mRTTImageSet->defineImage(
      "Hangar/Ship/Display/Image",
      CEGUI::Point( 0.0f, 0.0f ),
      CEGUI::Size( mTexture->getWidth(), mTexture->getHeight() ),
      CEGUI::Point( 0.0f, 0.0f ) );

   // Set the Image in the StaticImage widow.
   mSIShipImage->setProperty( "Image", "set:Hangar/Ship/Display/ImageSet image:Hangar/Ship/Display/Image" );




Return to “Help”

Who is online

Users browsing this forum: No registered users and 26 guests