Skip to content

Im-Rises/ParticleSystem

Repository files navigation

ParticleSystem

cmakeLogo cppLogo openglLogo glfwLogo

Description

This project is a particle system made in C++ using OpenGL and GLFW.

The UI is made using ImGui and allows you to modify some parameters of the particle system and the camera view.

This project has been ported to WebGL using Emscripten. You can find the source code here. The webgl version can be tested at the link below.

Note
This project was made as a learning exercise to learn some OpenGL features.

Features

  • Particle system
  • ImGui UI
  • Camera movement
  • Pausing the simulation
  • Different settings for the particle system
  • Different settings for the camera

Images and Videos

Watch the video

Watch the video

Click on the images to watch the video.

Dependencies

  • C++ 14
  • C++ compiler (MSVC, Mingw, ...)
  • CMake
  • Glad
  • GLFW (3.3.8)
  • OpenGl (3.3)
  • Dear ImGui (1.88)
  • glm (0.9.8.5)
  • stb (2.28)

Table of Contents

  1. Description
  2. Features
  3. Images and Videos
  4. Dependencies
  5. Table of Contents
  6. Project Architecture
  7. Quickstart
    1. Windows
    2. Linux
    3. MacOs
  8. Controls
  9. Compilation
    1. Windows
    2. Linux
    3. MacOs
  10. GitHub-Actions
  11. Documentation
  12. Contributors

Project Architecture

Click to expand
ParticleSystem
β”œβ”€β”€ .github
|  β”œβ”€β”€ labels.yml
|  β”œβ”€β”€ release.yml
β”‚  β”œβ”€β”€ workflows
β”‚  β”‚   |── cmake.yml
β”‚  β”‚   |── codeql.yml
β”‚  β”‚   |── cpp-cmake-publish.yml
β”‚  β”‚   |── cpp-linter.yml
β”‚  β”‚   |── dependency-review.yml
β”‚  β”‚   |── flawfinder.yml
β”‚  β”‚   |── greetings.yml
β”‚  β”‚   |── label.yml
β”‚  β”‚   |── msvc.yml
β”‚  β”‚   |── stale.yml
β”œβ”€β”€ dependencies
|  β”œβ”€β”€ glad
|  β”œβ”€β”€ glfw
|  β”œβ”€β”€ glm
|  β”œβ”€β”€ imgui
|  β”œβ”€β”€ stb
β”œβ”€β”€ ParticleSystem
|  β”œβ”€β”€ Shader
β”‚  β”‚   |── *
|  β”œβ”€β”€ Texture
β”‚  β”‚   |── *
|  β”œβ”€β”€ Scene
β”‚  β”‚   |── *
|  β”œβ”€β”€ CMakeLists.txt
|  β”œβ”€β”€ InputManager.cpp
|  β”œβ”€β”€ InputManager.h
|  β”œβ”€β”€ main.cpp
|  β”œβ”€β”€ ParticleSystemLauncher.cpp
|  β”œβ”€β”€ ParticleSystemLauncher.h
β”œβ”€β”€ .clang-format
β”œβ”€β”€ .clang-tidy
β”œβ”€β”€ .editorconfig
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ CMakelists.txt
β”œβ”€β”€ CMakePresets.json
β”œβ”€β”€ CMakeSettings.json
β”œβ”€β”€ imgui.ini
β”œβ”€β”€ README.md

Quickstart

To download the app, you can click one of the icons below (depending on your operating system). You can also click the release section of the GitHub page.

Depending on you operating system you will need to install some libs, they are installed differently depending on your system, please follow one of the section below Windows or Linux or MacOs.

For the compilation, follow the section Compilation.

The controls are described in the section Controls.

Warning Be sure to put the imgui.ini file in the same folder as the executable. You can find it in the root of the project. If you don't do this, the UI will not be displayed correctly.

Windows

cmakeLogo

For Windows users you don't need to install the libs. You can just download the app and run it.

.\ParticleSystem.exe

Linux

cmakeLogo

For Linux users, you need to install the GLFW lib, to do so type one of the following commands:

