SDL Device correctly processing events?

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
despair
Posts: 1
Joined: Wed Aug 16, 2017 7:27 am

SDL Device correctly processing events?

Post by despair »

Is the Irrlicht SDL device binding correctly processing input/window focus events? I am unable to get it to stop rendering when the focus is released, or when the window is minimised.

How to reproduce: create any irrlicht device using type EIDT_SDL, and insert code that occurs when device->isWindowActive() or device->isWindowMinimized().

Expected: when the device window loses focus, the loop falls through to the next code that occurs when the window is NOT active. When the device is minimised, the loop additionally jumps to the code when the device is minimised.

Actual: I cannot break out of the regular device rendering loop; i.e. the device thinks it's always active and in focus.

???
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: SDL Device correctly processing events?

Post by CuteAlien »

Phew, I've only started working with SDL device a little bit very recently and original coder long gone. From code (CIrrDeviceSDL.cpp) it looks like it tries to handle it at least:

Code: Select all

 
case SDL_ACTIVEEVENT:
    if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) ||
            (SDL_event.active.state == SDL_APPINPUTFOCUS))
        WindowHasFocus = (SDL_event.active.gain==1);
    else
    if (SDL_event.active.state == SDL_APPACTIVE)
        WindowMinimized = (SDL_event.active.gain!=1);
    break;
 
isWindowActive returns "WindowHasFocus && !WindowMinimized);" and isWindowFocused and isWindowMinimized return the corresponding variables.

That seems to be all code about this. Not sure if it's enough or would need to handle any other events. Might also depend on platform somewhat (for example I use SDL in webbrowser/emscripten which does not always work exactly the same as SDL on desktop).
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
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@All
Tried to use SDL device on few different oses, and found, that when i run any example which contain if (device->isWindowActive()) check (ast most of examples have) , then when you run that example everything in the window are black , until you move mouse inside of the window. If i compile irrlicht for win32 with win32device instead of sdl, then on runnin all works as expected, no needs to move mouse inside of the window.

That all with 1.8.4 version.

Is there something need to be fixed inside of irrlicht's SDL code ?
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: SDL Device correctly processing events?

Post by CuteAlien »

Argh, turns out I no longer have no working test environment for SDL1. Seems my last Debian update (still Debian 9) made it a little harder to get that running. Not sure right now if it's more work for me to figure out how to get SDL1 working again or just adding a SDL2 device to Irrlicht (there had been some already posted, I just wanted to add that after some other tasks, so ... kinda never happened).

Also not sure if I can do something about Irrlicht 1.8. Thought adding a device might even be possible without breaking compile compatibilty, especially as SDL is disabled by default anyway. So no solution at the moment, sorry.
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
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@CuteAlien
Its the same and with latest trunk code of 1.9.0 version, its just SDL1 device code seems kind of "broken" now (at least since 1.8.4).
And i compare now cirrldeviceSDL from 1.8.4 and 1.9.0, its kind of the same. So those bugs sleeps there ..

I need to recheck of coruse with 1.9.0 again, but chances that its the same are high.
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@CuteAlien
I do some more tests with 1.9.0, and that my finding are : its just SDL driver have issue (or better non implement something) with no-window-focus-by-default.

I do check on 2 different oses (win10 & amigaos4) , both have sdl1.2.15 , and for both i compile irrlicht with usage of SDL device, and on both issue is the same : once you run any example which have iswindowactive(), then by default window will be black, until you not make it both active, and put mouse inside of the window. Like for example, 02.QuakeMap.

Those examples which didn't have iswindowactive() check (like , 03.CustomSceneNode), works fine by default, even if mouse is out of window, and window is not active.

With win32device compiled for win32, i can see that for examples with iswindowactive() check, window automatically makes auto-active, and cursor moves in the middle of the screen. And for examples where is no iswindowactive() check, it works without forcing mouse be in focus, but window also makes to be active.

Now question is : what should i add to CIrrDeviceSDL.cpp, which will by default make window auto active in all cases, but move cursor to the middle of the window when we use in irrlicht's examples iswindowactive() ?
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: SDL Device correctly processing events?

Post by CuteAlien »

I guess a call to SDL_SetWindowInputFocus might help. Thought not sure why it's not active by default. Sorry, I still have no test-environment. I plan to update my Debian system again next month, after that I'll try getting back to a working test-environment for SDL.
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
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@CuteAlien
I guess a call to SDL_SetWindowInputFocus might help. Thought not sure why it's not active by default.
That one SDL2 only imho :) But anyway i currently fix it for myself like this (but that ugly of course):

1. At end of CIrrDeviceSDL constructor add "WindowHasFocus = true;"
2. And made CIrrDeviceSDL::isWindowActive() be like this:

Code: Select all

 
bool CIrrDeviceSDL::isWindowActive() const
{
#ifdef SDL1_FIX
    if(firstrun == true) {
        SDL_WarpMouse(Width/2,Height/2);
        firstrun = false;
    }
#endif
    return (WindowHasFocus && !WindowMinimized);
}
 
And at begining of source file "bool firstrun = false".

By this way it reacts now just like win32-device.

But probabaly that all should be fixed just in SDL_Events loop, in the block which handle those APP_MOUSEFOCUS, etc.

