alnitak / flutter_opengl

A Flutter OpenGL ES plugin using a Texture() widget. Supports Android, Linux and Windows. Many shaders from ShaderToy.com can be copy/pasted
Other
178 stars 20 forks source link

Unable to run on android because of ffmpeg #3

Closed Lixelo closed 1 year ago

Lixelo commented 1 year ago

Hello, First of all, thanks for developing this package! I think it could be useful for my personal project but I can't get it to work. I tried a simple OpenGLController().initializeGL(); before the runApp call by having the package imported with :

flutter_opengl: git: url: https://github.com/alnitak/flutter_opengl.git ref: master

I don't get any error when building for Linux but on android I got the following error:

Execution failed for task ':flutter_opengl:buildCMakeDebug[arm64-v8a]'. > Build command failed. Error while executing process /home/user/Android/Sdk/cmake/3.18.1/bin/ninja with arguments {-v -C /home/user/.pub-cache/git/flutter_opengl-c385fadea39c5174af57c0e379f866319b6a41fa/android/.cxx/Debug/47u1i66b/arm64-v8a flutter_opengl_plugin} ninja: Entering directory '/home/user/.pub-cache/git/flutter_opengl-c385fadea39c5174af57c0e379f866319b6a41fa/android/.cxx/Debug/47u1i66b/arm64-v8a

ninja: error: '../../../../src/ffmpeg/arm64-v8a/libavcodec.so', needed by '/home/user/project/build/flutter_opengl/intermediates/cxx/Debug/47u1i66b/obj/arm64-v8a/libflutter_opengl_plugin.so', missing and no known rule to make it

So I understood that I had to build ffmpeg for android and place it in the android/src folder of the package, which I did. This time the build goes well but during the execution, there seems to be an error when executing the instruction ffi.DynamicLibrary.open("libflutter_opengl_plugin.so") (line 21 of opengl_controller.dart)

I get the following error :

ArgumentError (Invalid argument(s): Failed to load dynamic library 'libflutter_opengl_plugin.so': dlopen failed: library "libavcodec.so" not found)

It seems that it always concerns ffmpeg but I can't understand how to correct it. Could you please help me?

alnitak commented 1 year ago

Hi @Lixelo ,

I was trying to use OpenCV video capture with the camera on Android and I forgot to remove ffmpeg dependencies! Sorry about that! ;)

So there is no camera texture for now on Android. I have removed ffmpeg from Android cmakelists.txt and it's working now. Let me know if any other problem.

PS: please would be awesome to see your project using this repo if it is possible!

Lixelo commented 1 year ago

Hi @alnitak, Ok no worries, thanks everything seems to work now :)

My goal is to make a remote telescope control application (based on the INDI protocol). I'm only at the beginning for the moment (communication with the INDI server is done). I would like to integrate a sky map that would allow to see where the telescope is pointing, a kind of light version of Stellarium (I don't know if you know it). That's why I would like to use Opengl. But I wonder if this package is really adapted since there is no ffi bindings to the classic Opengl functions

Dart/Flutter is quite new for me and Opengl even more, let me know if you have any idea how to solve this problem ;)

alnitak commented 1 year ago

yes I know Stellarium! I love astronomy. This plugin is centered to GLSL. So only shaders are supported, no 3D. Hence you can't use camera, sprites and so on to compose a sky with stars. Unfortunately I don't think this could be helpful for you! With the new incoming Impeller graphics engine I think you will, but I don't know how far it is to be release for now.

Lixelo commented 1 year ago

I guessed you liked astronomy with your username 😉

Yes I realized that too when I saw that I couldn't define vertices Oh thanks for the information, I didn't know about the new Impeller graphics engine, it looks promising but yes indeed no date is announced and I don't know the speed of Flutter development nor the priority of this feature.

I think I'll continue with the rest of my application and then see if the new graphics engine is released. If it takes too long, do you know if it's possible to do this from your package by simply adding the bindings to the OpenGl functions or is it more complicated?

alnitak commented 1 year ago

IMHO Impeller will take long (maybe more then a year) for a stable release.

do you know if it's possible to do this from your package by simply adding the bindings to the OpenGl functions or is it more complicated? I think it's possible! If you look at the 4 years ago code of this, there is a 3D cube example. It was running only on Android and then I rewritten all from scratch. The 3D scene was hard-coded but using FFI and some new classes in c++ code to pass scene vertex, colors, camera and so on, this plugin can be extended for 3D.

For now I am stuck at porting this to macos and ios because I am at almost at zero knowledge on those OSes, but adding some basic 3D to this plugin was a hope since the beginning!