sudo apt-get install libglfw3

or if you're a developer and want to compile the app, please install this version of GLFW:

sudo apt-get install libglfw3-dev

Then you can start by double-clicking the executable of typing the following command next to it:

./ParticleSystem

MacOs

cmakeLogo

For macOS users you will need to install Brew, please follow the instruction in the link below:
https://brew.sh

Once it is installed, you can type the following command to install GLFW.

brew install glfw

Then you can start by double-clicking the executable of typing the following command next to it:

./ParticleSystem

Controls

The speed and some parameters can be modified directly in the ImGui windows.

Action Key
Translate camera (WASD) or (↑ ← ↓ β†’)
Pause/Resume P
Move up/down camera (Space/Shift) or (Page up/down)
Rotate camera Right Mouse Button + Mouse movement
Exit app Escape

Note You can the inputs by changing their attribution in the InputManager.cpp file, if so you'll need to compile the project.

Compilation

To compile the app, the first thing you need to do is install a C++ compiler:

  • Visual Studio (MSVC)
  • Mingw
  • ...

You also need to install Cmake:
https://cmake.org

Once your environment is set up, depending on your operating system you'll need to install some libs before compiling the project. Refer to the section below Windows or Linux or MacOs.

Windows

Windows users can directly compile the project by typing the following command at the project root folder:

cmake -B . -DCMAKE_BUILD_TYPE=<Debug/Release>

then

cmake --build . --config <Debug/Release>

You need to replace <Debug/Release> by the build type you want to use.

Note
If you're using Visual Studio, you can install CMake directly from the IDE (Visual Studio Installer). Then you need to open the Project as a CMake Project, not a Visual Studio Project!

Warning
The project is set up to be built using CMake and vc2019 for Windows. If you want to modify the compiler for vc2022 or other you will need to change the CMakeLists.txt .lib linking file accordingly to your vc20** version.

Linux

Linux's users need to install some libs before compiling the project:

First thing to do is to install CMake, type the following command to install it.

sudo apt-get install cmake

You also need to install the GLFW lib. Type the following command at the project root.

sudo apt-get install libglfw3-dev

You are now able to compile the project. Go to the project root and type the following command:

cmake -B . -DCMAKE_BUILD_TYPE=Release

MacOs

For macOS user, you should install brew package manager by following the instructions in the link below:
https://brew.sh

Then type the following command to install cmake:

brew install cmake

and this one to install GLFW

brew install glfw

You are now able to compile the project. Go to the project root and type the following command:

cmake -B . -DCMAKE_BUILD_TYPE=Release

Github-Actions

CodeQL CMake Cpp Cmake Publish flawfinder Microsoft C++ Code Analysis cpp-linter

The project is set with a set of different scripts:

  • CodeQL: This script is used to check the code for security issues.
  • CMake: This script is used to build the project.
  • Cpp Cmake Publish: This script is used to publish the project on GitHub.
  • Flawfinder: This script is used to check the code for security issues.
  • Microsoft C++ Code Analysis: This script is used to check the code for security issues.
  • Cpp Linter: This script is used to check the code for security issues.

Libraries

glfw:
https://www.glfw.org/docs/latest/

glm:
https://glm.g-truc.net/0.9.9/index.html

glad:
https://glad.dav1d.de/

stb (stb_image):
https://github.com/nothings/stb/blob/master/stb_image.h

Dear imgui:
https://github.com/ocornut/imgui

OpenGL:
https://www.opengl.org/

Documentation

learnopengl (OpenGL tutorial):
https://learnopengl.com/In-Practice/2D-Game/Particles

opengl-tutorial (OpenGL tutorial):
http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/particles-instancing/

3dgep:
https://www.3dgep.com/simulating-particle-effects-using-opengl/

levelup (Particle Generation):
https://levelup.gitconnected.com/how-to-create-instanced-particles-in-opengl-24cb089911e2

unrealistic.dev (Change CMake working directory):
https://unrealistic.dev/posts/setting-debug-parameters-with-cmake-tools-for-visual-studio

Contributors

Quentin MOREL:

GitHub contributors