diff --git a/.gitignore b/.gitignore index da8dc778c1..1691db3d79 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,8 @@ install_manifest.txt .vs/ x64/ src/vsg/vsg.dir/ + +#xcode +DerivedData/ +*.build +*.xcodeproj diff --git a/INSTALL.md b/INSTALL.md index 31ecfa0516..8321a5acc7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -37,7 +37,7 @@ After running cmake open the generated VSG.sln file and build the All target. On ## Quick build instructions for Android -Requires Android NDK 18. Full build instructions coming soon. +Requires Android NDK 18 and CMake 3.13 (lower CMake versions may work but have not been tested). cmake ./ \ -DCMAKE_BUILD_TYPE="Debug" \ @@ -138,22 +138,55 @@ From there download and install the Vulkan SDK (1.1 or later) and the Vulkan run VULKAN_SDK = C:\VulkanSDK\1.1.85.0 -Next we need to download build and install GLFW with Vulkan support. GLFW does provide prebuilt binaries for Windows. However they do not ship the CMake.config files required for CMake to find the GLFW headers and lib. +So now we have the Vulkan SDK installed and findable by CMake so we can go ahead and build VSG. Below are simple instructions for downloading the VSG source code, generating a Visual Studio project using CMake and finally building and installing VSG onto your system. - git clone https://github.com/glfw/glfw.git - cd ./glfw + git clone https://github.com/vsg-dev/VulkanSceneGraphPrototype.git + cd VulkanSceneGraphPrototype cmake . -G "Visual Studio 15 2017 Win64" -Once CMake is finished open the generated GLFW.sln file and build the Install target for release. Remember to open Visual Studio as Administrator if installing to the Program Files folder, the default. Finally CMake needs to know where GLFW is installed on your system. As it's using CMake.config files we use the CMAKE_PREFIX_PATH environment variable to inform CMake of the location of our installed libraries. So go ahead and add GLFW to this list. Example below. +After running CMake open the generated VSG.sln file and build the All target. Once built you can run the install target. If you are using the default CMake install path (in Program Files folder), ensure you have started Visual Studio as administrator otherwise the install will fail. - CMAKE_PREFIX_PATH = C:\Program Files\GLFW;C:\Program Files\VSG +It's recommended at this point that you add the VSG install path to you CMAKE_PREFIX_PATH, this will allow other CMake projects, like the vsgExamples project to find your VSG installation. CMAKE_PREFIX_PATH can be set as an environment variable on you system. -You can see in the example that we also have VSG in the list, this will be required later once VSG is built and installed and we want to utilise it with other CMake based projects. + CMAKE_PREFIX_PATH = C:\Program Files\VSG -So now we have the Vulkan SDK and GLFW installed and findable by CMake so we can go ahead and build VSG. Below are simple instructions for downloading the VSG source code, generating a Visual Studio project using CMake and finally building and installing VSG onto your system. - git clone https://github.com/vsg-dev/VulkanSceneGraphPrototype.git - cd VulkanSceneGraphPrototype - cmake . -G "Visual Studio 15 2017 Win64" +## Detailed instructions for setting up your environment and building for Android + +This guide is to build VSG for Android, these steps have been completed on macOS but should be almost identical on Linux and similar on Windows. Inorder to build VSG for Android you'll need the following installed on your machine. + + Android NDK 18 + CMake 3.13 + +The easiest way to get the Android NDK installed is via Android Studio. Follow the link below to download and install it for your OS. + +[Android Studio](https://developer.android.com/studio/) + +If you got to the 'SDK Manager' ensure you have at least Android API level 24 installed, then go to the 'SDK Tools' tab and check the 'NDK' option. Once done click apply and Android Studio should download and install these components for you. + +If you already have Android Studio and or the NDK installed. Still go to the 'SDK Manager' and see if you need to update your NDK to version 18. + +Take note of the 'Android SDK Location' as you'll need it when running CMake to generate our Android make files. + +So now we have the Android NDK installed lets go ahead and fetch the VSG source then use CMake to generate the make files. + + git clone https://github.com/vsg-dev/VulkanSceneGraphPrototype.git + cd VulkanSceneGraphPrototype + cmake ./ \ + -DCMAKE_BUILD_TYPE="Debug" \ + -DCMAKE_SYSTEM_NAME="Android" \ + -DCMAKE_SYSTEM_VERSION=24 \ + -DCMAKE_ANDROID_STL_TYPE="c++_static" \ + -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \ + -DCMAKE_ANDROID_NDK=/location/of/Android/sdk/ndk-bundle \ + -DCMAKE_INSTALL_PREFIX=/usr/local/android + +Make sure you change the -DCMAKE_ANDROID_NDK path to the path of your NDK, typically this is the 'Android SDK Location'/ndk-bundle. Also note the -DCMAKE_INSTALL_PREFIX. This is where the VSG library and header will be installed. It's useful to change this from the default to seperate your Android version from your native OS version. Depending where you put it you may need to manually create the top level folder first depending on permissions. + +Now we've generated the make files we can simply run + + make -j 8 + make install + +That's it, you've built VSG for Android and installed the required headers and library files onto your machine ready to use with you project or the Android vsgExamples. -After running CMake open the generated VSG.sln file and build the All target. Once built you can run the install target. If you are using the default CMake install path (in Program Files folder), ensure you have started Visual Studio as administrator otherwise the install will fail. diff --git a/include/vsg/viewer/platforms/Android_Window.h b/include/vsg/platform/android/Android_Window.h similarity index 100% rename from include/vsg/viewer/platforms/Android_Window.h rename to include/vsg/platform/android/Android_Window.h diff --git a/src/vsg/viewer/Win32_Window.h b/include/vsg/platform/win32/Win32_Window.h similarity index 100% rename from src/vsg/viewer/Win32_Window.h rename to include/vsg/platform/win32/Win32_Window.h diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 79ff6947d6..c8f4c50b80 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -83,8 +83,8 @@ set(SOURCES set(LIBRARIES PUBLIC Vulkan::Vulkan) if (ANDROID) - set(HEADERS ${HEADERS} ${CMAKE_SOURCE_DIR}/include/vsg/viewer/platforms/Android_Window.h) - set(SOURCES ${SOURCES} viewer/Android_Window.cpp) + set(HEADERS ${HEADERS} ${CMAKE_SOURCE_DIR}/include/vsg/platform/android/Android_Window.h) + set(SOURCES ${SOURCES} platform/android/Android_Window.cpp) if(CMAKE_SYSTEM_VERSION GREATER 24) set(LIBRARIES ${LIBRARIES} PRIVATE ${AndroidLib} PRIVATE ${AndroidNativeWindowLib}) @@ -93,7 +93,7 @@ if (ANDROID) endif() elseif (WIN32) - set(SOURCES ${SOURCES} viewer/Win32_Window.cpp) + set(SOURCES ${SOURCES} platform/win32/Win32_Window.cpp) elseif (APPLE) set(SOURCES ${SOURCES} viewer/GLFW_Window.cpp) set(LIBRARIES ${LIBRARIES} PRIVATE glfw) diff --git a/src/vsg/viewer/Android_Window.cpp b/src/vsg/platform/android/Android_Window.cpp similarity index 99% rename from src/vsg/viewer/Android_Window.cpp rename to src/vsg/platform/android/Android_Window.cpp index 12bc48a24b..7ae7f6a34b 100644 --- a/src/vsg/viewer/Android_Window.cpp +++ b/src/vsg/platform/android/Android_Window.cpp @@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include +#include #include #include diff --git a/src/vsg/viewer/Win32_Window.cpp b/src/vsg/platform/win32/Win32_Window.cpp similarity index 99% rename from src/vsg/viewer/Win32_Window.cpp rename to src/vsg/platform/win32/Win32_Window.cpp index bbc2513a96..9f36884c61 100644 --- a/src/vsg/viewer/Win32_Window.cpp +++ b/src/vsg/platform/win32/Win32_Window.cpp @@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ -#include "Win32_Window.h" +#include #include