Code Monkey home page Code Monkey logo

opengl-sandbox's Introduction

opengl-sandbox

Personal OpenGL Sandbox.
Object-oriented implementation of basic rendering functionalities, done as university project on efficient programming.
This project uses CMake as build system. The supported compilers are MinGW, MSVC on Windows and GCC on Linux (tested on Lubuntu). A Visual Studio solution file is also provided.
For simplicity, required library files are contained within this repository.

Screenshot

Overview


Goal

The aim of this project is to implement different techniques commonly used in rendering engines and to provide a "sandbox" for testing and showcasing.
These implementations are definitely no perfectly engineered code. This is a learning project.

Implemented features:

Window abstraction

The GUI library IUP is used for a rudimentary GUI and to provide an OpenGL context. The entire window logic is abstracted away in a "window class".

OpenGL shader abstraction

The OpenGL shaders and shader programs are encapsulated in entitled classes.

Event system

A simple event system in a bus topology is implemented. Events are triggered by user interaction (e.g. mouse moving, clicking, resizing the window, ...). All relevant components of the program are connected to the event bus and act as "listeners". Control flow by an excessive amount of callbacks is avoided.

Camera system

A simple user input-controlled camera system is implemented. The camera rotates on a sphere around a target point while the target point itself can be shifted ("pan").
The implementation contains perspective and orthogonal camera projection modes and their handling.

Material system

A simple material system is implemented, following the general interpretation: Material = Shader + Uniforms. Uniforms which define a material are ownded by the material itself.
Currently, flat materials and Phong model materials are implemented (see FlatMaterial and PhongMaterial classes).

Simple Voxel World Grid

A simple voxel grid is defined from which voxel meshes are generated. Currently, the grid definition consists of 8x8x8 block sections which are simply held in a std::map and consist of flat char arrays.

3D object selection

A simple object selection via a casted ray is implemented for blocks which are contained in the voxel grid. The implementation makes a block selectable directly in the 3D rendering. It works by iterating through the grid along a ray. (The selection logic is encapsulated within MouseSelector).


Build instructions

NOTE: All instructions here show how to build a Release build. Debug builds can be built by changing the according CMake parameters.

Windows - MSVC/Visual Studio

mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 ..
cmake --build . --config Release -j

Windows - MinGW

mkdir build
cd build
cmake -G "MinGW Makefiles" ..
cmake --build . --config Release -j

Linux - GCC

mkdir build
cd build
cmake -G "Unix Makefiles" ..
cmake --build . --config Release -j

NOTE: Currently the resource folder res needs to be manually copied to the executable directory before running.
This will be changed in the future.
Copying can be manually done with e.g. scp -r ./res ./build/res


Code documentation

Doxygen HTML code documentation can be generated with the included Doxyfile:

doxygen Doxyfile

Third-party dependencies

All dependent libraries are included within this repository, see LICENSES.txt.


opengl-sandbox's People

Contributors

dwood2020 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.