load texture from memory problem

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

richy
Just popping in
Just popping in
Posts: 3
Joined: Sat Oct 28, 2006 12:25

load texture from memory problem

Postby richy » Sun Oct 29, 2006 02:20

im trying to load a texture from memory with the code:

from minimap class

Code: Select all

#define MAXSIZE 900
int *m_pMapBuffer[MAXSIZE];

MiniMap::MiniMap(void)
{
   for (int i = 0; i < MAXSIZE; i++)
   {
      m_pMapBuffer[i] = (int*)RGB(120,120,120);
   }
}
MiniMap* MiniMap::pGS()
{
   static MiniMap MiniMapInstance;
   return &MiniMapInstance;
}
void* MiniMap::getMiniMap()
{
   return &m_pMapBuffer;
}


from game class

Code: Select all

CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::StaticImage* img = (CEGUI::StaticImage*)wmgr.getWindow((CEGUI::utf8*)"MiniMap");
CEGUI::Renderer* render = mGUISystem->getRenderer();
CEGUI::Texture* text;

text = render->createTexture();
text->loadFromMemory(MiniMap::pGS()->getMiniMap(),30,30);

CEGUI::Imageset* imageSet = CEGUI::ImagesetManager::getSingleton().createImageset("MiniMap", text);
imageSet->defineImage("MiniMap", CEGUI::Point(0.0,0.0), CEGUI::Size(30,30), CEGUI::Point(0.0,0.0));
img->setImage(&imageSet->getImage((CEGUI::utf8*)"MiniMap"));
img->show();



I've tested it with an image from disk and it displays fine, just when i do loadFromMemory it displays nothing.

Please help,


thanks

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Sun Oct 29, 2006 11:26

Textures need to be powers of two. try 32x32 instead

richy
Just popping in
Just popping in
Posts: 3
Joined: Sat Oct 28, 2006 12:25

Postby richy » Sun Oct 29, 2006 15:06

I changed MAXSIZE to 1024, the temp function to devidex by 10000*16 inszted of 10000*15 and text->loadFromMemory(MiniMap::pGS()->getMiniMap(),32,32); and imageSet->defineImage("MiniMap", CEGUI::Point(0.0,0.0), CEGUI::Size(32,32), CEGUI::Point(0.0,0.0));

but it still displays black, I also tried using unsigned ints for m_pMapBuffer and still only black, it should display a grey.

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

Postby CrazyEddie » Sun Oct 29, 2006 16:55

Hi,

I think this is probably an issue with the pixel format; you need an alpha component too, I'm not sure what:

Code: Select all

RGB(120,120,120);
returns, but if it returns something that has 0 where the alpha would be, then this is why you are getting nothing.

So, my advice would be to check the format of the data you are providing to loadFromMemory.

HTH

CE.

richy
Just popping in
Just popping in
Posts: 3
Joined: Sat Oct 28, 2006 12:25

Postby richy » Mon Oct 30, 2006 06:03

worked awesome, thanks guys. I used

Code: Select all

(unsigned int*)((181 <<  0) |(181 <<  8) |(181 << 16) |(255 << 24));

insted.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 22 guests