This is a few highly related questions but it boils down to:
TLDR - Can I get my app to use GLES2 on older phones that don't support GLES3 at runtime?
I have made an app (written in c++ using Visual Studio's Native Application project) which sorta grows Fractals (some 2d, some 3d) I originally made using GLES1 which simply wasn't good enough for what I needed so I set about getting it to work with GLES3 which I did. When it was 'done' I decided to try it one some other phones I had lying around and it crashed on start. I checked Logcat and foudn this:
E/linker ( 6457): load_library(linker.cpp:757): library "libGLESv3.so" not found
E/linker ( 6457): soinfo_link_image(linker.cpp:1647): could not load library "libGLESv3.so" needed by "libFractals.so"; caused by load_library(linker.cpp:757): library "libGLESv3.so" not found
The phone doesn't support it so then I tried compiling with GLES2 but that doens't support vertex array objects. That wasn't so bad, I had abstracted those away thanks to suggestions in another thread and I was easily able to make the object work like a VAO without OpenGL vao support. I had a simple preprocessor define that uses the appropriate code so I could switch between GLES2 and 3 when needed (needs a rebuild though). Unfortunately I then discovered the other reason I wanted to use GLES3 and that is GLES2 only supports unsigned shorts as indices which massively limits the detail I can show on my fractals, I am stuck with ~65k where as my phone (GLES 3 supporting one) can easily play with ~2 million without issue. When GLES2 is enabled I limit the amount of vertices to ~65k and when GLES3 I have much higher (hard coded) limits. I do this by having a GLES2 and GLES3 configuration which links as appropriate so I can build one or the other or both.
I can split up my vertex buffer and use multiple element arrays to get around that 65k limit but it really makes things messy, particularly for my 3d fractals.
My options therefore are have 2 versions of the app or get both working in one app. Although I link the appropriate lib when I am building, the error message suggests to me they are actually loaded dynamically by the app on the device so can I get it to pick the appropriate one at runtime?
Can I get the app to cleanly fail? That loading stuff seems to happen before it gets to things that I control so I can't give any feedback to the user saying the device is not supported etc. I see I can say which versions of android I am supporting in the manifest which should help. I made this as a demo project of sorts so getting it to behave is important to me but I have limited experience in this department.
I've tried it on 3 devices:
Nexus 5 (this is what I developed it on so it works perfectly here).
Alcatel One Touch Pop C1 (I have no idea what this phone is or where it came from, I found it lying around my house), this works rather well with GLES2 but I do get some wierd behaviour which is another question.
HTC Desire (apparently there are many versions of this, I think this one was an original). VS complained that it's too old, something about sdk not supported so I'm happy to skip this one and change my supported version int he manifest as appropriate.
I've also tried it using an emulator though I've messed with the settings and it's difficult to know what device it was supposed to emulate now :/. I believe it was a Galaxy Note - it was the original/default device on the Android Virtual Device manager.
So, loading GLES2/3 at runtime depending on device possible?
thanks in advance.