Skip to content

eerii/fresa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fresa 🍓

A tiny game engine made in C 20.

This repository holds the legacy working version of fresa. fresa was being redesigned from scratch in a 'new' branch. I was reimplementing the entire API, this time with a focus on clarity and documentation. However, I no longer had the time to work on this project and I have moved on to other ways of making graphics. Still, this had taught me so much and is so special to me, and there are some things I'm really proud of hidden here.

▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼

Check the project template here

▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲

features ✨

Graphics

  • Custom renderer with Vulkan, OpenGL and WebGL support
  • Instanced rendering
  • Multiple shader subpasses
  • Automatic GLSL shader compilation for each API and reflection using SPIRV-Cross
  • High level API that allows complete customization of the cross platform renderer
  • Compute shaders and Indirect drawing (Vulkan only)

ECS

  • Data oriented Entity Component System
  • Scene management
  • Custom component controllers for specialized behaviour
  • Entity editor GUI

Reflection

  • C compile time type reflection implementation
  • Loop through each member of a struct and apply callables
  • Automatic serialization (save/load)

Other

  • Custom compile time state machine implementation
  • Input handling
  • Logging and debugging tools
  • Collision checking
  • Time managment and timers
  • Event handling

building 🔨

Right now the project is in the very pre-alpha state, so use it at your own risk.

Template: mermelada

You can check the template on how one could set up a fresa project. Detailed instructions on how to build it are there.

Dependencies

  • SDL2 (cross-platform window and input)
  • Vulkan/OpenGL (renderer of choice)
  • SPIR-V Cross (shader reflection and compilation)
  • VulkanMemoryAllocator (only Vulkan renderer, memory management)
  • imGUI (for a debug graphical interface)
  • stb_image (loading images)
  • glm (glsl linear algebra)

Included as submodules. Only SDL2 and VK/GL are needed.

Options

  • USE_VULKAN or USE_OPENGL: Enables the desired renderer
  • LOG_LEVEL = 1...5: Selects log verbosity, 1 being only errors and 5 debug
  • DISABLE_GUI: Disables the compilation of imGUI and all the GUI code
  • PROJECT_DIR: For debugging editor tools, the root of your project

code example 📚

main.cpp

#include "game.h"
#include "scene.h"

using namespace Fresa;

int main(int argc, const char * argv[]) {
    //: Initialize game
    bool running = Game::init();
    
    //: Load scene
    SceneID scene = registerScene();
    active_scene = scene;
    
    //: Update loop
    while (running) {
        running = Game::update();
    }
    
    //: Cleanup
    Game::stop();
    
    return EXIT_SUCCESS;
}

other files

To access the ECS capabilities, a component_list.h file may be created that #includes all the component headers you create, as well as a variant for the component type. Follow the instructions on ecs.h or the example in mermelada to create one.

You can also create a vertex_list.h to add new vertex type definitions to use with glsl.

license 📝

This project is licensed under GNU GPLv3.

Releases

No releases published

Languages