### Define CMake Function for r3d Example Builds Source: https://github.com/bigfoot71/r3d/blob/master/examples/CMakeLists.txt This CMake function, `add_example`, encapsulates the common build steps for each r3d demonstration. It creates an executable, links it against `raylib` and `r3d`, defines the `RESOURCES_PATH` for compilation, and adds necessary include directories, streamlining example setup. ```CMake function(add_example example_name source_file) add_executable(${example_name} ${source_file}) target_link_libraries(${example_name} PRIVATE raylib r3d) target_compile_definitions(${example_name} PRIVATE RESOURCES_PATH="${RESOURCES_PATH}") target_include_directories(${example_name} PRIVATE ${RAYLIB_PATH} ${INCLUDE_PATH}) endfunction() ``` -------------------------------- ### Register r3d Project Examples in CMake Source: https://github.com/bigfoot71/r3d/blob/master/examples/CMakeLists.txt This section utilizes the `add_example` CMake function to register all individual r3d demonstration applications. Each line specifies an example's target name and its corresponding source file, automating the compilation and linking process for the entire suite of examples. ```CMake add_example(r3d_basic "examples/basic.c") add_example(r3d_lights "examples/lights.c") add_example(r3d_pbr_musket "examples/pbr_musket.c") add_example(r3d_pbr_car "examples/pbr_car.c") add_example(r3d_transparency "examples/transparency.c") add_example(r3d_skybox "examples/skybox.c") add_example(r3d_sponza "examples/sponza.c") add_example(r3d_sprite "examples/sprite.c") add_example(r3d_animation "examples/animation.c") add_example(r3d_fog "examples/fog.c") add_example(r3d_bloom "examples/bloom.c") add_example(r3d_resize "examples/resize.c") add_example(r3d_particles "examples/particles.c") add_example(r3d_instanced "examples/instanced.c") add_example(r3d_sprite_instanced "examples/sprite_instanced.c") add_example(r3d_directional "examples/directional.c") ``` -------------------------------- ### Initialize and Render 3D Scene with R3D (C) Source: https://github.com/bigfoot71/r3d/blob/master/README.md A comprehensive C example demonstrating how to initialize a raylib window, set up the R3D renderer, load and render a sphere mesh, create a directional light, configure a camera, and run a main rendering loop. It showcases the basic steps for creating a 3D application using R3D. ```c #include int main() { // Initialize raylib window InitWindow(800, 600, "R3D Example"); // Initialize R3D Renderer with default settings R3D_Init(800, 600, 0); // Load a model to render // 'true' indicates that we upload immediately to the GPU R3D_Mesh mesh = R3D_GenMeshSphere(1.0f, 16, 32, true); // Get a material with default values R3D_Material material = R3D_GetDefaultMaterial(); // Create a directional light // NOTE: The direction will be normalized R3D_Light light = R3D_CreateLight(R3D_LIGHT_DIR); R3D_SetLightDirection(light, (Vector3) { -1, -1, -1 }); R3D_SetLightActive(light, true); // Init a Camera3D Camera3D camera = { .position = (Vector3) { -3, 3, 3 }, .target = (Vector3) { 0, 0, 0 }, .up = (Vector3) { 0, 1, 0 }, .fovy = 60.0f, .projection = CAMERA_PERSPECTIVE }; // Main rendering loop while (!WindowShouldClose()) { BeginDrawing(); R3D_Begin(camera); R3D_DrawMesh(&mesh, &material, MatrixIdentity()); R3D_End(); EndDrawing(); } // Close R3D renderer and raylib R3D_UnloadMesh(mesh); R3D_Close(); CloseWindow(); return 0; } ``` -------------------------------- ### Initialize and Configure R3D Material Properties Source: https://github.com/bigfoot71/r3d/blob/master/README.md This C code example illustrates the initialization of a default R3D material and the extensive configuration of its properties. It covers setting albedo, ORM (Occlusion-Roughness-Metalness), emission, normal mapping, blend mode, face culling, shadow casting, billboard behavior, and alpha cutoff for rendering. ```C R3D_Material material = R3D_LoadMaterialDefault(); // Creates a default R3D material // Sets the material's albedo with a texture and color tint material.albedo.texture = myTexture; material.albedo.color = WHITE; // Configure ORM (Occlusion-Roughness-Metalness) properties material.orm.texture = myORMTexture; // Optional: combined ORM texture material.orm.roughness = 1.0f; // Surface roughness (0.0 = mirror, 1.0 = rough) material.orm.metalness = 0.0f; // Metallic property (0.0 = dielectric, 1.0 = metallic) material.orm.occlusion = 1.0f; // Ambient occlusion (1.0 = no occlusion) // Set up emission properties material.emission.texture = myEmissionTexture; // Optional: emission texture material.emission.color = RED; // Emission color material.emission.multiplier = 3.0f; // Emission intensity // Configure normal mapping material.normal.texture = myNormalTexture; // Set rendering modes directly in the material material.blendMode = R3D_BLEND_ALPHA; // Transparency blending material.cullMode = R3D_CULL_BACK; // Face culling material.shadowCastMode = R3D_SHADOW_CAST_ON; // Shadow casting material.billboardMode = R3D_BILLBOARD_NONE; // Billboard behavior // Alpha cutoff for transparency testing material.alphaCutoff = 0.5f; ``` -------------------------------- ### Define Resource and Include Paths in CMake Source: https://github.com/bigfoot71/r3d/blob/master/examples/CMakeLists.txt This CMake snippet sets essential variables for the project's resource and include directories. These paths are then used by other build rules to locate assets and header files, ensuring proper compilation and linking of example applications. ```CMake set(RESOURCES_PATH "${R3D_ROOT_PATH}/examples/resources/") set(INCLUDE_PATH "${R3D_ROOT_PATH}/include") ``` -------------------------------- ### Define Project Build Options Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt Defines various build options for the project using the 'option' command. These options include whether to build examples (R3D_BUILD_EXAMPLES) and whether to use vendored versions of raylib (R3D_RAYLIB_VENDORED) and assimp (R3D_ASSIMP_VENDORED) from submodules. ```CMake option(R3D_BUILD_EXAMPLES "Build the examples" ${R3D_IS_MAIN}) option(R3D_RAYLIB_VENDORED "Use vendored raylib from submodule" OFF) option(R3D_ASSIMP_VENDORED "Use vendored assimp from submodule" OFF) ``` -------------------------------- ### Discover System-Installed Assimp Library in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet attempts to find a system-installed version of the Assimp library using CMake's `find_package` command. If found, it retrieves the include directories for the library. If Assimp is not found, it issues a fatal error, guiding the user on how to resolve the missing dependency by ensuring it's installed and discoverable. ```CMake else() find_package(assimp QUIET) if(TARGET assimp) message(STATUS "Using system-installed assimp") get_target_property(RAYLIB_INCLUDE_DIR assimp INTERFACE_INCLUDE_DIRECTORIES) set(R3D_ASSIMP_INC_PATH "${RAYLIB_INCLUDE_DIR}" CACHE STRING "Path to assimp includes" FORCE) else() message(FATAL_ERROR "System assimp not found.\nMake sure assimp is installed and discoverable by CMake (e.g. via CMAKE_PREFIX_PATH or pkg-config).") endif() endif() ``` -------------------------------- ### Conditionally Include Examples CMakeLists.txt Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This CMake snippet conditionally includes an external CMakeLists.txt file located in the examples directory. The inclusion occurs only if the `R3D_BUILD_EXAMPLES` variable is set, allowing for modular project configuration and optional example compilation. ```CMake if(R3D_BUILD_EXAMPLES) include("${R3D_ROOT_PATH}/examples/CMakeLists.txt") endif() ``` -------------------------------- ### Install MinGW for Cross-Compilation Source: https://github.com/bigfoot71/r3d/blob/master/README.md Command to install the MinGW-w64 toolchain on Debian or Ubuntu-based systems. This prerequisite is necessary for cross-compiling R3D for Windows from a Linux environment. ```bash sudo apt-get install mingw-w64 ``` -------------------------------- ### Clone R3D Repository with Submodules Source: https://github.com/bigfoot71/r3d/blob/master/README.md Clones the R3D repository along with its Git submodules, including raylib, to ensure all dependencies are fetched correctly for initial setup. ```Bash git clone --recurse-submodules https://github.com/Bigfoot71/r3d ``` -------------------------------- ### Configure Vendored Assimp Library in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet configures a vendored (submodule) version of the Assimp library. It sets various build options, including disabling tests, exports, and installation, while selectively enabling specific model importers like COLLADA, GLTF, OBJ, and FBX. It also adds the Assimp subdirectory to the build process. ```CMake if(R3D_ASSIMP_VENDORED) set(R3D_ASSIMP_SUBMODULE_PATH "${R3D_ROOT_PATH}/external/assimp") set(R3D_ASSIMP_CMAKELISTS "${R3D_ASSIMP_SUBMODULE_PATH}/CMakeLists.txt") # Vendored assimp configuration here! if(EXISTS "${R3D_ASSIMP_CMAKELISTS}") message(STATUS "Using vendored assimp from: ${R3D_ASSIMP_SUBMODULE_PATH}") set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "") set(ASSIMP_WARNINGS_AS_ERRORS OFF CACHE BOOL "") set(ASSIMP_IGNORE_GIT_HASH ON CACHE BOOL "") set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "") set(ASSIMP_NO_EXPORT ON CACHE BOOL "") set(ASSIMP_INSTALL OFF CACHE BOOL "") set(ASSIMP_BUILD_COLLADA_IMPORTER ON CACHE BOOL "") set(ASSIMP_BUILD_GLTF_IMPORTER ON CACHE BOOL "") set(ASSIMP_BUILD_OBJ_IMPORTER ON CACHE BOOL "") set(ASSIMP_BUILD_M3D_IMPORTER ON CACHE BOOL "") set(ASSIMP_BUILD_FBX_IMPORTER ON CACHE BOOL "") set(ASSIMP_BUILD_IQM_IMPORTER ON CACHE BOOL "") set(ASSIMP_BUILD_AMF_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_BVH_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_OFF_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_COB_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_STL_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_3DS_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_AC_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_ASE_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_ASSBIN_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_B3D_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_DXF_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_CSM_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_HMP_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_IRRMESH_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_IRR_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_LWO_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_LWS_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MD2_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MD3_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MD5_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MDC_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MDL_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_NFF_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_NDO_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_OGRE_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_OPENGEX_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_PLY_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MS3D_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_BLEND_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_IFC_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_XGL_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_Q3D_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_Q3BSP_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_RAW_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_SIB_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_SMD_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_TERRAGEN_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_3D_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_X_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_X3D_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_3MF_IMPORTER OFF CACHE BOOL "") set(ASSIMP_BUILD_MMD_IMPORTER OFF CACHE BOOL "") add_subdirectory("${R3D_ASSIMP_SUBMODULE_PATH}") set(R3D_ASSIMP_INC_PATH "${R3D_ASSIMP_SUBMODULE_PATH}/src" CACHE STRING "Path to assimp includes" FORCE) else() message(FATAL_ERROR "Vendored assimp not found!\nMissing: ${R3D_ASSIMP_CMAKELISTS}\nPlease initialize the submodule with:\n git submodule update --init --recursive") endif() ``` -------------------------------- ### Create and Manage R3D Spotlight in C Source: https://github.com/bigfoot71/r3d/blob/master/README.md This C code snippet demonstrates how to create a spotlight, set its position and target, and activate it within the R3D library. It uses `R3D_CreateLight` to instantiate the light, `R3D_LightLookAt` for positioning, and `R3D_SetLightActive` to enable it. ```c R3D_Light light = R3D_CreateLight(R3D_SPOTLIGHT); // Create a spotlight and return its ID R3D_LightLookAt(light, (Vector3){0, 10, 0}, (Vector3){0}); // Set light position and target R3D_SetLightActive(light, true); // Indicates to turn on the light ``` -------------------------------- ### Clone R3D Repository Source: https://github.com/bigfoot71/r3d/blob/master/README.md Instructions to clone the R3D library's Git repository and navigate into its directory. This is the essential first step to set up the development environment. ```bash git clone https://github.com/Bigfoot71/r3d cd r3d ``` -------------------------------- ### Initialize Raylib Submodule Source: https://github.com/bigfoot71/r3d/blob/master/README.md Optional step to update and initialize the raylib submodule, which is a dependency for R3D. This ensures all necessary components are available for a successful build. ```bash git submodule update --init --recursive ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/bigfoot71/r3d/blob/master/README.md Initializes and updates Git submodules for an existing R3D repository clone, useful if the repository was cloned without the --recurse-submodules flag initially. ```Bash git submodule update --init --recursive ``` -------------------------------- ### Build R3D Library with CMake Source: https://github.com/bigfoot71/r3d/blob/master/README.md Commands to create a build directory, configure the project with CMake, and then build the R3D library. This compiles the source code into usable binaries for your system. ```bash mkdir build cd build cmake .. cmake --build . ``` -------------------------------- ### Load and Draw R3D Model in C Source: https://github.com/bigfoot71/r3d/blob/master/README.md This C code snippet demonstrates how to load a 3D model from a file using `R3D_LoadModel` and then draw it in the scene at the origin with a default scale using `R3D_DrawModel`. It illustrates a basic model rendering workflow in R3D. ```c R3D_Model model = R3D_LoadModel("model.fbx"); R3D_DrawModel(&model, (Vector3) { 0 }, 1.0f); ``` -------------------------------- ### R3D Model Drawing Functions API Reference Source: https://github.com/bigfoot71/r3d/blob/master/README.md This section provides the API signatures for drawing models in R3D, including variants for basic drawing, extended positioning/scaling, and advanced rotation/scaling. These functions are similar to raylib's but handle tinting via material properties. ```APIDOC R3D_DrawModel(model: const R3D_Model*) -> void R3D_DrawModelEx(model: const R3D_Model*, position: Vector3, scale: float) -> void R3D_DrawModelPro(model: const R3D_Model*, position: Vector3, rotationAxis: Vector3, rotationAngle: float, scale: Vector3) -> void Notes: - Tinting is handled via material.albedo.color, not directly as a function parameter. - Material is copied internally, allowing modification between calls. ``` -------------------------------- ### R3D Light Types API Reference Source: https://github.com/bigfoot71/r3d/blob/master/README.md This section details the various light types supported by the R3D library, including their characteristics, typical use cases, and configurable parameters. It covers directional, spotlight, and omni light types. ```APIDOC R3D_CreateLight(light_type: R3D_LightType) -> R3D_Light light_type: The type of light to create (e.g., R3D_SPOTLIGHT). R3D_Light Types: - R3D_DIRLIGHT (Directional Light): - Description: Simulates sunlight, casting parallel rays of light in a specific direction across the entire scene. - Use Case: Outdoor environments, consistent lighting over large areas. - R3D_SPOTLIGHT (Spotlight): - Description: Emits a cone-shaped beam of light from a specific position, pointing toward a target. - Parameters: - Range: How far the spotlight reaches before fading out. - Inner Cutoff: Angle of the cone where light is at full intensity. - Outer Cutoff: Angle where light fades to darkness. - Attenuation: Controls intensity decrease with distance. - R3D_OMNILIGHT (Omni Light): - Description: A point light that radiates uniformly in all directions, similar to a light bulb. - Parameters: - Range: Maximum distance the light affects objects. - Attenuation: Controls intensity decrease with distance. ``` -------------------------------- ### Configure CMake for Windows 64-bit Cross-Compilation Source: https://github.com/bigfoot71/r3d/blob/master/README.md CMake command to configure the R3D project for cross-compilation targeting Windows 64-bit. This utilizes a specific toolchain file to prepare the build system for the target architecture. ```bash cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w64-x86_64.cmake ``` -------------------------------- ### Specify Include Directories for CMake Project Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This CMake snippet defines the public include directories for the project. It includes paths for external libraries like GLAD, project-specific headers, and paths for raylib and assimp includes, ensuring the compiler can find necessary header files during compilation. ```CMake target_include_directories(${PROJECT_NAME} PUBLIC "${R3D_ROOT_PATH}/external/glad" "${R3D_ROOT_PATH}/include" "${R3D_RAYLIB_INC_PATH}" "${R3D_ASSIMP_INC_PATH}" ) ``` -------------------------------- ### Configure Shadow Mapping in R3D Source: https://github.com/bigfoot71/r3d/blob/master/README.md This C code snippet demonstrates how to enable shadow mapping for a light source in the R3D engine by specifying a resolution. It also shows how to disable shadow mapping, with an option to either retain or destroy the allocated shadow map resources. ```C R3D_EnableLightShadow(light, 2048); // Enable shadow mapping with a 2048x2048 shadow map resolution R3D_DisableLightShadow(light, false); // Disables the light; `false` keeps the allocated shadow map, while `true` destroys it ``` -------------------------------- ### Link Project Dependencies in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet demonstrates how to link external libraries like raylib, assimp, and the math library (m) to a CMake project. It uses `target_link_libraries` for direct linking and `check_library_exists` to conditionally link the math library based on its availability. ```CMake target_link_libraries(${PROJECT_NAME} PUBLIC raylib assimp) check_library_exists(m cos "" HAVE_LIB_M) if(HAVE_LIB_M) target_link_libraries(${PROJECT_NAME} PUBLIC m) endif() ``` -------------------------------- ### Configure CMake for Windows 32-bit Cross-Compilation Source: https://github.com/bigfoot71/r3d/blob/master/README.md CMake command to configure the R3D project for cross-compilation targeting Windows 32-bit. This uses a specific toolchain file to prepare the build system for the desired architecture. ```bash cmake .. -DCMAKE_TOOLCHAIN_FILE=cmake/mingw-w32-x86_64.cmake ``` -------------------------------- ### Define CMake Minimum Version and Project Name Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt Sets the minimum required CMake version to 3.8 and defines the project name as 'r3d'. This is a standard initial configuration for any CMake project. ```CMake cmake_minimum_required(VERSION 3.8) project("r3d") ``` -------------------------------- ### Configure Raylib Dependency in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet demonstrates how to manage the raylib dependency for the 'r3d' project. It checks if a vendored raylib submodule is available, configures it by disabling certain features (like model loading) to avoid conflicts and reduce build size, and sets the include path. If the vendored version is not found, it attempts to find a system-installed raylib. ```CMake if(R3D_RAYLIB_VENDORED) set(R3D_RAYLIB_SUBMODULE_PATH "${R3D_ROOT_PATH}/external/raylib") set(R3D_RAYLIB_CMAKELISTS "${R3D_RAYLIB_SUBMODULE_PATH}/CMakeLists.txt") # Vendored assimp configuration here! if(EXISTS "${R3D_RAYLIB_CMAKELISTS}") message(STATUS "Using vendored raylib from: ${R3D_RAYLIB_SUBMODULE_PATH}") # Disable model loading and mesh generation support # to avoid symbol redefinition errors with Assimp, # and because it's not needed with r3d set(CUSTOMIZE_BUILD ON CACHE BOOL "" FORCE) set(SUPPORT_FILEFORMAT_OBJ OFF CACHE BOOL "" FORCE) set(SUPPORT_FILEFORMAT_MTL OFF CACHE BOOL "" FORCE) set(SUPPORT_FILEFORMAT_IQM OFF CACHE BOOL "" FORCE) set(SUPPORT_FILEFORMAT_GLTF OFF CACHE BOOL "" FORCE) set(SUPPORT_FILEFORMAT_VOX OFF CACHE BOOL "" FORCE) set(SUPPORT_FILEFORMAT_M3D OFF CACHE BOOL "" FORCE) set(SUPPORT_MESH_GENERATION OFF CACHE BOOL "" FORCE) add_subdirectory("${R3D_RAYLIB_SUBMODULE_PATH}") set(R3D_RAYLIB_INC_PATH "${R3D_RAYLIB_SUBMODULE_PATH}/src" CACHE STRING "Path to raylib includes" FORCE) else() message(FATAL_ERROR "Vendored raylib not found!\nMissing: ${R3D_RAYLIB_CMAKELISTS}\nPlease initialize the submodule with:\n git submodule update --init --recursive") endif() else() find_package(raylib QUIET) if(TARGET raylib) message(STATUS "Using system-installed raylib") get_target_property(RAYLIB_INCLUDE_DIR raylib INTERFACE_INCLUDE_DIRECTORIES) set(R3D_RAYLIB_INC_PATH "${RAYLIB_INCLUDE_DIR}" CACHE STRING "Path to raylib includes" FORCE) else() message(FATAL_ERROR "System raylib not found.\nMake sure raylib is installed and discoverable by CMake (e.g. via CMAKE_PREFIX_PATH or pkg-config).") endif() endif() ``` -------------------------------- ### Configure MSVC 'Edit and Continue' Debugging Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt Configures Microsoft Visual C++ (MSVC) to enable 'Edit and Continue' debugging for 'Debug' and 'RelWithDebInfo' configurations. It checks for CMake policy CMP0141 and sets the CMAKE_MSVC_DEBUG_INFORMATION_FORMAT accordingly to enhance the debugging experience. ```CMake if(POLICY CMP0141) cmake_policy(SET CMP0141 NEW) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") endif() ``` -------------------------------- ### Include Custom CMake Scripts Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt Includes several custom CMake scripts that provide additional functionalities for the project. These scripts are 'CheckLibraryExists' for verifying library presence, 'EmbedShaders' for embedding shader files, and 'EmbedAssets' for embedding other asset files directly into the build. ```CMake include(CheckLibraryExists) include(EmbedShaders) include(EmbedAssets) ``` -------------------------------- ### Define R3D Library and Source Files in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet defines the 'r3d' library target in CMake. It conditionally adds preprocessor definitions for shared library builds and lists all the C source files that constitute the 'r3d' library, ensuring they are compiled and linked into the final product. ```CMake if(BUILD_SHARED_LIBS) add_definitions(-DR3D_BUILD_SHARED) add_definitions(-DGLAD_API_CALL_EXPORT) endif() add_library(${PROJECT_NAME} "${R3D_ROOT_PATH}/src/details/r3d_primitives.c" "${R3D_ROOT_PATH}/src/details/r3d_billboard.c" "${R3D_ROOT_PATH}/src/details/r3d_collision.c" "${R3D_ROOT_PATH}/src/details/r3d_drawcall.c" "${R3D_ROOT_PATH}/src/details/r3d_frustum.c" "${R3D_ROOT_PATH}/src/details/r3d_light.c" "${R3D_ROOT_PATH}/src/r3d_environment.c" "${R3D_ROOT_PATH}/src/r3d_particles.c" "${R3D_ROOT_PATH}/src/r3d_lighting.c" "${R3D_ROOT_PATH}/src/r3d_culling.c" "${R3D_ROOT_PATH}/src/r3d_skybox.c" "${R3D_ROOT_PATH}/src/r3d_curves.c" "${R3D_ROOT_PATH}/src/r3d_sprite.c" "${R3D_ROOT_PATH}/src/r3d_model.c" "${R3D_ROOT_PATH}/src/r3d_utils.c" "${R3D_ROOT_PATH}/src/r3d_state.c" "${R3D_ROOT_PATH}/src/r3d_core.c" ) ``` -------------------------------- ### Determine Project Root Directory and Main Project Status Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt Identifies the project's root directory by setting R3D_ROOT_PATH to CMAKE_CURRENT_SOURCE_DIR. It also determines if the current CMakeLists.txt is being processed as the main project (R3D_IS_MAIN ON) or as a sub-directory (R3D_IS_MAIN OFF), which is useful for conditional logic. ```CMake set(R3D_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(R3D_IS_MAIN ON) else() set(R3D_IS_MAIN OFF) endif() ``` -------------------------------- ### Configure CMake Module Search Path Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt Adds the project's 'cmake' subdirectory to the CMAKE_MODULE_PATH. This allows CMake to locate and include custom modules and scripts defined within the project's own 'cmake' directory, extending its functionality. ```CMake set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake") ``` -------------------------------- ### Embed Assets into R3D Library in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet uses a custom CMake function `EmbedAssets` to embed various asset files, such as DDS and PNG images, into the 'r3d' library. This ensures that necessary resources are available at runtime without external file dependencies, simplifying deployment and resource management. ```CMake EmbedAssets(${PROJECT_NAME} "${R3D_ROOT_PATH}/assets/lut/ibl_brdf_256.dds" "${R3D_ROOT_PATH}/assets/noise/blue_noise_128.png" ) ``` -------------------------------- ### Embed Shaders into R3D Library in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet uses a custom CMake function `EmbedShaders` to embed a comprehensive list of shader files into the 'r3d' library. This process typically converts shader source code into C/C++ arrays or similar formats, bundling them directly into the executable or library for runtime access. ```CMake EmbedShaders(${PROJECT_NAME} "${R3D_ROOT_PATH}/shaders/common/screen.vert" "${R3D_ROOT_PATH}/shaders/common/cubemap.vert" "${R3D_ROOT_PATH}/shaders/generate/gaussian_blur_dual_pass.frag" "${R3D_ROOT_PATH}/shaders/generate/downsampling.frag" "${R3D_ROOT_PATH}/shaders/generate/upsampling.frag" "${R3D_ROOT_PATH}/shaders/generate/cubemap_from_equirectangular.frag" "${R3D_ROOT_PATH}/shaders/generate/irradiance_convolution.frag" "${R3D_ROOT_PATH}/shaders/generate/prefilter.frag" "${R3D_ROOT_PATH}/shaders/raster/geometry.vert" "${R3D_ROOT_PATH}/shaders/raster/geometry_instanced.vert" "${R3D_ROOT_PATH}/shaders/raster/geometry.frag" "${R3D_ROOT_PATH}/shaders/raster/forward.vert" "${R3D_ROOT_PATH}/shaders/raster/forward_instanced.vert" "${R3D_ROOT_PATH}/shaders/raster/forward.frag" "${R3D_ROOT_PATH}/shaders/raster/skybox.vert" "${R3D_ROOT_PATH}/shaders/raster/skybox.frag" "${R3D_ROOT_PATH}/shaders/raster/depth_volume.vert" "${R3D_ROOT_PATH}/shaders/raster/depth_volume.frag" "${R3D_ROOT_PATH}/shaders/raster/depth.vert" "${R3D_ROOT_PATH}/shaders/raster/depth_instanced.vert" "${R3D_ROOT_PATH}/shaders/raster/depth.frag" "${R3D_ROOT_PATH}/shaders/raster/depth_cube.vert" "${R3D_ROOT_PATH}/shaders/raster/depth_cube_instanced.vert" "${R3D_ROOT_PATH}/shaders/raster/depth_cube.frag" "${R3D_ROOT_PATH}/shaders/screen/ssao.frag" "${R3D_ROOT_PATH}/shaders/screen/ambient.frag" "${R3D_ROOT_PATH}/shaders/screen/lighting.frag" "${R3D_ROOT_PATH}/shaders/screen/scene.frag" "${R3D_ROOT_PATH}/shaders/screen/bloom.frag" "${R3D_ROOT_PATH}/shaders/screen/fog.frag" "${R3D_ROOT_PATH}/shaders/screen/tonemap.frag" "${R3D_ROOT_PATH}/shaders/screen/adjustment.frag" "${R3D_ROOT_PATH}/shaders/screen/fxaa.frag" ) ``` -------------------------------- ### Set C Standard for MSVC in CMake Source: https://github.com/bigfoot71/r3d/blob/master/CMakeLists.txt This snippet conditionally sets the C standard to C99 for the 'r3d' target when using CMake versions greater than 3.12. This ensures compatibility and proper compilation behavior, especially for MSVC compilers, by enforcing a specific C standard. ```CMake if(CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET r3d PROPERTY C_STANDARD 99) endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.