Use external images

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

User avatar
Yoha
Just popping in
Just popping in
Posts: 6
Joined: Thu Apr 17, 2008 12:48

Use external images

Postby Yoha » Fri Apr 18, 2008 13:44

Hi, I would like to use a CEGUI Interface with SFML (there is a version in english too). I successed to compile and use an interface. My problem is: I want to use images from files wich are not frameset and no in repertories of CEGUI in a Window of CEGUI but I don't know how do it. If someone can help me... :roll:

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

Postby CrazyEddie » Sat Apr 19, 2008 08:52

Hi, and welcome :)

I've not looked at SFML at all so what I say here is just general descriptions of how things are.

As you may know, currently all imagery used by CEGUI needs to be defined in an Imageset somehow. That somehow is important, since it does not mean you have load the Imageset from a graphic file and xml definition.

Generally the approach will be:
1) obtain the image / texture from the engine (in this case SFML)
2) use this base level imagery to create a CEGUI::Texture (the interface / renderer module will hopefully provide a means of doing that)
3) use the CEGUI::Texture to create a CEGUI::Imageset in code using the ImagesetManager
4) define images on the newly created CEGUI::Imageset
5) use the new Imageset images as normal.

HTH

CE

User avatar
Yoha
Just popping in
Just popping in
Posts: 6
Joined: Thu Apr 17, 2008 12:48

Postby Yoha » Sat Apr 19, 2008 10:41

Thanks. I think I loaded the image but I can't draw it on the screen. I tried to do it with setMouseCursor on a FrameWindow but it do nothing. The cursor is not displayed. How can I get sure the image is loaded or no ?

Edit: I didn't find CEGUI::StaticImage in the doc and the compiler refuse it. What is a StaticImage in fact ? How use it ?

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

Postby CrazyEddie » Sun Apr 20, 2008 08:29

Please post some code or whatever showing what you're doing. To be sure the image is loaded you can use ImagesetManager::isImagesetPresent and Imageset::isImageDefined

The StaticImage is actually a simple DefaultWindow - everything else is handled via a combination of the window renderer (most likely Falagard/StaticImage) and looknfeel skin.

CE.

User avatar
Yoha
Just popping in
Just popping in
Posts: 6
Joined: Thu Apr 17, 2008 12:48

Postby Yoha » Sun Apr 20, 2008 08:45

The two tests return true. My code is:

Code: Select all

sf::Image* image = new sf::Image(*GestionnaireDonnees->GetImage(7));
CEGUI::Texture* texture = mRenderer->createTexture( (image->GetWidth() > image->GetHeight() ? image->GetWidth() : image->GetHeight()) );
texture->loadFromMemory(image->GetPixelsPtr(), image->GetWidth(), image->GetHeight(), CEGUI::Texture::PF_RGBA);
CEGUI::Imageset* test = CEGUI::ImagesetManager::getSingleton().createImageset("test", texture);
test->defineImage("ImgTest", CEGUI::Rect(0, 0, 64, 64), CEGUI::Point(0, 0) );
CEGUI::Image testImg = test->getImage("ImgTest");
m_win->setMouseCursor(&testImg);

std::cout << "ImageSet: " << CEGUI::ImagesetManager::getSingleton().isImagesetPresent("test") << "\n";
std::cout << "Image: " << test->isImageDefined("ImgTest") << "\n";


Where "GestionnaireDonnees" is an image manager I created. The result on the console is:

Code: Select all

ImageSet: 1
Image: 1


Edit: The image class I use: http://www.sfml-dev.org/documentation/classsf_1_1Image.htm

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

Postby CrazyEddie » Mon Apr 21, 2008 08:45

Well it seems the thing is getting created, but the data is not getting transferred to the texture properly.

Is there some way you can dump the underlying texture content to see what is getting transferred?

Rather than setting the image as the cursor on a frame window, can you set it as the default mouse cursor (this way you know it's definitely going to get used - even if nothing eventually shows up).

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Mon Apr 21, 2008 10:06

Hi,

i a not sure whether the Texture dimensions should be a power of two. Maybe you can try to play with that.

HTH.
Check out my released snake game using Cegui!

User avatar
Yoha
Just popping in
Just popping in
Posts: 6
Joined: Thu Apr 17, 2008 12:48

Postby Yoha » Wed Apr 23, 2008 11:17

scriptkid -> Normally, it is calculated automatically.

The program stop directly when I use:

Code: Select all

frame->setMouseCursor(&testImg);


Where frame is the Window returned by the loadWindowLayout method.


I don't understand the mean of "Is there some way you can dump the underlying texture content to see what is getting transferred?". If I have to test if the image is loaded well by SFML, I used it and it runs.

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

Postby CrazyEddie » Thu Apr 24, 2008 18:43

Yoha wrote:I don't understand the mean of "Is there some way you can dump the underlying texture content to see what is getting transferred?". If I have to test if the image is loaded well by SFML, I used it and it runs.


Ok. Let me try to explain. What is currently happening is this:

1) You load the image into SFML
2) You create a CEGUI texture of the required dimension.
3) You load the data from the SFML image to the CEGUI texture - this should copy the pixel data from one buffer to another.

What I meant was, is there a way to examine the underlying SFML buffer/texture created in step 2, after the data has been copied in step 3 - because it seems the data may not be getting copied correctly.

CE

User avatar
Yoha
Just popping in
Just popping in
Posts: 6
Joined: Thu Apr 17, 2008 12:48

Postby Yoha » Sat Apr 26, 2008 14:43

I found it int he CEGUI log:

Code: Select all

26/04/2008 16:36:50 (Std)    Attempting to create Imageset 'test' with texture only.


but there is also these lines after imageset delcaration:


Code: Select all

test->defineImage("ImgTest", CEGUI::Rect(0, 0, 64, 64), CEGUI::Point(0, 0) );
CEGUI::Image testImg = test->getImage("ImgTest");

User avatar
Yoha
Just popping in
Just popping in
Posts: 6
Joined: Thu Apr 17, 2008 12:48

Postby Yoha » Fri May 02, 2008 16:20

Nobidy knows how I can do it ?

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

Postby CrazyEddie » Mon May 05, 2008 07:54

To reiterate...

I think there is an issue with how the pixel data is getting transferred to the texture used for the 'test' imageset; not that the creation of the imageset or image fails, we have clearly established that is happening correctly.

What you need is to confirm that the pixel data in the texture used is what it should be (not the original version, but the copy made when the loadFromMemory call is made). One way you might do this is to to get the engine to render the entire texture to the screen.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 15 guests