Image
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
Image
Jsut a quick question i didn;t see in the tutorials:
i made a nice little title screen in paint and was wodnering how i import it into Irrlicht and then how to display it?
i made a nice little title screen in paint and was wodnering how i import it into Irrlicht and then how to display it?
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
ok cool got it on there with
device->getGUIEnvironment()->addImage(
driver->getTexture("media/Title_Screen.jpg"),
core::position2d<s32>(0,0));
(its in the main loop if it makes any difference)
but my question now is what is the command to remove it, i got i tal set up to
remove the image when the enter key is pressed, but i don't know hte actually command to remove the image. Anyone know what that command is?
device->getGUIEnvironment()->addImage(
driver->getTexture("media/Title_Screen.jpg"),
core::position2d<s32>(0,0));
(its in the main loop if it makes any difference)
but my question now is what is the command to remove it, i got i tal set up to
remove the image when the enter key is pressed, but i don't know hte actually command to remove the image. Anyone know what that command is?
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
try
IGUIImage* m_pMyImage;
m_pMyImage = device->getGUIEnvironment()->addImage(
driver->getTexture("media/Title_Screen.jpg"),
core::position2d<s32>(0,0));
then
m_pMyImage ->setVisible(false);
to make invisible or
m_pMyImage->remove();
to remove it
Just a suggestion.. you may want to get IrrWizird an make a project and see how it does things
IGUIImage* m_pMyImage;
m_pMyImage = device->getGUIEnvironment()->addImage(
driver->getTexture("media/Title_Screen.jpg"),
core::position2d<s32>(0,0));
then
m_pMyImage ->setVisible(false);
to make invisible or
m_pMyImage->remove();
to remove it
Just a suggestion.. you may want to get IrrWizird an make a project and see how it does things
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
Code: Select all
m_pMyImage ->setVisible(false);
to make invisible or
m_pMyImage->remove();
to remove it
could you explain more about it not working.
It works in IrrWizard CMenuState and I did a small test to make sure.
If it doesnt work for you then maybe something else is wrong. Is your IGUIImage* pointer global or part of a class that is not destroyed so that it is valid after the addImage function is called?.
It works in IrrWizard CMenuState and I did a small test to make sure.
If it doesnt work for you then maybe something else is wrong. Is your IGUIImage* pointer global or part of a class that is not destroyed so that it is valid after the addImage function is called?.
-
- Posts: 16
- Joined: Sat May 06, 2006 4:36 am
i figured out a way around hte problem at least. I guess irrlicht has 2 ways of laoding 2d images.. the 1 i used from the tutorials was about how to put the irrlicht logo on it.
device->getGUIEnvironment()->addImage(
driver->getTexture("../../media/irrlichtlogoalpha2.tga"),
core::position2d<s32>(10,10));
i assume this way was created to place logo's, so there was no need to remove htem.
So i tried the other way, i used it like i was creating a 2d game:
loaded it b4 the main loop:
video::ITexture* titleScreen = driver->getTexture("media/Title_Screen.jpg");
then in the mainloop it looks like:
if (titlescreen == 1) {
driver->draw2DImage(titleScreen, core::position2d<s32>(0,0),
core::rect<s32>(0,0,1024,768), 0,
video::SColor(255,255,255,255), false);
}
and when i press enter it makes titlescreen equal to 0 and it no longers displays it.
I assume this is because the first method, for the logo just has it build into the GUI, where as the second method updates it every loop of the game. Hope that helps any1 out and htank you all for your sugestions =]
device->getGUIEnvironment()->addImage(
driver->getTexture("../../media/irrlichtlogoalpha2.tga"),
core::position2d<s32>(10,10));
i assume this way was created to place logo's, so there was no need to remove htem.
So i tried the other way, i used it like i was creating a 2d game:
loaded it b4 the main loop:
video::ITexture* titleScreen = driver->getTexture("media/Title_Screen.jpg");
then in the mainloop it looks like:
if (titlescreen == 1) {
driver->draw2DImage(titleScreen, core::position2d<s32>(0,0),
core::rect<s32>(0,0,1024,768), 0,
video::SColor(255,255,255,255), false);
}
and when i press enter it makes titlescreen equal to 0 and it no longers displays it.
I assume this is because the first method, for the logo just has it build into the GUI, where as the second method updates it every loop of the game. Hope that helps any1 out and htank you all for your sugestions =]
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
are you kidding???
IGUIEnvironment::addImage is meant for what you want but, you are not supposed to call that function every frame. just once to add the image. after that you can alter its state. example:
pressing s makes the element visible and pressing h hides it.
you could also call remove but then u should set the pointer to zero.
IGUIEnvironment::addImage is meant for what you want but, you are not supposed to call that function every frame. just once to add the image. after that you can alter its state. example:
Code: Select all
#include <irrlicht.h>
using namespace irr;
class Receiver : public IEventReceiver
{
public:
gui::IGUIElement* Element;
bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
{
if (event.KeyInput.Key == KEY_KEY_S)
Element->setVisible(true);
else if (event.KeyInput.Key == KEY_KEY_H)
Element->setVisible(false);
}
}
};
int main(int argc, char* argv[])
{
/*
CMyApp app(argc, argv);
app.Init();
app.registerProcess();
app.Run();
*/
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640,480));
video::IVideoDriver* driver = device->getVideoDriver();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
Receiver reciever;
reciever.Element = gui->addImage(driver->getTexture("media/irrlichtlogoalpha2.tga"), core::position2d<s32>(10,10));
device->setEventReceiver(&reciever);
while (device->run() && driver)
{
driver->beginScene(true, true, video::SColor(255,0,0,255));
gui->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
you could also call remove but then u should set the pointer to zero.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.