如何在 Android NDK 中创建新的 NativeWindow?
我尝试了 test-libstdc++ 演示,并喜欢我可以从控制台启动它,而无需运行成熟的 Android 应用程序。
我想创建一个 opengl 上下文,以便我能够从控制台内执行我的 opengl es 2.0 应用程序,而无需太多麻烦。
知道如何从不使用本机活动或任何内容的 NDK 应用程序中初始化 EGL,即它甚至没有打包在 .APKK 文件中,只是将 main 方法打包为可执行 Linux 文件。
多谢!
更新
它是否有可能与*android/native_window.h`中的ANativeWindow_acquire
有关?
谢谢!
I tried the test-libstdc++ demo and liked that I can start it from the console and all without running a full-grown android application.
I'd like to create an opengl context so that I'd be able to execute my opengl es 2.0 app from within the console without too many bothering.
Any idea how could I initialize the EGL from within a NDK-app that doesn't use native activity or anything, i.e. it is not even packaged in a .APKK file, just has a main method is packed as an executable linux file.
Thanks a lot!
UPDATE
Does it by any chance has anything to do with ANativeWindow_acquire
in *android/native_window.h`?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您查看 Android 的 git 树,您将看到有几个简单的测试应用程序,它们创建本机窗口并从命令行启动。
点击这里查看测试
关于Albus上面的一些评论的问题,翻转链的问题是因为你当前的驱动程序只能支持系统中的1个翻转链,并且它由 SurfaceFlinger 持有,因为它是可以写入本机窗口/帧缓冲区的实体。要解决此问题,您只需在 adb shell 中输入“stop”即可停止 Android 运行时引擎,然后重新运行您的应用程序。要恢复 Android 运行时引擎,请执行“启动”。
If you look inside the git trees for Android, you will see that there are several simple test apps that create a native window and are launched from the command line.
click here to see the tests
Regarding the questions to some of the comments above by Albus, the issue with the flip chain is because your current driver can only support 1 flip chain in the system, and that's being held by SurfaceFlinger since that's the entity who can write to the native window/framebuffer. To work around this you can just stop the Android Run Time engine by typing 'stop' inside adb shell, then re-run your app. To get the Android Run time engine back up, do 'start'.
以下是从命令行使用 EGL 的示例:
http://jiggawatt.org/badc0de/android/index .html
然而,这样的没有“合法”Android UI Activity 的进程将随时被系统杀死,因为它被视为后台进程。此外,您将无法使用触摸屏或键盘输入,或任何其他需要上下文的东西,例如确定 SD 卡的安装位置等。
Here's an example of using EGL from command line:
http://jiggawatt.org/badc0de/android/index.html
However such process without 'legal' Android UI Activity is going to be killed by the system at any time for being considered as a background process. Also you wouldn't be able you use touchscreen or keyboard input, or any other stuff that require Context, like figuring out where the SD card is mounted, etc.