SDL2 and Irrlicht 1.9
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
SDL2 and Irrlicht 1.9
Does the latest irrlicht 1.9 svn trunk come with support for SDL2?
i saw this flag: #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
inside source/irrlicht/CIrrDeviceSDL.cpp
Just wondering how this works has anyone got an example? and does it work with SDL2?
i saw this flag: #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
inside source/irrlicht/CIrrDeviceSDL.cpp
Just wondering how this works has anyone got an example? and does it work with SDL2?
Re: SDL2 and Irrlicht 1.9
Sorry, SDL2 patch is still open and I haven't continued work on it for last 6 months *sigh*(and yeah, I know SDL3 is out by now). And there's some other open todo's which have higher priority right now, so it'll probably still take a while until I get to it.
You could patch Irrlicht with the patch from Minetest: https://github.com/minetest/irrlicht/co ... 9624cf3d61
And it will be very similar to the final patch Irrlicht will get, thought not sure yet if exactly identical (I won't replace the existing device so this will be called CIrrDeviceSDL2 for example. Also I'm trying to backport it to 1.8 first, thought I might give up on that, not sure yet).
Thought in general you shouldn't need SDL device often - unless you target some specific platforms which Irrlicht doesn't support yet.
You could patch Irrlicht with the patch from Minetest: https://github.com/minetest/irrlicht/co ... 9624cf3d61
And it will be very similar to the final patch Irrlicht will get, thought not sure yet if exactly identical (I won't replace the existing device so this will be called CIrrDeviceSDL2 for example. Also I'm trying to backport it to 1.8 first, thought I might give up on that, not sure yet).
Thought in general you shouldn't need SDL device often - unless you target some specific platforms which Irrlicht doesn't support yet.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
Re: SDL2 and Irrlicht 1.9
Ahh i see, wait the patch is only 7 files? lol that doesnt seem too bad. Do i just apply patch then add _IRR_COMPILE_WITH_SDL_DEVICE_ to the preprocessor #defines ?
Re: SDL2 and Irrlicht 1.9
Maybe. I'm going through patches line-by-line usually, so I've not finished with that one and can't tell.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: SDL2 and Irrlicht 1.9
I am using SDL2 myself but I am not using that specific patch. This patch looks pretty similiar to my custom device however. You should just be able to add that flag to your compiler defines when building irrlicht. If you want to handle events through SDL2 directly rather than irrlicht's event handler then you can also checkout my custom device here: https://github.com/n00b87/RCIrrlicht/tree/sdl2_device
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
Re: SDL2 and Irrlicht 1.9
Thank you so much, So i've managed to apply the patch to the latest 1.9 using SDL2 However im a bit confused how to setup the SDL2 with irrlicht
do you maybe have an example how i can use the D3D9 renderer, with SDL2, and mix in custom SDL_RenderCopy with irrlictht draw calls?
Hmm i got pretty far but i keep getting an error now after this point saying:
Irrlicht Engine version 1.9.0
SDL initialized
SDL Version 2.30.1
Using renderer: Direct3D 9.0
NVIDIA GeForce GTX 1080 Ti nvldumd.dll 32.0.15.6636
Was not able to create Direct3D9 device.
Was not able to create DIRECT3D9 device.
Quit SDL
And here is code when trying to initalize irrlicht:
Any ideas?
do you maybe have an example how i can use the D3D9 renderer, with SDL2, and mix in custom SDL_RenderCopy with irrlictht draw calls?
Hmm i got pretty far but i keep getting an error now after this point saying:
Irrlicht Engine version 1.9.0
SDL initialized
SDL Version 2.30.1
Using renderer: Direct3D 9.0
NVIDIA GeForce GTX 1080 Ti nvldumd.dll 32.0.15.6636
Was not able to create Direct3D9 device.
Was not able to create DIRECT3D9 device.
Quit SDL
Code: Select all
void CIrrDeviceSDL::createDriver()
{
HWND wind = static_cast<HWND>(CreationParams.WindowId);
switch (CreationParams.DriverType)
{
case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
os::Printer::log("DIRECT3D8 Driver is no longer supported in Irrlicht. Try another one.", ELL_ERROR);
break;
case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, wind);
#else
os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
break;
Code: Select all
if (SDL_Init(SDL_INIT_EVENTS | SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_SENSOR | SDL_INIT_NOPARACHUTE) < 0) //Audio causes init to fail on Fedora40 so I am leaving it out for now
{
//os::Printer::log("SDL_Init Error: ", SDL_GetError());
std::cout << "No DICE" << std::endl;
return 0;
}
SDL_Window* window = SDL_CreateWindow("D3D9 SDL2 Test Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);
SIrrlichtCreationParameters params;
params.DriverType = video::EDT_DIRECT3D9;
params.WindowSize = core::dimension2d<u32>(800, 600);
params.Bits = 32;
params.Fullscreen = false;
params.Stencilbuffer = true;
params.Vsync = true;
params.AntiAlias = true;
params.EventReceiver = this;
params.DeviceType = EIDT_SDL;
params.WindowId = window;
Re: SDL2 and Irrlicht 1.9
You need to use opengl for your video driver.
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
Re: SDL2 and Irrlicht 1.9
Theres no way around that?
Re: SDL2 and Irrlicht 1.9
Not with SDL2. SDL2 can give you a rendering context for opengl or a rendering surface for vulkan or metal. When you think about it, it does make sense for them not to provide a directx renderer since the directx API provides all the window handling and input itself.
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
Re: SDL2 and Irrlicht 1.9
Ahhh i kinda get what your saying i guess its just not easily possible to somehow join the two into one window unless you use those render contexts, i was kinda hoping i could somehow use SDL_Rendercopy for 2D stuff and then use Irrlicht for 3D stuff but now that i think about it, its probably just easier to use irrlichts built in 2D rendering anyways. I didn't really care much for the SDL input since i'm mainly just making everything primarily for Windows anyways.n00bc0de wrote: Sun Jan 19, 2025 9:47 pmNot with SDL2. SDL2 can give you a rendering context for opengl or a rendering surface for vulkan or metal. When you think about it, it does make sense for them not to provide a directx renderer since the directx API provides all the window handling and input itself.
Re: SDL2 and Irrlicht 1.9
Using an SDL2 device is really only useful if you want the window handling and input from SDL2. SDL_RenderCopy is a function that is only designed to be used with SDL2s rendering API and SDL2 keeps full control of the rendering context so irrlicht would probably not even be able to render at all or it would have random black screens or other graphical glitches.
Irrlicht's 2D rendering API is actually very similiar to SDL2. I was able to implement animated sprites and tile maps in irrlicht pretty easy. The reason for SDL2 is that it does give you options irrlicht does not have like creating borderless windows or better gamepad support. With the joystick support, irrlicht does not support rumble and I have had some issues with hotswapping.
It also makes it easier to port to other platforms since SDL runs on everything including game consoles. If you only need web or mobile support, irrlicht will build for those platforms out of the box.
Irrlicht's 2D rendering API is actually very similiar to SDL2. I was able to implement animated sprites and tile maps in irrlicht pretty easy. The reason for SDL2 is that it does give you options irrlicht does not have like creating borderless windows or better gamepad support. With the joystick support, irrlicht does not support rumble and I have had some issues with hotswapping.
It also makes it easier to port to other platforms since SDL runs on everything including game consoles. If you only need web or mobile support, irrlicht will build for those platforms out of the box.
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
Re: SDL2 and Irrlicht 1.9
This makes sense, actually im a bit shocked that irrlicht doesnt support borderless windows out the box? I found this thread viewtopic.php?t=45905 i thought this would of got patched into irrlicht by now?n00bc0de wrote: Sun Jan 19, 2025 11:02 pm Using an SDL2 device is really only useful if you want the window handling and input from SDL2. SDL_RenderCopy is a function that is only designed to be used with SDL2s rendering API and SDL2 keeps full control of the rendering context so irrlicht would probably not even be able to render at all or it would have random black screens or other graphical glitches.
Irrlicht's 2D rendering API is actually very similiar to SDL2. I was able to implement animated sprites and tile maps in irrlicht pretty easy. The reason for SDL2 is that it does give you options irrlicht does not have like creating borderless windows or better gamepad support. With the joystick support, irrlicht does not support rumble and I have had some issues with hotswapping.
It also makes it easier to port to other platforms since SDL runs on everything including game consoles. If you only need web or mobile support, irrlicht will build for those platforms out of the box.
Also if the SDL2 only works with opengl or vulkan contexts.. that doesnt help me wanting to use DX9 driver..
Re: SDL2 and Irrlicht 1.9
Pretty much same reason as always - way more open todo's than developers. I think even if I had a year full-time for Irrlicht I would have no chance to get through my todo-list (which I don't have anyway, usually just rare spare-time). There's lots of things which only would cost a day or two on it :-(
In this case the additional problem that the patch file either wasn't attached or got removed at some point for an unknown reason. And it had some open points mentioned in the thread, so it's maybe not a quick thing to solve either.
That said - yes, borderless windows are a thing which we should have. Someone make a patch with test and it has a good chance I'll spend some time on it.
In this case the additional problem that the patch file either wasn't attached or got removed at some point for an unknown reason. And it had some open points mentioned in the thread, so it's maybe not a quick thing to solve either.
That said - yes, borderless windows are a thing which we should have. Someone make a patch with test and it has a good chance I'll spend some time on it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 25
- Joined: Sun Jan 12, 2025 3:31 pm
- Location: New Zealand
Re: SDL2 and Irrlicht 1.9
Hey so yeah the attachment for the patch was removed i found it using waybackmachine:CuteAlien wrote: Wed Jan 22, 2025 11:02 am Pretty much same reason as always - way more open todo's than developers. I think even if I had a year full-time for Irrlicht I would have no chance to get through my todo-list (which I don't have anyway, usually just rare spare-time). There's lots of things which only would cost a day or two on it
In this case the additional problem that the patch file either wasn't attached or got removed at some point for an unknown reason. And it had some open points mentioned in the thread, so it's maybe not a quick thing to solve either.
That said - yes, borderless windows are a thing which we should have. Someone make a patch with test and it has a good chance I'll spend some time on it.
You can download the patch and maybe take a look at it?
https://web.archive.org/web/20151106035 ... ment/patch
As for the open todo-list i totally get it and i wasn't trying to add more to the list, was just kinda sad that there's not some quick solutions to basic needs lol. For example im gonna need to look into an IrrTTF next aswell

Re: SDL2 and Irrlicht 1.9
There is already an irrlicht TTF library. Check this thread: viewtopic.php?f=6&t=37296Elevations wrote: Wed Jan 22, 2025 5:05 pm For example im gonna need to look into an IrrTTF next aswell![]()