How to blend Irrlicht with SDL?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

How to blend Irrlicht with SDL?

Post by The BasheR »

Hi all, i would like to use the GUI interface of Irrlicht and the SDL functions, but when i try the program exits violently and i don't know why :(
I just know that is the blend of Irrlicht and SDL who products this bug :(

So is someone can tell me how to do to display an image with SDL, in an Irrlicht's environment?

This is a sheet of my code:

Code: Select all

while(Device->run() && driver)
   {
		if (Device->isWindowActive())
		{
			driver->beginScene(true, true, video::SColor(255,245,245,245));
			smgr->drawAll();
			env->drawAll();

			/* SDL code */
			if(surface != NULL)
			{
			   pos.x = SDL_GetVideoSurface()->w/2 - surface->w/2;
            pos.y = SDL_GetVideoSurface()->h/2 - surface->h/2;

			   SDL_BlitSurface(surface, NULL, SDL_GetVideoSurface(), &pos);
			   SDL_Flip(SDL_GetVideoSurface());
			}

			driver->endScene();
		}
   }
Thanks a lot
When you want you can!
Quand on veut on peut!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Why would you want to do that? Irrlicht can also display images! But it might be possible to use an external window and pass it to Irrlicht to let it draw the GUI. SDL would work on the external window directly. Or you might want to check out the experimental SDL device from SVN. It uses SDL to create the Irrlicht window, i.e. you have a real SDL window underneath. this might simplify the mixture.
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Ok so i think i'm going to blend SDL with GTK, that might be simpler.
When you want you can!
Quand on veut on peut!
Perceval
Posts: 158
Joined: Tue May 30, 2006 2:42 pm

Post by Perceval »

Ok so i think i'm going to blend SDL with GTK, that might be simpler.
What would be simpler would be to use Irrlicht to display your pictures :lol:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

On the other hand, using just Irrlicht's GUI might be also inappropriate. Irrlicht's a 3d engine, not a GUI toolkit. So if he just uses the GUI without the 3d functions of Irrlicht there are probably better solutions than plain Irrlicht.
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Actually i want to use SDL because i want to make a program to modify images, and i only know how to do with SDL, and I don't think Irrlicht is able to do that.
When you want you can!
Quand on veut on peut!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Still you'd only use Irrlicht's GUI, right? That's not the way one should use Irrlicht. If you don't need 3d graphics (or 3d look-alike 2d graphics) Irrlicht is probably not what you want.
Irrlicht has some image manipulation features, but of course it is not intended as a graphics manipulation library. Again, there are others to do so. But, you'd be able to use shaders to do the stuff which might speed up your manipulations...
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Yes actually at the beginning i wanted to use Irrlicht with the SDL because the interfaces with Irrlicht are very simply :)

But i'm learning GTK+ and I am going to do that with it.
When you want you can!
Quand on veut on peut!
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

Post by eneru »

speaking of irrlicht and SDL, i think i am going to use SDL to handle the keyboard events, so is there a way to make these SDL events work with irrlicht ? :)

I'd gladly use the irrlicht keyboard events, but it seems that it keeps sending unwanted info when we push a button ==> instead of sending 1 event when we push a button, and another one when we release it, it keeps sending "pushed " and "released" events, which screws things up badly... :(
Please tell me there is a way to change this behavior ^^
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The key repeat is not changeable, we want to make this the same on all platforms, though (but still don't know how...).
In order to use the SDL events you should use the SDL device. This uses the SDL event queue. It's available from the SVN version. Please note that I did not really test it under Windows, yet, as I did not intend to use it there. It seemed to have severe problems with event handling on that platform, while it worked under Linux. But I'm willing to check it as soon as someone tests it (i.e. you can be sure that I'll try to help if you dare to use it 8) )
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

Post by eneru »

i will definitely have to use SDL if irrlicht keys' behaviour is not changeable ;)
... I didn't believe it when a friend of mine who made some tests told me about it though, because irrlicht being destined to 3D gaming (mainly), it would seem more logical to not repeat the key events like that (the character keeps sending events saying he is beginning to advance, then stop, then advance, and so on, which of course screws up the animations badly).


===============


So, about your tests on SDL : it works well under linux but seem to have problems with windows ? are they due to irrlicht or to SDL only ? (i will test it as soon as i'll have some code ready, but it might be not before one or 2 weeks (because of exams and such awful events lol) :))
Your help will be more than welcome of course ;p (i will surely create a new thread dedicated to it)

This said, i have one last question about irrlicht + SDL : if i use SDL for the mouse too (while i am at it), will it work right with the irrlicht GUI ? (=> i am not used to SDL yet (nor to irrlicht :p), but will the coordinates i will retrieve from the mouse correspond to where the mouse is in the irrlicht window ?... other than that i can't think of any problem, but if you know about some it would be nice for you to tell me about it :D)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The key repeat feature simply has to be handled by your app - one or the other way. It just should be the same on all architectures. How'd you do a GUI with key repeat then? Starting a timer when a key is pressed? Just use the bool-keys technique and don't do anything if the key was already pressed!
I think the Windows problems are in the SDL code of the Irrlicht device. There is something missing, or maybe it was just a compiling problem on my side. I did not really test it too much under windows.
The mouse should work as expected. If not there is a cursor control class in the device which does all the transformations etc. So it could be adapted.
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

Post by eneru »

hybrid wrote:The key repeat feature simply has to be handled by your app - one or the other way. It just should be the same on all architectures. How'd you do a GUI with key repeat then? Starting a timer when a key is pressed? Just use the bool-keys technique and don't do anything if the key was already pressed!
About the GUI, i guess i'll have to play with timers though i'd really like to be able to use the irrlicht key events if i could use them as i want.. => what is this bool key technique ? What would be great would be if the irrlicht key event sent key pressed events while the key is pressed, allowing key repeat feature without having the problem we have now (as he sends key released events too, the walking (by example) keeps starting and stopping, which wouldn't happen if only the key pressed events were to be sent repeatedly)
I don't want to search too deeply into irrlicht events if i will have to use SDL instead later, but if you say that these events can work as i said earlier (with this bool key technique..? maybe looking at the state of the key while receiving the key released event will be able to tell me if it was really released or not ?) i'll definitly search more into that direction !

Thanks a lot anyway, you are of great help :D
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No problem, I'm always glad to help. You should search for 'bool AND keys' or check the Irrlicht Wiki to find something about it.
Do you use the Linux or Win32 device? I though that only Linux device sends both events?!
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

Post by eneru »

i use linux along with most of my friends (we are beginning working on a little irrlicht game demo), and some are using windows too, but anyway it is supposed to be cross platform ;)

i'll look into what you said tomorrow, thanks a lot for the help :)


edit : the most interestings threads i found are :
- one which is in the FAQs forum about these bool keys : http://irrlicht.sourceforge.net/phpBB2/ ... ys&start=0
- it seemed good but the other one, more recent, isn't as pleasant : http://irrlicht.sourceforge.net/phpBB2/ ... =bool+keys

vitek and xskinyx codes using the bool keys don't seem to be of help under linux according to the others :/
Post Reply