vsgExamples

repository·master·Indexed 41 days ago

https://github.com/vsg-dev/vsgexamples

A collection of example programs designed to test and illustrate the usage of VulkanSceneGraph (VSG) and its optional add-on libraries. Includes examples for core functionality, raytracing, UI, and platform-specific implementations for Android and HarmonyOS.

Tokens
1.9K
Snippets
10
Records
13
Agent score
50%

What's inside vsgExamples

  1. Build the VSG Native Activity example with Android Studio

    master

    Follow these steps to import and configure the project in Android Studio:

    1. Import Project: Open Android Studio and select 'Import Project', then select the vsgandroidnative folder.
    2. Configure VSG Path: Open /app/cpp/CMakeLists.txt and locate the find vsg section. You must provide the path to your VulkanSceneGraph installation using one of the following two methods:
      • Method A (Subdirectory): Use add_subdirectory( /path/to/VulkanSceneGraph vsg ).
      • Method B (Package Find): Use find_package( vsg REQUIRED NO_CMAKE_FIND_ROOT_PATH ). If you use this method, you must also update your build.gradle file to pass the installation directory via the following flag: -Dvsg_DIR=/path/to/vsg/android/installation.
    3. Build: Run the standard build process in Android Studio.
    # Option A: Subdirectory approach
    add_subdirectory( /path/to/VulkanSceneGraph vsg )
    
    # OR
    
    # Option B: Package approach (requires build.gradle update)
    find_package( vsg REQUIRED NO_CMAKE_FIND_ROOT_PATH )
  2. Build vsgExamples out-of-source

    master

    Use these instructions to perform an out-of-source build, which keeps the source directory clean. This assumes all dependencies are installed in standard system directories.

    git clone https://github.com/vsg-dev/vsgExamples.git
    mkdir build-vsgExamples
    cd build-vsgExamples
    cmake .
    make -j 8
  3. Build vsgExamples in-source

    master

    Use these instructions to build vsgExamples directly within the source directory, assuming all dependencies are installed in standard system directories.

    git clone https://github.com/vsg-dev/vsgExamples.git
    cd vsgExamples
    cmake .
    make -j 8
  4. Prerequisites for building vsgExamples

    master

    Before building vsgExamples, ensure your environment meets the following minimum requirements:

    • C++ Compiler: C++17 compliant (e.g., g++ 7.3+, Clang 6.0+, or Visual Studio 2017+).
    • Vulkan: Version 1.1 or later.
    • CMake: Version 3.7 or later.
    • VulkanSceneGraph: Use the master branch.
    • vsgXchange (Optional): Required for 3D model and image loaders.
    • vsgImGui (Optional): Required for in-window GUI examples.
  5. Setup the vsgdraw environment

    master

    To run vsgdraw, you must set the VSG_FILE_PATH environment variable to point to the vsgExamples/data directory so the application can locate shaders and textures. Additionally, you should add the vsgExamples/bin directory to your system's PATH.

    Linux

    export VSG_FILE_PATH=/path/to/vsgExamples/data
    export PATH=/path/to/vsgExamples/bin:${PATH}

    Windows

    set VSG_FILE_PATH drive:\path\to\vsgExamples\data
    set PATH drive:\path\to\vsgExamples\bin
  6. Prerequisites for VSG HarmonyOS Example

    master

    To run the VSG HarmonyOS example, ensure your environment meets the following requirements:

    • DevEco Studio: Version 6 or higher.
    • Harmony SDK: API Level 19.
    • CMake: Version 3.5.
    • Hardware/Runtime: A device running HarmonyOS 6 or higher that supports Vulkan 1.0.
    WARNING

    The DevEco simulator does not support Vulkan; you must use a physical device or a compatible emulator that supports Vulkan.

  7. Configure environment variables to run examples

    master

    After building the examples, you must configure your environment to ensure the binaries can find their dependencies and data files. Set the PATH to include the vsgExamples/bin directory and set the VSG_FILE_PATH environment variable to point to the vsgExamples/data directory.

    Replace /path/to/vsgExamples/ with your actual installation path.

    export PATH="$PATH:/path/to/vsgExamples/bin"
    export VSG_FILE_PATH=/path/to/vsgExamples/data
  8. Build the VSG HarmonyOS Example with DevEco Studio

    master

    Follow these steps to configure and build the example project in DevEco Studio:

    1. Open Project: Launch DevEco Studio and select Open, then choose the vsgharmony folder.
    2. Configure VSG Path: Open /src/main/cpp/CMakeLists.txt. Locate the find vsg section and update the CMAKE_PREFIX_PATH to point to your VulkanSceneGraph installation:
      set(CMAKE_PREFIX_PATH /path/to/VulkanSceneGraph vsg)
    3. Adjust Toolchain Configuration: Open the file ohos.toolchain.cmake. Find the line set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) and ensure it is set to BOTH. This prevents find_package from failing when searching for libraries outside the cross-compilation environment.
    4. Build: Execute the build process within DevEco Studio.
    # In /src/main/cpp/CMakeLists.txt
    set(CMAKE_PREFIX_PATH /path/to/VulkanSceneGraph vsg)
    
    # In ohos.toolchain.cmake
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
  9. Build the vsgExamples from source

    master

    To build and install the vsgExamples in source, assuming all dependencies are installed in standard system directories, follow these steps:

    1. Clone the repository.
    2. Navigate to the directory.
    3. Run cmake . to generate build files.
    4. Run make -j 8 to compile.

    Note: For more detailed instructions, refer to the INSTALL.md file in the repository.

    git clone https://github.com/vsg-dev/vsgExamples.git
    cd vsgExamples
    cmake .
    make -j 8
  10. Run vsgExamples binaries

    master

    Once the environment variables are set, you can run the compiled example binaries directly. Examples include:

    • vsgmaths: Runs simple tests of vsg/maths functionality.
    • vsgdraw: Runs the vsgdraw example (a port of VulkanTutorial).

    Other example categories available in the repository include core, nodes, app, vk, text, raytracing, state, commands, io, ui, platform, utils, threading, volume, and meshshaders.

    vsgmaths
    vsgdraw