We should handle both pause and focus events, but they may occur in different order or in some cases we may receive only lost focus event.
So we need to check the current state to make sure that pause/resume sounds is executed only once.
STK could crash when invalid graphics restriction name was set in graphics_restrictions.xml file.
It's because of wrong while (m_names_of_restrictions[i] != NULL) condition.
It was be done only for GLES before, but also for OpenGL some drivers create OpenGL 4.x compatibility profile context even if we request GL 2.1. So we can't assume that it will report GL2.1 and we should make sure that fixed pipeline will be used.
Actually now it works in the same way as force_legacy_device in config.xml.
It can be restricted to Android-only, but tbh. I don't see any reason that it can't work in the same way on desktop computers (may be usable on laptops with touch screen, all-in-one computers etc...).
I also made a minor fix with if(!event.MouseInput.isLeftPressed()) because the EGET_ELEMENT_FOCUS_LOST event seems to not work at all.
The glGetStringi is available only in GLES >= 3.0. We can't easily check if this function exists or not because it requires EGL >= 1.5 (and still we can't be sure that all drivers handle it properly).
Though glGetString(GL_EXTENSIONS) is allowed on both GLES2.0 and GLES3.0, so we can just fallback to this method.
It is generally safe for GLES drivers. The driver often reports OpenGL ES 3.1 or 3.0 support even though we request only GLES 2.0. But we can still use GLES 2.0 / GLSL 1.0 functions on GLES 3.x context, so it shouldn't cause any issues.
I also added Android Emulator to graphics restrictions.
Enter texture filename(s) (full path is optional) separating by
";" in the artist debug mode "Reload texture" dialog
Notice: premultiplied alpha texture reloading is not supported,
because it was done on STK side.