mbredif / cgp

Computer Graphics Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CGP - Computer Graphics Programming Library

BuildWindows BuildLinux BuildMacOS

Introduction

CGP - Computer Graphics Programming - is a lightweight and minimalist C++ library using OpenGL to represent, animate, and interact with 3D scenes.

It features a set of simple structures and functions (vectors, matrices, mesh structures, transforms, camera, etc) that are simple to use and read. The objective is to save time compared to raw OpenGL coding, while preserving the fundamental logic and comprehension of high-performance Graphics. The 3D scene can be exported as a Webpage via Emscripten scripts.

The main objective of CGP is to provide

  • Easy to use CG basic tools.
  • Data and structure ready for simple interaction and animation.
  • Helping structures and functions that do not impose a framework.
  • Easy to read and understand source code.
  • Secured and easy to debug code.

Additional documentation

CGP Webpage

Examples of CGP-based codes can be found in examples/

Compile the library

The directory library/ contains the source code of CGP, while the directory examples/ contains a set of example scenes. Each example is an independent program with its own CMakeLists.txt and/or Makefile.

CGP requires

  • A C++14 (or greater) compatible compiler (GCC/CLang, or a recent Visual Studio).
  • An OpenGL 3.3 (or greater) compatible system.
  • libGLFW and pkgconfig installed on Linux system.

Linux

System setup

sudo apt install build-essential pkg-config cmake
sudo apt install libglfw3-dev

Building examples/00_empty_3D_scene/ (via CMake)

cd examples/00_empty_3D_scene/
cmake -B build/
cd build/
make -j$(nproc)
./00_empty_3D_scene

Alternative: Building examples/00_empty_3D_scene/ (via Makefile)

cd examples/00_empty_3D_scene/
make -j$(nproc)
./00_empty_3D_scene

Windows

Method 1. Create a Visual Studio project using CMake

  • You may use the following batch script: examples/00_empty_3D_scene/scripts/windows_cmake_visual.bat

Once opened by Visual Studio, the project should be configured to compile and be executed directly without further setup. Make sure your Windows version is updated for Visual Studio to be able to compile correctly C++14.

Method 2. Install MinGW from MSYS2.

  • You may use the following batch script: examples/00_empty_3D_scene/scripts/windows_compile_mingw.bat
  • You may build/edit the project using VS Code.

MacOS

Building examples/00_empty_3D_scene/ (via CMake)

cd examples/00_empty_3D_scene/
cmake -B build/
cd build/
make -j$(nproc)
./00_empty_3D_scene

Detailed system set-up and compilation

A detailed tutorial on how to install and compile C++ code is available here if needed: Detailed installation and compilation for CGP.

Export result as a Website

CGP is set to be compatible with Emscripten compilation. A website template and compilation script is provided for Linux system (emscripten must be installed).

Generating a website for examples/00_empty_3D_scene/

$ cd examples/00_empty_3D_scene/
$ python scripts/linux_compile_emscripten.py
$ emrun index.html

About

Computer Graphics Library

License:MIT License


Languages

Language:C++ 99.9%Language:CMake 0.1%