AI generated
AI assisted

Welcome to the installation guide for the Dominique library. Follow these steps to get Dominique up and running in your project.

This guide explains how to set up and run the Dominique Native library using CMake in a C++ project.

Prerequisites

Ensure you have the following tools installed:

  • C++ Compiler (GCC, Clang, MSVC)
  • CMake (version 3.15 or higher)
  • Git

Installation

Step 1: Clone the Repository

git clone https://github.com/Dominique-Game-Engine/dominique-native.git
cd dominique-native

Step 2: Build Dominique Native

  1. Create a build folder and configure the project:

    mkdir build
    cd build
    cmake .. -DCMAKE_INSTALL_PREFIX=../DominiqueSDK
    cmake --build . --config Release --target install
    
  2. This will install Dominique SDK to DominiqueSDK/, containing:

dominique-native/
├── DominiqueSDK/
│   ├── include/
│   ├── lib/
│   └── bin/

Project Setup

Project Directory Structure

MyProject/
├── CMakeLists.txt
├── examples/
│   └── main.cpp
├── DominiqueSDK/
│   ├── include/
│   ├── lib/
│   └── bin/
└── res/
    ├── WaterBottle.gltf
    ├── shaders/
    │   ├── baseFragment.glsl
    │   └── baseVertex.glsl
    └── textures/
        └── lava.png

CMakeLists.txt

# CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(MyProject)

# Define output folders
set(EXAMPLES_FOLDER ${CMAKE_BINARY_DIR}/examples)

# Set Dominique SDK path
set(DOMINIQUE_SDK "${PROJECT_SOURCE_DIR}/DominiqueSDK")

# Define the example executable
add_executable(DEexample "examples/main.cpp")

# Include and link Dominique Native
target_include_directories(DEexample PRIVATE ${DOMINIQUE_SDK}/include)
target_link_directories(DEexample PRIVATE ${DOMINIQUE_SDK}/lib)
target_link_libraries(DEexample PRIVATE Dominique)

# Set output directory
set_target_properties(DEexample PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${EXAMPLES_FOLDER})

# Add required resources
set(ExamplesRequiredExtras
    "res/WaterBottle.gltf"
    "res/shaders/baseFragment.glsl"
    "res/shaders/baseVertex.glsl"
    "res/textures/lava.png"
)

# Resource copying after build
get_target_property(EXAMPLES_BINARY_EXECUTABLE_OUTPUT DEexample RUNTIME_OUTPUT_DIRECTORY)

foreach (_file ${ExamplesRequiredExtras})
    if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
        list(APPEND extraFiles COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${PROJECT_SOURCE_DIR}/${_file}" "${EXAMPLES_BINARY_EXECUTABLE_OUTPUT}/$<CONFIG>/")
    else ()
        list(APPEND extraFiles COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${PROJECT_SOURCE_DIR}/${_file}" "${EXAMPLES_BINARY_EXECUTABLE_OUTPUT}/")
    endif ()
endforeach ()

add_custom_command(TARGET DEexample POST_BUILD ${extraFiles})

Building the Project

  1. Create a build directory in your project:

    mkdir build
    cd build
    cmake ..
    cmake --build .
    
  2. Run the built example executable:

    ./examples/DEexample
    

Example Code (main.cpp)

Here’s how to use Dominique Native in main.cpp:

#ifndef APP_VERSION
#define APP_VERSION "0.0.0"
#endif

#include <iostream>
#include <glm/glm.hpp>

// Dominique Includes
#include "dengine/ecs/ecs.hpp"
#include "dengine/core.h"
#include "dengine/sdl_helpers.h"
#include "dengine/spdlog_helper.h"
#include "dengine/utils/uuid.h"
#include "dengine/components/scriptable.hpp"
#include "dengine/components/camera.hpp"
#include "dengine/utils/fileLoader.h"

using namespace std;

int main() {
    // Initialize the engine
    de::DE App;

    // Display renderer information
    de::logSDL2renderersInfo();

    // Create a new scene
    de::ecs::Scene scene;

    // Create and configure a camera
    de::ecs::EntityID camera = scene.NewEntity();
    scene.Assign<de::components::Camera>(camera);

    // Load models
    getMultiSinkLogger().info("Loading models...");
    de::utils::LoadGLTF("res/WaterBottle.gltf");
    de::utils::LoadObj("res/Prop_Tree_Palm_3.obj");

    // Initialize and run the application
    de::core::Init(App);
    de::core::Run(App, scene);
    de::core::Clean(App);

    return 0;
}

Usage Notes

  • App Lifecycle: Use de::core::Init(), de::core::Run(), and de::core::Clean() for initialization, execution, and cleanup.
  • Model Loading: Load models using de::utils::LoadGLTF() and de::utils::LoadObj().
  • Logging: Use getMultiSinkLogger() for debugging and engine information.

Troubleshooting

  • Incorrect Paths: Ensure resource paths are correctly set.
  • Missing Files: Ensure libraries and includes from DominiqueSDK are correctly installed and referenced.
  • Rebuild the Project: If CMake or the build process fails, delete the build/ directory and try again.

Contributing

Follow the CONTRIBUTING.md file guidelines for contributing.


License

Dominique Native is licensed under the MIT License.


Thank you for using Dominique Native! Let us know if you have any feedback or suggestions.