Code Monkey home page Code Monkey logo

cpp-opengl-renderer's Introduction

cpp-opengl-renderer

Table of Contents

Summary

A cross-platform C++ OpenGL renderer

Features

  • Compilation on MacOS, Linux Ubuntu 20.04/22.04, Linux debian 11 and Windows 10/11 OS
  • Support for glTF scene loading
  • PBR shader pipeline considering primarily the metal roughness workflow
  • High code coverage with GoogleTest for methods in module structs and classes
  • Create CMakeLists.txt files for cross-platform build environment generation
  • CI workflows ensuring cross-platform compilation primarily for Desktop operating systems
  • CI workflows ensuring continuous testing of the modules
  • Cross-platform CPack packaging for Linux, MacOS and Windows OSes
  • Integrated simple menu (e.g. with sliders and other widgets)
  • Native file dialog support for loading new glTF scenes
  • PBR fragment shader with switchable fragmentColor for inspecting intermediate outcomes (OPTIONAL)
  • Support for USD scene loading (OPTIONAL)
  • Skeletal animation support (OPTIONAL)
  • Port Desktop application to the web trough emscripten SDK (OPTIONAL)
  • Consider compiled library for mobile support trough Java native interface (JNI) with kotlin and Swift native interface (SNI) with Swift (OPTIONAL)

Getting started

Preconditions

Integrate vcpkg with Visual Studio

Open a command prompt and navigate to the vcpkg directory. Run the following command to integrate vcpkg with Visual Studio: <vcpkg installation path>/vcpkg integrate install Run the following command from the vcpkg directory to install the dependencies specified in the vcpkg.json file: <vcpkg installation path>/vcpkg install

Mac OS

Ensure on MacOS you have installed brew with /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add brew to the PATH variable and substitute <your user> for:

`(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/<your user>/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"

Thereafter install the required brew packages/formulas with brew install pkg-config cmake

Debugging

Open the cpp-opengl-renderer.sln. Modify include pathes, library pathes and library names in the cpp-opengl-renderer.vcxproj. Confirm the presence of only one entry point int main(). Set breakpoints as needed. Initiate the debugging process. If you encounter DLL-related errors, make sure to copy the necessary dynamic libraries to the directory where the built executable is located and then rebuild.

Google Test build configurations

Make sure to configure the project settings appropriately for the Debug|x64 build configuration by setting the correct library path and copying the required DLLs:

  • Library path: <vcpkg installation path>/vcpkg/packages/gtest_x64-windows/debug/lib
  • Binary path: <vcpkg installation path>/vcpkg/packages/gtest_x64-windows/debug/bin

Similair for Release|x64 build configurations:

  • Library path: <vcpkg installation path>/vcpkg/packages/gtest_x64-windows/lib
  • Binary path: <vcpkg installation path>/vcpkg/packages/gtest_x64-windows/bin

CMake

Unix

In order to compile the source code and link the binaries run in a Unix terminal:

cd devops/scripts/bash/
./compile_source_code.sh -CMakeToolchainFile <path to the vcpkg.cmake file>

For web builds ensure the emscripten SDK is installed and then run:

cd devops/scripts/bash/
source <Path to emsdk folder>/emsdk_env.sh
./compile_source_code.sh -WebBuild 
# Copy build artifacts (.js, .wasm, .data) over to assets\web\html-js-wasm
# Start the dev container within the `.devcontainer/nginx` directory. Once inside the container, copy the contents of the assets/web/html-js-wasm directory to /usr/share/nginx/html
# Visit in a browser of choice `localhost:8090/rotating_texture_cube.html` or `localhost:8090/opengl_viewer.html`

In order to additionaly start the test executables in a Unix terminal:

cd devops/scripts/bash/
./compile_source_code.sh -CMakeToolchainFile <path to the vcpkg.cmake file> -RunTests

In order to create compressed files or packages:

cd build/
cpack -G <DEB, ZIP, TGZ, TXZ> # DEB only for Linux systems. Check further generators for the specific Unix OS and CPU arch via `cpack -G --help` 
cd ../packages
# install package or unzip compressed file

Windows

In order to compile the source code and link the binaries run in a PowerShell terminal:

cd devops\scripts\ps1
.\compile_source_code.ps1 -CMakeToolchainFile <path to the vcpkg.cmake file>

For web builds ensure the emscripten SDK is installed, ninja or mingw32-make are available and then run:

cd devops\scripts\ps1
source <Path to emsdk folder>\emsdk_env.bat
.\compile_source_code.ps1 -WebBuild
# Copy build artifacts (.js, .wasm, .data) over to assets/web/html-js-wasm
# Start the dev container within the `.devcontainer/nginx` directory. Once inside the container, copy the contents of the assets/web/html-js-wasm directory to /usr/share/nginx/html
# Visit in a browser of choice `localhost:8090/rotating_texture_cube.html` or `localhost:8090/opengl_viewer.html`

In order to additionaly start the test executables in a PowerShell terminal:

cd devops\scripts\ps1
.\compile_source_code.ps1 -CMakeToolchainFile <path to the vcpkg.cmake file> -RunTests

In order to create compressed files or installers:

cd build/
cpack -G <ZIP, NSIS, NSIS64> # Check further generators for later Windows OSes and CPU arch via `cpack -G --help` 
cd ../packages
# run installer or unzip compressed file

Apps

Images of the rendered scenes can be viewed here:

cpp-opengl-renderer's People

Contributors

mgthetrain avatar github-actions[bot] avatar nr461 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.