Installing Raftel Engine

This guide will walk you through the process of installing Raftel Engine and setting up your development environment. Raftel Engine is a high-performance graphics engine built with C++ and OpenGL, designed for creating immersive 3D applications and games.

Prerequisites

Before installing Raftel Engine, ensure you have the following software installed on your system:

Python

Required for running build scripts and tools.

Download Python

Conan

Package manager for C++ (version < 2.0 required).

Download Conan

CMake

Cross-platform build system generator.

Download CMake

Visual Studio

IDE for development (2019 or 2022 recommended).

Download Visual Studio

Compatible Operating Systems

Raftel Engine currently supports Windows development. Support for macOS and Linux is under development.

Installation Steps

Step 1: Download Raftel Engine

Clone or download the Raftel Engine repository from GitHub:

Clone Repository
git clone https://github.com/your-username/raftel-engine.git
cd raftel-engine

Alternatively, you can download the engine as a ZIP file from the releases page.

Step 2: Generate Dependencies

Run the dependency generator script from the terminal:

Generate Dependencies
./tools/gendeps.bat

Dependency Resolution

This script automatically downloads and configures all required third-party libraries using Conan. Make sure your internet connection is stable during this process.

Step 3: Build the Project

Navigate to the root directory of the project and build using Premake:

Build Project
premake5.exe vs2022  # or vs2019, depending on your Visual Studio version

Step 4: Open and Run the Solution

Open the generated solution file in Visual Studio:

Open Solution
./build/Raftel.sln

Build and run the solution from within Visual Studio by pressing F5 or selecting "Debug > Start Debugging" from the menu.

Verifying Your Installation

To verify that Raftel Engine has been installed correctly, try running one of the example projects included with the engine:

  1. In Visual Studio's Solution Explorer, right-click on the "Examples" folder
  2. Select one of the example projects (e.g., "WindowExample")
  3. Set it as the startup project by right-clicking and selecting "Set as StartUp Project"
  4. Press F5 to build and run the example

If the example runs without errors, congratulations! Raftel Engine is now installed and ready to use.

Example: Terrain with Spot Light

Here's a simple example that demonstrates how to create a terrain model and display it using Raftel Engine:

Terrain with Spot Light Example
#include "raftel/window.hpp"
#include "raftel/shader.hpp"
#include "raftel/ecs.hpp"
#include "raftel/camera.hpp"
#include "raftel/imguiRenderer.hpp"
#include "raftel/systems.hpp"
#include "raftel/input.hpp"
#include "raftel/imguiWindows.hpp"
#include <fstream>
#include <string>

int main(void)
{
  // create window system and window
  auto windowSystemOpt = Raftel::WindowSystem::make();
  auto windowOpt = Raftel::Window::make("WindowTest", *windowSystemOpt);
  if (!windowOpt) {
    std::cerr << "Can't create window\n";
    return -1;
  }

  // make window context
  windowOpt->MakeContextCurrent();

  // create input
  Raftel::Input input(windowOpt->window_);

  //create core shader
  Raftel::ShaderProgram shader;
  if (!shader.load("../assets/shaders/lit.vs", "../assets/shaders/lit.fs")) {
    std::cerr << "Error al cargar los shaders.\n";
    return -1;
  }

  // movable camera
  Raftel::Camera cam(&input);

  // to create and show entities you need create entity system (ecs)
  auto ecs = std::make_unique<Raftel::EntityManager>();

  // we will create a entity terrain 
  // create entity
  auto terrain = ecs->CreateEntity();

  // create texture and mesh
  auto cube_t = Raftel::Texture::loadTexture("../assets/textures/cubetex.png");
  auto terrainMesh = Raftel::MeshFactory::createTerrain("../assets/heightmap/heightMap_test3.png", 1.0f, 200.0f, true);
  terrainMesh->GetMaterialByIndex(0)->setAlbedo(cube_t);
  terrainMesh->setupMesh();

  // add components to the entity
  terrain.addMeshComp(terrainMesh);
  terrain.addRenderComp(true);
  terrain.addTransformComp(Raftel::TransformComponent{
    glm::vec3(0.0f, -200.0f, -400.0f),
    glm::vec3(0.0f),
    glm::vec3(1.0f)
    });

  //add some light
  auto spotLightEntity = ecs->CreateEntity();
  spotLightEntity.addLightComp(Raftel::LightComponent(
    Raftel::LightComponent::LightType::SPOT,
    glm::vec3(1.0f, 0.8f, 0.6f),
    glm::vec3(0.0f),
    glm::vec3(0.0f),
    1.0f, 1000.0f, 170.0f, 200.0f,
    windowOpt->getScreenSize()));
  spotLightEntity.addMeshComp(Raftel::MeshFactory::createSphere(2.0f, 20));
  spotLightEntity.addRenderComp(true);
  spotLightEntity.addTransformComp({ glm::vec3(200.0f, -60.0f, -400.0f), glm::vec3(0.0f, 180.0f, -180.0f), glm::vec3(10.0f) });

  // Main render loop
  while (!windowOpt->ShouldClose())
  {
    //update input
    input.updateKeys();

    //camera controls
    cam.ChangeSpeedWithScroll(windowOpt.get(), 1.0f);
    cam.PossessedInput(windowOpt.get());
    cam.ToggleState(windowOpt.get(), Raftel::Input::Buttons::Mouse_Right);

    windowOpt->clear();

    //update camera
    cam.Update(windowOpt);

    //render system -> render the entities that you create in the ecs
    Raftel::RenderSystem::UpdateRenderSystem(*ecs, cam, shader, windowOpt->getScreenSize(), true);
    
    windowOpt->swapBuffers();
  }

  return 0;
}

Troubleshooting

Common Issues

Dependencies Failed to Download

If the dependency generator script fails, try the following:

  • Check your internet connection
  • Make sure Conan is properly installed and in your PATH
  • Try running the script with administrator privileges

Build Errors

If you encounter build errors:

  • Make sure all prerequisites are installed correctly
  • Check if the correct Visual Studio version is being used
  • Try cleaning the solution and rebuilding

Runtime Errors

If you encounter runtime errors:

  • Verify that all asset paths are correct
  • Check if OpenGL drivers are up to date
  • Make sure all required DLLs are in the correct location

Next Steps

Now that you've successfully installed Raftel Engine, you're ready to start exploring its features and creating your first applications.

Creating a Window

Learn how to create and manage application windows.

Drawing a Triangle

Start with the fundamentals of rendering geometry.

Entity Component System

Understand how to organize your scene with ECS architecture.

Lighting System

Learn how to implement different types of lights in your scene.

For complete API details, see the API Reference Documentation.