How do you create SDL2 Visual Studio 2015 or 2017 Solution For Windows and Android?

空扰寡人 提交于 2019-12-23 21:44:17

问题


Visual Studio 2015 has integrated Android Emulator support. They even have a pre-made template to set up Windows Phone, Android, and iOS targets. It seems like there should be some way of setting up SDL 2.0 in the same solution to easily toggle between Android and Windows targets.

A valid answer to this question will simply be a set of steps to set up the targets for an example SDL2 program that compiles and creates a simple OpenGL/ES context rotating cube or similar which will either create a window and run as a windows .exe or execute in the android emulator depending on the target.

Please include all steps in the body of your answer in a numbered bullet list so that it is a complete stand-alone answer.


回答1:


For android specific settings. (Setting up makefiles, the AndroidManifest.xml, etc.) refer to SDL2/docs/readme.android and general "command line android help" on the internet.

Setting up the VS2015 solution generally goes as follows:

  • Create new folder project
  • Put game source in project/src
  • Create shared items project in project/
  • Create an android makefile project into project/android
  • Create an android basic application(ANT) project into project/android
  • Copy the contents of SDL2/android-proj to project/android
  • In the solution explorer check "show all files" and "include in project" all files from SDL2/android-proj except jni to the basic application project.
  • In the references of the basic app project add the makefile project.
  • In the references of the makefile project add the shared items project.
  • Edit project/android/jni/src/Android.mk to compile your files in projects/src
  • After building the makefile project, add its resulting .so files from project/android/libs/ to the basic app project.
  • Create other project like usual except instead of including source, just include shared items project in references.

Here is where you can find the shared items project:



来源:https://stackoverflow.com/questions/42149447/how-do-you-create-sdl2-visual-studio-2015-or-2017-solution-for-windows-and-andro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!