如何在 Android NDK 中创建新的 NativeWindow?

发布于 2024-10-24 21:31:55 字数 344 浏览 7 评论 0原文

我尝试了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╄→承喏 2024-10-31 21:31:55

如果您查看 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'.

岁月打碎记忆 2024-10-31 21:31:55

以下是从命令行使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文