Java 将 SDL 2.0 游戏移植到 Android
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24713185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Porting an SDL 2.0 game to Android
提问by UnTraDe
I have a game written in C/C++ with SDL 2.0, I would like to port it to mobile platforms (specifically Android and maybe other platforms too). I read SDL has a native support for Android but the game itself is written for Windows at first, although no Windows-dependent libraries/code were used. As for Android, I only used the Java based SDK before and never integrated it with native code. Which changes (if any) do I have to make to the C/C++ so I could use it on Android platform? How exactly do I acually compile the whole thing to an APK? Is it possible to use Java and C/C++ for the application, I mean, the game's activity will be the native one but the other activities (menus, settings, etc) can be written with the regular Android Java SDK?
我有一个用 SDL 2.0 用 C/C++ 编写的游戏,我想将它移植到移动平台(特别是 Android 和其他平台)。我读到 SDL 对 Android 有原生支持,但游戏本身最初是为 Windows 编写的,尽管没有使用依赖于 Windows 的库/代码。对于Android,我之前只使用过基于Java的SDK,并没有与原生代码集成。我必须对 C/C++ 进行哪些更改(如果有)才能在 Android 平台上使用它?我究竟如何将整个内容编译为 APK?是否可以将 Java 和 C/C++ 用于应用程序,我的意思是,游戏的活动将是本机活动,但其他活动(菜单、设置等)可以使用常规 Android Java SDK 编写?
采纳答案by nick.amor
The Android README file in the SDL source release outlines most of what you need to know with regards to porting your SDL App to Android. There's also an example project for Eclipse that demonstrates you can modify to suit your needs.
SDL 源版本中的 Android README 文件概述了将 SDL 应用程序移植到 Android 时需要了解的大部分内容。还有一个用于 Eclipse 的示例项目,它演示您可以进行修改以满足您的需要。
https://hg.libsdl.org/SDL/file/d6a8fa507a45/README-android.txt
https://hg.libsdl.org/SDL/file/d6a8fa507a45/README-android.txt
The iOS README file is also useful, namely for the sections on events and input, as much of it carries over to the Android port.
iOS README 文件也很有用,即关于事件和输入的部分,因为它的大部分内容都转移到了 Android 端口。
https://hg.libsdl.org/SDL/file/d6a8fa507a45/README-ios.txt
https://hg.libsdl.org/SDL/file/d6a8fa507a45/README-ios.txt
If you need help setting up the build environment, check out this (brief) tutorial which covers installing the ADK and NDK, SDL source, building a project, programming for Android and interfacing with Java.
如果您需要有关设置构建环境的帮助,请查看此(简要)教程,其中包括安装 ADK 和 NDK、SDL 源代码、构建项目、Android 编程和 Java 接口。
http://www.dinomage.com/2013/01/howto-sdl-on-android/
http://www.dinomage.com/2013/01/howto-sdl-on-android/
http://www.dinomage.com/2013/05/howto-sdl-on-android-part-2-platform-details/
http://www.dinomage.com/2013/05/howto-sdl-on-android-part-2-platform-details/
回答by Niels
(1)
(1)
I dont know anything about SDL but as long as you only make calls suported by the android NDK and what ever android supported library it should be ok. I guess you would have to set up your tool chain such that it links with SDL for android?
我对 SDL 一无所知,但只要您只进行由 android NDK 支持的调用以及任何 android 支持的库,它应该没问题。我猜你必须设置你的工具链,以便它与 SDL for android 链接?
(2) Yes it is possible to call c++ (ndk) from the android sdk and vice versa (see 3)
(2) 是的,可以从 android sdk 调用 c++ (ndk),反之亦然(参见 3)
(3+ rest)
(3+ 休息)
See
看
https://developer.android.com/tools/sdk/ndk/index.html
https://developer.android.com/tools/sdk/ndk/index.html
If you download the NDK you can also see examples of how to compile with NDK to APK
如果您下载 NDK,您还可以看到如何使用 NDK 编译为 APK 的示例