Sorry, I still have no test-environment. I plan to update my Debian system again next month, after that I'll try getting back to a working test-environment for SDL.
Sounds good !

In meantime found another issue, which happens only with SDL1 device when use OpenGL (bug reproduced on all oses including win32): Any example which has arrow gui elements (like those tiny left/right/mark_on/mark_off images) didn't have them, just like they fully non-visibly-or-transparent. With burning video or software renderer all fine. Its exactly SDL1device + OpenGL. With Win32device+OpenGL all fine too. That for example how looks like 09.Meshviewer:

Image

See no left/right gadgets, not on/off marks, no drop-down image , no close gadget in toolbars, etc.


So that mean that in CIrrDeviceSDL.cpp just didn't handle something in that regards when it come to opengl.. Have any idea where i can have a look and what need to be done to make it works ? That probabaly something about createwindow() and CreationParams.DriverType == video::EDT_OPENGL part check where some opengl bits sets, but not sure of course, i experemented with it a bit and have no visual changes does not matter what kind of blits / alpha / etc i set.

Thanks!
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

And another cosmetic issue about SDL_ACTIVEEVENT : when you iconify (minimaze) the example (like that 09.Meshviewer) and then deiconify/maximaze it back, then it not active by default, you need to click on it.

That again reproduced on all oses including win32 when SDL1 device is used.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: SDL Device correctly processing events?

Post by CuteAlien »

About the arrows. Those are coming from the default-font (the main reason that tiny font is still used as default-font...). So maybe bmp-loading fails (maybe disabled for testing?). Though it should give a warning on console about that.
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
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@CuteAlien
So maybe bmp-loading fails (maybe disabled for testing?). Though it should give a warning on console about that.
Do you mean disabled only for SDL device + OpenGL combo ? Because Win32 device + OpenGL works. Or SDL1 device + Burning video , or SDL1 device + Software Renderer all works.
Only when it SDL1 + OpenGL it fail.

I assume if it was disabled bmp-loading, it should fail for all, not just SDL1+OpenGL ?

And i see in 90.Meshviewer example that it loaded:

Code: Select all

 
    IGUISkin* skin = env->getSkin();
    IGUIFont* font = env->getFont("fonthaettenschweiler.bmp");
    if (font)
        skin->setFont(font);
 
As well as by tracing tools can see that font is found and loaded indeed. Just when SDL1 device is used, and i choice OpenGL, there is no arrow buttons. If i recompile irrlicht with win32 device instead of sdl1, then those arrows fine, they only not visibly when sdl1 device + opengl is used. Maybe some #ifdef SDL somewhere which skip the stage about adding those arrow gadgets ..

And what is strange is, why font itself are fine, but gadgets are not ? Is font coming from some other place, while gadgets from other ?
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: SDL Device correctly processing events?

Post by CuteAlien »

Yeah, the gadgets are from the default-font. Which is loaded from a header file as long as bmp-support is enabled. So other font is independent. But no - it shouldn't make a difference for other combos like Win32+OpenGL. So something else going on there I guess.
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
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@CuteAlien
I do check on just all SDL ifdefs in whole Irrlicht, and found them only in those files:

source/Irrlicht/COpenGLDriver.cpp
source/Irrlicht/COpenGLExtensionHandler.cpp
source/Irrlicht/CSoftwareDriver2.cpp
source/Irrlicht/Irrlicht.cpp
source/Irrlicht/os.cpp
+ their .h files
+ CIrrDeviceSDL.cpp/.h itself

So, knowing that win32device work with in that terms with sdl1 , then the only place where things can go wrong with gadgets when use SDL1 + OpenGL are something in COpenGLDriver.cpp or in CirrDeviceSDL.cpp.

Quite strange.
Yeah, the gadgets are from the default-font. Which is loaded from a header file as long as bmp-support is enabled. So other font is independent.
Ok so, the fonts i have in examples are from font loaded by example, and gadgets from some default-font loaded from irrlicht header.. Can you please point out on what header is it , so i can check maybe some ifdefs missing or something ?
kas1e
Posts: 212
Joined: Sun Jan 21, 2018 8:39 am

Re: SDL Device correctly processing events?

Post by kas1e »

@CureAlien
And found kind of the same kind of weird issue with 24.Control example, see how it looks like when used SDL1 device + OpenGL:

Image

And the same all fine when win32device with opengl is used, or, when sdl1 device is used together with software render or burning video.

Just when it SDL1 device + OpenGL (only opengl), then such issue as with gadgets in previous examples.

Imho issue may have the same roots as issue with gadgets in gui , but maybe you will have some other idea now as well )
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: SDL Device correctly processing events?

Post by CuteAlien »

This looks like a bug I had a few months ago when texture-locking in GL did go wrong (fonts do use texture-lock() a lot). Are you using the current svn trunk or some older version there? Current trunk should use ETCF_ALLOW_MEMORY_COPY currently which simply puts a texture-copy in memory so GL shouldn't even be involved anymore (and that bug might even be fixed now as I worked on lock() a while ago, thought I haven't tested fonts yet since then with ETCF_ALLOW_MEMORY_COPY disabled, have to do...).

edit: Default font header is BuiltInFont.h
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
Post Reply