stevenlovegrove / Pangolin

Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input.
MIT License
2.4k stars 855 forks source link

Porting to core functionality to Android #895

Open AndrewBloom opened 11 months ago

AndrewBloom commented 11 months ago

Hi Steven, I know this has been asked multiple times, but I'm trying to port a minimal core of Pangolin on Android. I'm doing the work myself, but it would be useful if you could enlight me with a couple of details. I'm looking at the openGL side right now, and it seems that it's not really compatible with OpenGL ES2. Ideally I would aim for ES2 cause all reasonably old Android devices should support that. (https://developer.android.com/about/dashboards). I see you used a lot of internal formats in glformattraits.h that are not supported, and I'm wondering why you deal with that and not just use GL_RGBA for everything. Is that useful for something in particular? These are the internal formats available on openGL ES2: GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA. (https://docs.gl/es2/glTexImage2D). Let me know if this porting it's something that you are interested in, you can contact me at ing.fiorito(at)gmail.com

stevenlovegrove commented 8 months ago

My apologies for the glacially slow reply - you've probably moved on by now, but a small note that for a time Pangolin did support android and it has some vestigial code related to it.

A windowing backed, currently defunct: https://github.com/stevenlovegrove/Pangolin/blob/master/components/pango_windowing/src/display_android.cpp

Gl logic for including a compatibility layer, originally written for Android. https://github.com/stevenlovegrove/Pangolin/blob/master/components/pango_opengl/include/pangolin/gl/glinclude.h#L33 https://github.com/stevenlovegrove/Pangolin/blob/master/components/pango_opengl/include/pangolin/gl/compat/gl2engine.h#L37

Although that compatibility layer isn't used for Android today, it is still active and used for the Emscripten web target https://github.com/stevenlovegrove/Pangolin/blob/master/components/pango_opengl/CMakeLists.txt#L39 which builds as part of CI, so that should be good.

Regarding your question about the internal formats - that is to support direct upload from different data sources without a hidden conversion in the OpenGL API which I've historically found to be incredibly slow and a huge source of performance issues. Sometimes scientific apps really want the original pixels for use in their shaders etc too. On Android or what-have-you, it seems acceptable that you would get a runtime error when trying to use an unsupported format, and with documentation on which formats are preferred for wider compatibility.