OpenGLSamples icon indicating copy to clipboard operation
OpenGLSamples copied to clipboard

OpenGLSamples

项目简介

此项目是作者在校学习图形学时,制作的OpenGL案例。主要参考了LearnOpenGL代码实现。项目中主要的功能包括:

  • glfw+glad+glm相关OpenGL环境配置
  • assimp加载模型
  • opencv摄像头捕获+视频编解码
  • imgui支持
  • freetype文字相关

案例覆盖(48个案例):

  • LearnOpenGL相关案例。阴影、法线贴图、深度贴图等
  • 光线追踪
  • 后处理
  • shaderToyGLSLSandbox兼容
  • OpenCV+Imgui滤镜
  • 分形几何相关

案例

  • 1.创建OpenGL窗口
1.1-createWindow
  • 2.绘制简单三角形
1.2-helloTriangle
  • 3.着色器初试
1.3-helloShader
  • 4.纹理初试
1.4-helloTexture
  • 5.三维变换
1.5-helloTransform
  • 6.坐标系统
1.6-helloCoordinateSystem
  • 7.相机
1.71-helloCamera
  • 8.第一人称相机
1.72-camera-freedom
  • 9.简单光照
2.1-sampleLighting
  • 10.光照贴图
2.2-lightingTexture
  • 11.射灯
2.3-castLiting
  • 12.模型加载
3.1-modelLoading
  • 13.模板测试(描边)
4.1-stencileTest
  • 14.混合
4.2-blend
  • 15.透明贴图
4.3-translucentTexture
  • 16.帧缓冲
4.4-frameBuffer
  • 17.立方体贴图(天空盒)
4.5-cubeMap
  • 18.几何着色器
4.6-geometryShader
  • 19.实例化(草地)
4.7-instantiation
  • 20.抗锯齿
4.8-antiAliasing
  • 21.Blinn-Phong光照模型
5.1-Blinn-Phong
  • 22.Gamma矫正
5.2-GammaCorrect
  • 23.点阴影
5.3.1-pointShadow
  • 24.万向阴影
5.3.2-universalShadow
  • 25.法线贴图
5.4-normalMap
  • 26.视差贴图
5.5-parallaxMapping
  • 27.HDR
5.6-HDR
  • 28.眩光
5.7-Bloom
  • 29.延迟渲染
5.8-deferredShading
  • 30.SSAO(屏幕空间环境光遮蔽)
5.9-ssao
  • 31.光线追踪(球+立方体)
6.1-rayTracing
  • 32.光线追踪(球,三维谢尔宾斯三角形)
6.2-rayTracing-Scherbinski_gasket
  • 33.文字渲染)
7.1-text

案例赏析

  • 1.朱莉亚集(Julia-set:分形几何)
Julia-Set
  • 2.Mandelbrot-Set(分形几何)
Mandelbrot-Set
  • 3.Worley噪声(分形几何)
Worley-Noise
  • 4.分形云
fractalCloud
  • 5.分形山
fractalMountain
  • 6.洛伦兹吸引子(混沌理论)
Lorentz-Attractor
  • 7.字符画(OpenCV+OpenGL+Imgui)
OpenGL+OpenCV
  • 8.星系(GLSL Sandbox)
galaxy
  • 9.imgui测试
imguiTest
  • 10.路径追踪(GLSL Sandbox)
rayCasting
  • 11.土星
saturn
  • 12.海洋
ocean
  • 13.独孤信印章-视差贴图
stamp-parallaxMapping
  • 14.独孤信印章
stamp
  • 15.滤镜测试
testFilter

编译

  • 第一次拉取代码需要编译第三方库
在third-party/目录下,终端执行`build.sh`编译三方库
  • 编译工程
根目录下终端执行`build.sh Debug` or `build.sh Release` 编译工程

编译完后可执行文件在build/bin/目录下

添加案例

  • samples/下新建文件夹
  • 文件结构:myTest/src/Test.cpp
  • 文件结构:此时cmake会扫描添加Test.cpp所在目录下所有.c、.cpp、.h、.hpp文件
  • 添加完后重新编译