
Use external images
Moderators: CEGUI MVP, CEGUI Team
Use external images
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... 

- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
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

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
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 ?
Edit: I didn't find CEGUI::StaticImage in the doc and the compiler refuse it. What is a StaticImage in fact ? How use it ?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
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.
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.
The two tests return true. My code is:
Where "GestionnaireDonnees" is an image manager I created. The result on the console is:
Edit: The image class I use: http://www.sfml-dev.org/documentation/classsf_1_1Image.htm
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
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
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).
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).
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Hi,
i a not sure whether the Texture dimensions should be a power of two. Maybe you can try to play with that.
HTH.
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!
scriptkid -> Normally, it is calculated automatically.
The program stop directly when I use:
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.
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.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
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
I found it int he CEGUI log:
but there is also these lines after imageset delcaration:
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");
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
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.
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.
Who is online
Users browsing this forum: No registered users and 15 guests