An open API service indexing awesome lists of open source software.

https://github.com/voldien/opengl-samples

OpenGL Samples - Basic to Advanced
https://github.com/voldien/opengl-samples

cpp graphics graphics-programming opengl opengl-api opengl-samples

Last synced: 6 months ago
JSON representation

OpenGL Samples - Basic to Advanced

Awesome Lists containing this project

README

          

[![Linux Build](https://github.com/voldien/opengl-samples/actions/workflows/linux-build.yml/badge.svg)](https://github.com/voldien/opengl-samples/actions/workflows/linux-build.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# OpenGL Sample Repository - Work In Progress

![github_opengl_thumbnail](https://github.com/user-attachments/assets/d3b6f060-8d80-479c-8543-b5a49bca78be)

A collection of OpenGL Samples, work in progress, for personal educational purposes.

## CLI - Command Line Options

```bash
Usage:
OpenGL Sample: GLSample [OPTION...]

GLSample options:
-h, --help helper information.
-d, --debug Enable Debug View. (default: true)
-t, --time arg How long to run sample (default: 0)
-f, --fullscreen Run in FullScreen Mode
-v, --vsync Vertical Blank Sync
-g, --opengl-version arg OpenGL Version (default: -1)
-F, --filesystem arg FileSystem (default: .)
-r, --renderdoc Enable RenderDoc
-G, --gamma-correction Enable Gamma Correction
-W, --width arg Set Window Width (default: -1)
-H, --height arg Set Window Height (default: -1)
-D, --display arg Display (default: -1)
-m, --multi-sample arg Set MSAA (default: 0)
-p, --use-postprocessing Use Post Processing (default: true)
-s, --glsl-version arg Override glsl version from system
```

## Graphic Based Samples

### [**Triangle**](Samples/Triangle)

![Triangle](https://github.com/voldien/OpenGL-Samples/assets/9608088/d85a24d2-97fb-4faa-a7ef-e71bdd979444)

### [**Texture**](Samples/Texture)

![Texture](https://github.com/voldien/OpenGL-Samples/assets/9608088/a87834cc-452e-41e0-8ea2-3de881780823)
![Texture](https://github.com/voldien/OpenGL-Samples/assets/9608088/7bdcaa6f-c0de-4030-b344-d6f180dc6e7b)

### [**Point Lights**](Samples/PointLight)

### ![PointLights](https://github.com/voldien/OpenGL-Samples/assets/9608088/dcd67197-4dc9-4333-ae6f-9fff9f7eb317)

### [**Normal Mapping**](Samples/NormalMap)

### [**SkyBox Cubemap**](Samples/Skybox)

![SkyboxPanoramic](https://github.com/voldien/OpenGL-Samples/assets/9608088/41cacd12-5782-46bd-b06b-dc3725f21b3d)

### [**SkyBox Panoramic**](Samples/Skybox)

![SkyboxPanoramic](https://github.com/voldien/OpenGL-Samples/assets/9608088/41cacd12-5782-46bd-b06b-dc3725f21b3d)

### [**Fog**](Samples/Fog)

![Fog](https://github.com/user-attachments/assets/f296f2b3-fed6-457c-9c87-5c7a610f4de3)

### [**Simple Reflection**](Samples/SimpleReflection/)

### [**Irradiance**](Samples/Irradiance/)

### [**Instance**](Samples/Instance)

![Instance](https://github.com/voldien/OpenGL-Samples/assets/9608088/8fb4adca-cd99-45c9-9811-38e727b6685b)

### [**SubSurface Scattering**](Samples/SubSurfaceScattering)

![Subsurface Scattering](https://github.com/voldien/OpenGL-Samples/assets/9608088/062f5af0-898e-4c1b-91ab-38975b898e0c)
![Subsurface Scattering](https://github.com/voldien/OpenGL-Samples/assets/9608088/ac752bfc-cc72-49ae-a9d6-2c729cd07c2d)

### [**Normal**](Samples/Normal)

![Normal](https://github.com/user-attachments/assets/d06d37ca-71d3-4346-91ef-266bc043a4f9)

### [**Blinn - Phong**](Samples/PhongBlinn/)

![PhongBlinn](https://github.com/voldien/OpenGL-Samples/assets/9608088/e14e4035-1639-4532-a316-65c8c879abf9)
![PhongBlinn](https://github.com/voldien/OpenGL-Samples/assets/9608088/02ae2bac-974e-4270-b80f-a59dba260160)

### [**Terrain**](Samples/Terrain/)

![Terrain](https://github.com/user-attachments/assets/2bf63a11-dc83-4c42-b823-7d45bab0eabd)

### [**FrustumCulling**](Samples/Frustum/)

![FrustumCulling](https://github.com/user-attachments/assets/41275f2f-9a65-4e56-81ac-956e758b62bd)

### [**Shadow Map**](Samples/ShadowMapping/)

![BasicShadowMapp](https://github.com/user-attachments/assets/f4596f70-1f89-4595-912c-dd3848c0788c)

### [**Shadow Map PCF**](Samples/ShadowMapping/)

![BasicShadowMap PCF](https://github.com/user-attachments/assets/f98cab19-afc2-454b-b843-c15aa821821f)
![BasicShadowMap PCF](https://github.com/user-attachments/assets/cae348e3-9c2a-4443-8119-02f018fc0109)

### [**Point Shadow Light**](Samples/ShadowPointLight/)

![PointLightShadow](https://github.com/user-attachments/assets/daaf91b3-b0ee-4b55-a182-ad326b0e2634)

### [**Shadow Projection**](Samples/ProjectedShadow/)

![ProjectedShadow](https://github.com/user-attachments/assets/d1a17f8e-21c5-42e3-8e4a-094bbe3d8a0b)

### [**Shadow Map Variance**](Samples/ShadowVariance/)

### **Shadow Volume**

### [**Tessellation Basic**](Samples/Tessellation/)

### [**MipMap Visual**](Samples/MipMapVisual/)

![MipMapVisual](https://github.com/voldien/OpenGL-Samples/assets/9608088/ea0714f4-4971-42ad-80db-4d567dc29b03)

### [**Multipass**](Samples/MultiPass/)

![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/6c156319-7617-43aa-af08-93d709bc07e9)

### [**Deferred Rendering**](Samples/Deferred/)

### [**Ambient Occlusion**](Samples/AmbientOcclusion/)

![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/91691104-4c70-4d25-91c0-17cb4bcf38af)
![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/4e8f9d85-b48d-4fc4-816d-632a9bbfd37f)
![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/4df33593-64f3-4a03-87b5-5e9d205642c5)
![AmbientOcclusion](https://github.com/voldien/OpenGL-Samples/assets/9608088/8ed5a638-2432-4800-8ead-2c5f4881fffc)

### **Physical Based Rendering**

### [**Panoramic**](Samples/Panoramic/)

![Panoramic](https://github.com/user-attachments/assets/3431b44d-0932-49cb-a96e-7cc6b4bbd8f2)
![Panoramic](https://github.com/user-attachments/assets/dd618200-ea77-4844-a56f-7b863878864f)

### [**Skinned Mesh**](Samples/SkinnedMesh/)

### [**Simple Ocean**](Samples/SimpleOcean/)

![SimpleOcean](https://github.com/user-attachments/assets/a9a12328-0428-44c6-9f67-3dae211ce358)

### [**Video Playback**](Samples/VideoPlayback/)

## Compute Shader Base Examples

### [**Ray Tracing**](Samples/RayTracing/Ray/)

### [**Game Of Life**](Samples/GameOfLife)

![GameOfLife](https://github.com/voldien/OpenGL-Samples/assets/9608088/5617752d-cd6d-4ceb-9918-f5015565489f)

### [**Mandelbrot**](Samples/Mandelbrot/)

![MandelBrot](https://github.com/user-attachments/assets/e54c7c89-fc88-4048-86f0-92f32cfccc25)

### [**ReactionDiffusion**](Samples/ReactionDiffusion)

### [**Vector Field 2D**](Samples/VectorField2D/)

![VectorField2D](https://github.com/user-attachments/assets/43b3da51-83d6-4b51-ae06-792b01493c2a)

### [**Compute Group Visual**](Samples/ComputeGroupVisual/)

![ComputeGroup](https://github.com/user-attachments/assets/a06d9256-05fa-4e16-9621-e2f7b473c9c5)

### [**Marching Cube**](Samples/MarchingCube/)

![MarchingCube](https://github.com/user-attachments/assets/f748e312-737c-4106-877b-93b59a9778d5)

### [**Rigidbody**](Samples/Rigidbody/)

![RigidBody](https://github.com/user-attachments/assets/74e55eea-8f19-4a80-82b1-e88952334db0)

## PostProcessing Effects

- **Chromatic Aberration**

- **Sobel Edge Detection**

- **Screen Space Ambient Occlusion**

- **Gaussian/Box Blur**

- **Mist Fog**

- **Volumetric Scattering**

![Volumetric](https://github.com/user-attachments/assets/a899f5da-8a9c-46eb-82e3-990f96ff7028)

- **ColorSpace**

- **Pixelate**

- **Grain**

- **Bloom**

- **Contact Shadow**

## Required Packages

```bash
apt-get install pkg-config libsdl2-dev libfreeimage-dev libfmt-dev libglm-dev libgtest-dev googletest mesa-common-dev mesa-utils libopenal-dev libalut-dev
apt-get install glslang-tools libassimp-dev libavcodec-dev libavformat-dev libswscale-dev libavutil-dev binutils-dev libeigen3-dev libglu1-mesa-dev libbz2-dev \
libzip-dev libogg-dev libopus-dev libvorbis-dev
```

## Build Instruction

```bash
git submodule update --init --recursive
mkdir build && cd build
cmake ..
make
make DownloadAsset
```

## License

This project is licensed under the GPL+3 License - see the [LICENSE](LICENSE) file for details

Models downloaded from Morgan McGuire's [Computer Graphics Archive](https://casual-effects.com/data)

## Misc Notes

### Force NVIDIA Usage

Force the system to try to use the NVIDIA GPU. This is very useful when using a system with multiple GPUs.

```bash
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia program arguments
```