Build Setup for Raftel Engine

This guide covers the build system setup for Raftel Engine, including how to configure your development environment, manage dependencies, and build your own projects with the engine.

Build System Overview

Raftel Engine uses a combination of these build tools:

CMake

Cross-platform build system generator that generates native build files for your platform and IDE.

Premake

Build configuration tool that generates project files for Visual Studio and other development environments.

Conan

C++ package manager that handles third-party library dependencies automatically.

Python Scripts

Custom scripts that automate parts of the build process and dependency management.

Setting Up the Build Environment

Step 1: Clone the Repository

Start by cloning the Raftel Engine repository from GitHub:

Clone Repository
git clone https://github.com/Marc433/3PVG_PMG_24_mazcunyabla_folgadoba.git
cd 3PVG_PMG_24_mazcunyabla_folgadoba

Step 2: Install Prerequisites

Make sure you have the required tools installed on your system:

Python Version Check

You can verify your Python version by running:

python --version

Make sure it shows version 3.6 or higher.

Step 3: Generate Dependencies

Run the dependency generator script to fetch and configure all required third-party libraries:

Generate Dependencies
cd tools
./gendeps.bat

This script performs the following tasks:

Dependency Configuration

The gendeps.bat script uses Conan profiles to configure dependencies for different build configurations. You can find these profiles in the tools/conan directory.

Step 4: Generate Project Files

Navigate back to the root directory and use Premake to generate project files for your preferred IDE:

Generate Project Files
cd ..  # Return to root directory
premake5.exe vs2022  # For Visual Studio 2022
# Or
premake5.exe vs2019  # For Visual Studio 2019

This command generates the solution and project files in the build directory.

Step 5: Open and Build the Solution

Open the generated solution file in Visual Studio:

Open Solution
cd build
start Raftel.sln

Once the solution is open in Visual Studio:

  1. Select the desired build configuration (Debug or Release) from the drop-down menu
  2. Right-click on the "Raftel" project in the Solution Explorer
  3. Select "Build" to compile the engine

Build Order

If you encounter build errors, make sure to build the projects in the correct order. The "Raftel" project should be built first, followed by any examples or applications that depend on it.

Creating Your Own Project

Once you have built Raftel Engine, you can create your own projects that use the engine.

Option 1: Using the Project Template

The easiest way to create a new Raftel Engine project is to use the provided template:

Create Project from Template
cd tools
python create_project.py --name MyProject --path C:/Projects

This script creates a new project with the basic structure and configuration files needed to use Raftel Engine.

Option 2: Manual Project Setup

Alternatively, you can set up a project manually by following these steps:

1. Create Project Structure

Project Structure
MyProject/
├── assets/
│   ├── models/
│   ├── shaders/
│   └── textures/
├── include/
├── src/
│   └── main.cpp
└── premake5.lua

2. Create a Premake Configuration File

Create a premake5.lua file in your project root with the following content:

premake5.lua
workspace "MyProject"
   configurations { "Debug", "Release" }
   platforms { "Win64" }
   location "build"

project "MyProject"
   kind "ConsoleApp"
   language "C++"
   cppdialect "C++17"
   targetdir "bin/%{cfg.buildcfg}"
   
   files { "src/**.h", "src/**.cpp", "include/**.h" }
   
   -- Adjust this path to point to your Raftel Engine installation
   local RAFTEL_PATH = "C:/Path/To/Raftel"
   
   includedirs { 
      "include",
      RAFTEL_PATH .. "/include"
   }
   
   libdirs {
      RAFTEL_PATH .. "/lib"
   }
   
   links { "Raftel" }
   
   filter "configurations:Debug"
      defines { "DEBUG" }
      symbols "On"
      runtime "Debug"
      
   filter "configurations:Release"
      defines { "NDEBUG" }
      optimize "On"
      runtime "Release"

3. Create a Basic Application

Create a main.cpp file in the src directory:

src/main.cpp
#include "raftel/window.hpp"

int main(void) {
    // Initialize window system
    auto windowSystemOpt = Raftel::WindowSystem::make();
    auto windowOpt = Raftel::Window::make("My Raftel Application", *windowSystemOpt);
    
    if (!windowOpt) {
        std::cerr < "Error creating window\n";
        return -1;
    }
    
    // Set up window context
    windowOpt->MakeContextCurrent();
    
    // Main render loop
    while (!windowOpt->ShouldClose()) {
        windowOpt->clear();
        // Your rendering code here
        windowOpt->swapBuffers();
    }
    
    return 0;
}

4. Generate and Build the Project

Build Project
cd MyProject
premake5 vs2022
cd build
start MyProject.sln

Build Configurations

Raftel Engine supports two main build configurations:

Debug

Includes debugging symbols and additional validation. Performance is slower, but it's easier to find and fix bugs.

  • No optimization
  • Debug symbols included
  • Additional runtime checks

Release

Optimized for performance with no debugging features. Use this for final builds or performance testing.

  • Full optimization
  • No debug symbols
  • Minimal runtime checks

Troubleshooting

Common Build Issues

Missing Dependencies

If you see errors about missing headers or libraries, make sure you ran the gendeps.bat script and that it completed successfully.

Linker Errors

If you encounter linker errors when building your project, check that:

  • The path to Raftel Engine in your premake5.lua file is correct
  • You've built the Raftel Engine library with the same configuration (Debug/Release)
  • The library file is in the expected location

Conan Errors

If Conan reports errors when generating dependencies, make sure:

  • You're using Conan version < 2.0
  • Your internet connection is stable
  • You have sufficient permissions to download and install packages

Next Steps

Now that you have set up your build environment, you're ready to start developing with Raftel Engine. Check out these tutorials to get started:

Creating a Window

Learn how to create and manage a window for your application.

Drawing a Triangle

Start with the fundamentals of rendering geometry.

Handling Input

Learn how to capture and respond to user input.

Loading 3D Meshes

Discover how to load and render 3D models.