├── .gitattributes ├── .gitignore ├── .gitmodules ├── 001-creating-opengl4-window ├── 001-creating-opengl4-window.cpp ├── 001-creating-opengl4-window.h ├── 001-creating-opengl4-window.vcxproj ├── 001-creating-opengl4-window.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 002-first-shader ├── 002-first-shader.cpp ├── 002-first-shader.h ├── 002-first-shader.vcxproj ├── 002-first-shader.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 003-adding-colors ├── 003-adding-colors.cpp ├── 003-adding-colors.h ├── 003-adding-colors.vcxproj ├── 003-adding-colors.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 004-entering-third-dimension ├── 004-entering-third-dimension.cpp ├── 004-entering-third-dimension.h ├── 004-entering-third-dimension.vcxproj ├── 004-entering-third-dimension.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 005-camera-pt1-simple-walking-camera ├── 005-camera-pt1-simple-walking-camera.cpp ├── 005-camera-pt1-simple-walking-camera.h ├── 005-camera-pt1-simple-walking-camera.vcxproj ├── 005-camera-pt1-simple-walking-camera.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 006-camera-pt2-flying-camera ├── 006-camera-pt2-flying-camera.cpp ├── 006-camera-pt2-flying-camera.h ├── 006-camera-pt2-flying-camera.vcxproj ├── 006-camera-pt2-flying-camera.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 007-textures-pt1-single-texture ├── 007-textures-pt1-single-texture.cpp ├── 007-textures-pt1-single-texture.h ├── 007-textures-pt1-single-texture.vcxproj ├── 007-textures-pt1-single-texture.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 008-textures-pt2-multitexturing ├── 008-textures-pt2-multitexturing.cpp ├── 008-textures-pt2-multitexturing.h ├── 008-textures-pt2-multitexturing.vcxproj ├── 008-textures-pt2-multitexturing.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 009-orthographic-2D-projection ├── 009-orthographic-2D-projection.cpp ├── 009-orthographic-2D-projection.h ├── 009-orthographic-2D-projection.vcxproj ├── 009-orthographic-2D-projection.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 010-first-great-refactoring ├── 010-first-great-refactoring.cpp ├── 010-first-great-refactoring.h ├── 010-first-great-refactoring.vcxproj ├── 010-first-great-refactoring.vcxproj.filters ├── CMakeLists.txt ├── HUD010.cpp ├── HUD010.h └── main.cpp ├── 011-indexed-rendering-torus ├── 011-indexed-rendering-torus.cpp ├── 011-indexed-rendering-torus.h ├── 011-indexed-rendering-torus.vcxproj ├── 011-indexed-rendering-torus.vcxproj.filters ├── CMakeLists.txt └── main.cpp ├── 012-freetype-fonts-pt1 ├── 012-freetype-fonts-pt1.cpp ├── 012-freetype-fonts-pt1.h ├── 012-freetype-fonts-pt1.vcxproj ├── 012-freetype-fonts-pt1.vcxproj.filters ├── CMakeLists.txt ├── HUD012.cpp ├── HUD012.h └── main.cpp ├── 013-blending-pt1 ├── 013-blending-pt1.cpp ├── 013-blending-pt1.h ├── 013-blending-pt1.vcxproj ├── 013-blending-pt1.vcxproj.filters ├── CMakeLists.txt ├── HUD013.cpp ├── HUD013.h └── main.cpp ├── 014-normals-diffuse-lighting ├── 014-normals-diffuse-lighting.cpp ├── 014-normals-diffuse-lighting.h ├── 014-normals-diffuse-lighting.vcxproj ├── 014-normals-diffuse-lighting.vcxproj.filters ├── CMakeLists.txt ├── HUD014.cpp ├── HUD014.h └── main.cpp ├── 015-geometry-shaders ├── 015-geometry-shaders.cpp ├── 015-geometry-shaders.h ├── 015-geometry-shaders.vcxproj ├── 015-geometry-shaders.vcxproj.filters ├── CMakeLists.txt ├── HUD015.cpp ├── HUD015.h └── main.cpp ├── 016-heightmap-pt1-random-terrain ├── 016-heightmap-pt1-random-terrain.cpp ├── 016-heightmap-pt1-random-terrain.h ├── 016-heightmap-pt1-random-terrain.vcxproj ├── 016-heightmap-pt1-random-terrain.vcxproj.filters ├── CMakeLists.txt ├── HUD016.cpp ├── HUD016.h └── main.cpp ├── 017-heightmap-pt2-from-image-and-skybox ├── 017-heightmap-pt2-from-image-and-skybox.cpp ├── 017-heightmap-pt2-from-image-and-skybox.h ├── 017-heightmap-pt2-from-image-and-skybox.vcxproj ├── 017-heightmap-pt2-from-image-and-skybox.vcxproj.filters ├── CMakeLists.txt ├── HUD017.cpp ├── HUD017.h └── main.cpp ├── 018-heightmap-pt3-multiple-layers ├── 018-heightmap-pt3-multiple-layers.cpp ├── 018-heightmap-pt3-multiple-layers.h ├── 018-heightmap-pt3-multiple-layers.vcxproj ├── 018-heightmap-pt3-multiple-layers.vcxproj.filters ├── CMakeLists.txt ├── HUD018.cpp ├── HUD018.h └── main.cpp ├── 019-assimp-model-loading ├── 019-assimp-model-loading.cpp ├── 019-assimp-model-loading.h ├── 019-assimp-model-loading.vcxproj ├── 019-assimp-model-loading.vcxproj.filters ├── CMakeLists.txt ├── HUD019.cpp ├── HUD019.h └── main.cpp ├── 020-fog ├── 020-fog.cpp ├── 020-fog.h ├── 020-fog.vcxproj ├── 020-fog.vcxproj.filters ├── CMakeLists.txt ├── HUD020.cpp ├── HUD020.h └── main.cpp ├── 021-specular-highlight ├── 021-specular-highlight.cpp ├── 021-specular-highlight.h ├── 021-specular-highlight.vcxproj ├── 021-specular-highlight.vcxproj.filters ├── CMakeLists.txt ├── HUD021.cpp ├── HUD021.h └── main.cpp ├── 022-cylinder-and-sphere ├── 022-cylinder-and-sphere.cpp ├── 022-cylinder-and-sphere.h ├── 022-cylinder-and-sphere.vcxproj ├── 022-cylinder-and-sphere.vcxproj.filters ├── CMakeLists.txt ├── HUD022.cpp ├── HUD022.h ├── main.cpp ├── planet.cpp ├── planet.h ├── spaceStation.cpp └── spaceStation.h ├── 023-point-lights ├── 023-point-lights.cpp ├── 023-point-lights.h ├── 023-point-lights.vcxproj ├── 023-point-lights.vcxproj.filters ├── CMakeLists.txt ├── HUD023.cpp ├── HUD023.h └── main.cpp ├── 024-uniform-buffer-object ├── 024-uniform-buffer-object.cpp ├── 024-uniform-buffer-object.h ├── 024-uniform-buffer-object.vcxproj ├── 024-uniform-buffer-object.vcxproj.filters ├── CMakeLists.txt ├── HUD024.cpp ├── HUD024.h ├── main.cpp ├── pointLightExtended.cpp └── pointLightExtended.h ├── 025-transform-feedback-particle-system ├── 025-transform-feedback-particle-system.cpp ├── 025-transform-feedback-particle-system.h ├── 025-transform-feedback-particle-system.vcxproj ├── 025-transform-feedback-particle-system.vcxproj.filters ├── CMakeLists.txt ├── HUD025.cpp ├── HUD025.h ├── fireParticleSystem.cpp ├── fireParticleSystem.h ├── main.cpp ├── snowCoveredPlainGround.cpp ├── snowCoveredPlainGround.h ├── snowParticleSystem.cpp └── snowParticleSystem.h ├── 026-camera-pt3-orbit-camera ├── 026-camera-pt3-orbit-camera.cpp ├── 026-camera-pt3-orbit-camera.h ├── 026-camera-pt3-orbit-camera.vcxproj ├── 026-camera-pt3-orbit-camera.vcxproj.filters ├── CMakeLists.txt ├── HUD026.cpp ├── HUD026.h └── main.cpp ├── 027-occlusion-query ├── 027-occlusion-query.cpp ├── 027-occlusion-query.h ├── 027-occlusion-query.vcxproj ├── 027-occlusion-query.vcxproj.filters ├── CMakeLists.txt ├── HUD027.cpp ├── HUD027.h ├── main.cpp ├── objectsWithOccluderManager.cpp └── objectsWithOccluderManager.h ├── 028-framebuffer-3D-color-picking ├── 028-framebuffer-3D-color-picking.cpp ├── 028-framebuffer-3D-color-picking.h ├── 028-framebuffer-3D-color-picking.vcxproj ├── 028-framebuffer-3D-color-picking.vcxproj.filters ├── CMakeLists.txt ├── HUD028.cpp ├── HUD028.h ├── main.cpp ├── objectPicker.cpp ├── objectPicker.h ├── world.cpp └── world.h ├── 029-framebuffer-rendering-to-a-texture ├── 029-framebuffer-rendering-to-a-texture.cpp ├── 029-framebuffer-rendering-to-a-texture.h ├── 029-framebuffer-rendering-to-a-texture.vcxproj ├── 029-framebuffer-rendering-to-a-texture.vcxproj.filters ├── CMakeLists.txt ├── HUD029.cpp ├── HUD029.h ├── main.cpp ├── world.cpp └── world.h ├── 030-animation-pt1-keyframe-md2 ├── 030-animation-pt1-keyframe-md2.cpp ├── 030-animation-pt1-keyframe-md2.h ├── 030-animation-pt1-keyframe-md2.vcxproj ├── 030-animation-pt1-keyframe-md2.vcxproj.filters ├── HUD030.cpp ├── HUD030.h ├── main.cpp ├── modelCollection.cpp └── modelCollection.h ├── CMakeLists.txt ├── LICENSE.md ├── README.md ├── bin └── data │ ├── heightmaps │ ├── tut017.png │ ├── tut018.png │ └── tut019.png │ ├── models │ ├── animated │ │ └── md2 │ │ │ ├── blade │ │ │ ├── blade.jpg │ │ │ └── blade.md2 │ │ │ ├── samourai │ │ │ ├── samourai.jpg │ │ │ └── samourai.md2 │ │ │ └── warrior │ │ │ ├── CC_attribution_licence.txt │ │ │ ├── GNU_licence.txt │ │ │ ├── Readme.txt │ │ │ ├── warrior.jpg │ │ │ └── warrior.md2 │ ├── house │ │ ├── house.3ds │ │ └── house.jpg │ ├── medieval_house │ │ ├── medieval_house.obj │ │ ├── medieval_house_diff.png │ │ ├── medieval_house_normals.png │ │ └── medieval_house_spec.png │ └── scheune_3ds │ │ ├── scheune.3ds │ │ ├── scheune2.jpg │ │ ├── stroh1.jpg │ │ └── wood.jpg │ ├── shaders │ ├── common │ │ └── random.glsl │ ├── fog │ │ └── fog.frag │ ├── heightmap │ │ ├── multilayer.frag │ │ ├── multilayer.vert │ │ ├── multilayer_fog.frag │ │ └── multilayer_fog.vert │ ├── lighting │ │ ├── ambientLight.frag │ │ ├── diffuseLight.frag │ │ ├── pointLight.frag │ │ └── specularHighlight.frag │ ├── normals │ │ ├── normals.frag │ │ ├── normals.geom │ │ └── normals.vert │ ├── single-color │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut002 │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut003 │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut004 │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut007 │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut008 │ │ ├── ground_shader.frag │ │ └── ground_shader.vert │ ├── tut009 │ │ ├── ortho2D.frag │ │ └── ortho2D.vert │ ├── tut012 │ │ ├── font2D.frag │ │ └── font2D.vert │ ├── tut014-diffuse-lighting │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut020-fog │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut021-specular-highlight │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut023-point-lights │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut024-ubos │ │ ├── multilayer_heightmap.frag │ │ ├── multilayer_heightmap.vert │ │ ├── shader.frag │ │ └── shader.vert │ ├── tut025-particle-system-tf │ │ ├── fire_render.frag │ │ ├── fire_render.geom │ │ ├── fire_render.vert │ │ ├── fire_update.geom │ │ ├── fire_update.vert │ │ ├── ground_shader.frag │ │ ├── ground_shader.vert │ │ ├── shader.frag │ │ ├── shader.vert │ │ ├── snow_render.frag │ │ ├── snow_render.geom │ │ ├── snow_render.vert │ │ ├── snow_update.geom │ │ └── snow_update.vert │ └── tut030-animation-pt1-keyframe-md2 │ │ └── md2anim.vert │ ├── skyboxes │ ├── desert │ │ ├── back.png │ │ ├── front.png │ │ ├── left.png │ │ ├── right.png │ │ └── top.png │ ├── jajlake1 │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ ├── jajlands1 │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ ├── jajsnow1 │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ ├── jajsundown1 │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ └── space_lightblue │ │ ├── README.txt │ │ ├── back.jpg │ │ ├── bottom.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── top.jpg │ └── textures │ ├── brick.png │ ├── clay.png │ ├── cobblestone_mossy.png │ ├── crate.png │ ├── diamond.png │ ├── grass.jpg │ ├── ice.png │ ├── metal.png │ ├── particles │ ├── fire.bmp │ └── snowflakes.bmp │ ├── pavement.jpg │ ├── prismarine_dark.png │ ├── rocky_terrain.jpg │ ├── sand.png │ ├── scifi_metal.jpg │ ├── snow.png │ ├── solar_system │ ├── 2k_earth_daymap.jpg │ ├── 2k_jupiter.jpg │ ├── 2k_mars.jpg │ ├── 2k_mercury.jpg │ ├── 2k_neptune.jpg │ ├── 2k_saturn.jpg │ ├── 2k_sun.jpg │ ├── 2k_uranus.jpg │ ├── 2k_venus_surface.jpg │ └── README.txt │ ├── tut007 │ ├── mag_linear_min_linear.png │ ├── mag_linear_min_linear_mipmap.png │ ├── mag_linear_min_linear_mipmap_linear.png │ ├── mag_linear_min_nearest.png │ ├── mag_linear_min_nearest_mipmap.png │ ├── mag_nearest_min_bilinear.png │ ├── mag_nearest_min_linear_mipmap.png │ ├── mag_nearest_min_linear_mipmap_linear.png │ ├── mag_nearest_min_nearest.png │ └── mag_nearest_min_nearest_mipmap.png │ ├── tut008 │ ├── house_texture_front.png │ ├── house_texture_side.png │ └── path.png │ ├── tut009 │ ├── christmas_tree.png │ └── snowflake.png │ ├── white_marble.jpg │ └── wood.jpg ├── common_classes ├── HUD.cpp ├── HUD.h ├── HUDBase.cpp ├── HUDBase.h ├── OpenGLWindow.cpp ├── OpenGLWindow.h ├── animated_meshes_3D │ ├── md2model.cpp │ └── md2model.h ├── flyingCamera.cpp ├── flyingCamera.h ├── frameBuffer.cpp ├── frameBuffer.h ├── freeTypeFont.cpp ├── freeTypeFont.h ├── freeTypeFontManager.cpp ├── freeTypeFontManager.h ├── gldebug.h ├── matrixManager.cpp ├── matrixManager.h ├── occlusionQuery.cpp ├── occlusionQuery.h ├── orbitCamera.cpp ├── orbitCamera.h ├── ostreamUtils.h ├── random.cpp ├── random.h ├── renderBuffer.cpp ├── renderBuffer.h ├── sampler.cpp ├── sampler.h ├── samplerManager.cpp ├── samplerManager.h ├── shader.cpp ├── shader.h ├── shaderManager.cpp ├── shaderManager.h ├── shaderProgram.cpp ├── shaderProgram.h ├── shaderProgramManager.cpp ├── shaderProgramManager.h ├── shader_structs │ ├── ambientLight.cpp │ ├── ambientLight.h │ ├── diffuseLight.cpp │ ├── diffuseLight.h │ ├── fogParameters.cpp │ ├── fogParameters.h │ ├── material.cpp │ ├── material.h │ ├── pointLight.cpp │ ├── pointLight.h │ ├── shaderStruct.cpp │ └── shaderStruct.h ├── simpleWalkingCamera.cpp ├── simpleWalkingCamera.h ├── staticGeometry.cpp ├── staticGeometry.h ├── static_meshes_2D │ ├── primitives │ │ ├── quad.cpp │ │ └── quad.h │ ├── staticMesh2D.cpp │ └── staticMesh2D.h ├── static_meshes_3D │ ├── assimpModel.cpp │ ├── assimpModel.h │ ├── heightmap.cpp │ ├── heightmap.h │ ├── heightmapWithFog.cpp │ ├── heightmapWithFog.h │ ├── house.cpp │ ├── house.h │ ├── plainGround.cpp │ ├── plainGround.h │ ├── primitives │ │ ├── cube.cpp │ │ ├── cube.h │ │ ├── cylinder.cpp │ │ ├── cylinder.h │ │ ├── pyramid.cpp │ │ ├── pyramid.h │ │ ├── sphere.cpp │ │ ├── sphere.h │ │ ├── torus.cpp │ │ └── torus.h │ ├── skybox.cpp │ ├── skybox.h │ ├── snowCoveredPlainGround.cpp │ ├── snowCoveredPlainGround.h │ ├── staticMesh3D.cpp │ ├── staticMesh3D.h │ ├── staticMeshIndexed3D.cpp │ └── staticMeshIndexed3D.h ├── stringUtils.h ├── texture.cpp ├── texture.h ├── textureManager.cpp ├── textureManager.h ├── transformFeedbackParticleSystem.cpp ├── transformFeedbackParticleSystem.h ├── uniform.cpp ├── uniform.h ├── uniformBufferObject.cpp ├── uniformBufferObject.h ├── vertexBufferObject.cpp └── vertexBufferObject.h ├── common_properties_debug.props ├── common_properties_debug64.props ├── common_properties_release.props ├── common_properties_release64.props ├── dependencies ├── assimp-prebuilt │ ├── include │ │ └── assimp │ │ │ └── config.h │ ├── vs2017 │ │ ├── assimp_properties_debug.props │ │ ├── assimp_properties_debug64.props │ │ ├── assimp_properties_release.props │ │ └── assimp_properties_release64.props │ └── vs2019 │ │ ├── assimp_properties_debug.props │ │ ├── assimp_properties_debug64.props │ │ ├── assimp_properties_release.props │ │ └── assimp_properties_release64.props ├── freetype2-prebuilt │ ├── vs2017 │ │ ├── freetype2_properties.props │ │ └── freetype2_properties64.props │ └── vs2019 │ │ ├── freetype2_properties.props │ │ └── freetype2_properties64.props ├── glad │ ├── include │ │ ├── KHR │ │ │ └── khrplatform.h │ │ └── glad │ │ │ └── glad.h │ └── src │ │ └── glad.c └── glfw-prebuilt │ ├── vs2017 │ ├── glfw_properties.props │ ├── glfw_properties64.props │ ├── libs32 │ │ └── glfw3.lib │ └── libs64 │ │ └── glfw3.lib │ └── vs2019 │ ├── glfw_properties.props │ ├── glfw_properties64.props │ ├── libs32 │ └── glfw3.lib │ └── libs64 │ └── glfw3.lib ├── opengl4-tutorials-mbsoftworks-vs2019.sln ├── unix_setup.sh └── windows_setup.sh /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/glm"] 2 | path = dependencies/glm 3 | url = https://github.com/g-truc/glm.git 4 | ignore = dirty 5 | [submodule "dependencies/stb"] 6 | path = dependencies/stb 7 | url = https://github.com/nothings/stb.git 8 | [submodule "dependencies/freetype2"] 9 | path = dependencies/freetype2 10 | url = https://github.com/aseprite/freetype2.git 11 | [submodule "dependencies/assimp"] 12 | path = dependencies/assimp 13 | url = https://github.com/assimp/assimp.git 14 | [submodule "dependencies/glfw"] 15 | path = dependencies/glfw 16 | url = https://github.com/glfw/glfw.git 17 | -------------------------------------------------------------------------------- /001-creating-opengl4-window/001-creating-opengl4-window.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "001-creating-opengl4-window.h" 3 | 4 | namespace opengl4_mbsoftworks { 5 | namespace tutorial001 { 6 | 7 | void OpenGLWindow001::initializeScene() 8 | { 9 | glClearColor(0, 0.5f, 1.0f, 1.0f); 10 | } 11 | 12 | void OpenGLWindow001::renderScene() 13 | { 14 | glClear(GL_COLOR_BUFFER_BIT); 15 | } 16 | 17 | void OpenGLWindow001::updateScene() 18 | { 19 | if (keyPressedOnce(GLFW_KEY_ESCAPE)) { 20 | closeWindow(); 21 | } 22 | } 23 | 24 | } // namespace tutorial001 25 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /001-creating-opengl4-window/001-creating-opengl4-window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial001 { 8 | 9 | class OpenGLWindow001 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | }; 16 | 17 | } // namespace tutorial001 18 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /001-creating-opengl4-window/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "001-creating-opengl4-window.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "001.) Creating OpenGL4 Window - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial001::OpenGLWindow001 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /002-first-shader/002-first-shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial002 { 8 | 9 | class OpenGLWindow002 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial002 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /002-first-shader/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "002-first-shader.h" 6 | 7 | /** 8 | Application entry point function. 9 | Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "002.) First Shader - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial002::OpenGLWindow002 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /003-adding-colors/003-adding-colors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial003 { 8 | 9 | class OpenGLWindow003 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial003 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /003-adding-colors/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "003-adding-colors.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "003.) Adding Colors - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial003::OpenGLWindow003 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /004-entering-third-dimension/004-entering-third-dimension.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial004 { 8 | 9 | class OpenGLWindow004 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial004 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /004-entering-third-dimension/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "004-entering-third-dimension.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "004.) Entering Third Dimension - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial004::OpenGLWindow004 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /005-camera-pt1-simple-walking-camera/005-camera-pt1-simple-walking-camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial005 { 8 | 9 | class OpenGLWindow005 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial005 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /005-camera-pt1-simple-walking-camera/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "005-camera-pt1-simple-walking-camera.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "005.) Camera pt. 1 - Simple Walking Camera - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial005::OpenGLWindow005 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /006-camera-pt2-flying-camera/006-camera-pt2-flying-camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial006 { 8 | 9 | class OpenGLWindow006 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial006 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /006-camera-pt2-flying-camera/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "006-camera-pt2-flying-camera.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "006.) Camera pt. 2 - Flying Camera - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial006::OpenGLWindow006 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /007-textures-pt1-single-texture/007-textures-pt1-single-texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial007 { 8 | 9 | class OpenGLWindow007 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial007 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /007-textures-pt1-single-texture/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "007-textures-pt1-single-texture.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "007.) Textures pt. 1 - Single Texture - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial007::OpenGLWindow007 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /008-textures-pt2-multitexturing/008-textures-pt2-multitexturing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial008 { 8 | 9 | class OpenGLWindow008 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial008 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /008-textures-pt2-multitexturing/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "008-textures-pt2-multitexturing.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "008.) Textures pt. 2 - Multitexturing - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial008::OpenGLWindow008 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /009-orthographic-2D-projection/009-orthographic-2D-projection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial009 { 8 | 9 | class OpenGLWindow009 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial009 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /009-orthographic-2D-projection/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "009-orthographic-2D-projection.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "009.) Orthographic 2D Projection - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial009::OpenGLWindow009 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /010-first-great-refactoring/010-first-great-refactoring.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial010 { 8 | 9 | class OpenGLWindow010 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial010 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /010-first-great-refactoring/HUD010.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // STL 4 | #include 5 | 6 | // Project 7 | #include "../common_classes/OpenGLWindow.h" 8 | #include "../common_classes/HUDBase.h" 9 | #include "../common_classes/texture.h" 10 | 11 | /** 12 | * HUD for tutorial 010. 13 | */ 14 | class HUD010 : public HUDBase 15 | { 16 | public: 17 | const static std::string CHRISTMAS_TREE_TEXTURE_KEY; 18 | const static std::string SNOWFLAKE_TREE_TEXTURE_KEY; 19 | 20 | HUD010(const OpenGLWindow& window); 21 | 22 | /** 23 | * Checks, if blending in HUD is enabled. 24 | */ 25 | bool isBlendingEnabled() const; 26 | 27 | /** 28 | * Toggles blending. 29 | */ 30 | void toggleBlending(); 31 | 32 | /** 33 | * Renders HUD. 34 | */ 35 | void renderHUD() const override; 36 | 37 | private: 38 | bool _blendingEnabled = true; // Flag telling, if blending is enabled 39 | 40 | /** 41 | * Gets Christmas tree texture. 42 | */ 43 | const Texture& getChristmasTreeTexture() const; 44 | 45 | /** 46 | * Gets snowlake texture. 47 | */ 48 | const Texture& getSnowflakeTexture() const; 49 | }; 50 | -------------------------------------------------------------------------------- /010-first-great-refactoring/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "010-first-great-refactoring.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "010.) First Great Refactoring - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial010::OpenGLWindow010 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /011-indexed-rendering-torus/011-indexed-rendering-torus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial011 { 8 | 9 | class OpenGLWindow011 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial011 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /011-indexed-rendering-torus/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "011-indexed-rendering-torus.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "011.) Indexed Rendering of Torus - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial011::OpenGLWindow011 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /012-freetype-fonts-pt1/012-freetype-fonts-pt1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial012 { 8 | 9 | class OpenGLWindow012 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial012 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /012-freetype-fonts-pt1/HUD012.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD012.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial012 { 9 | 10 | HUD012::HUD012(const OpenGLWindow& window) 11 | : HUD(window) 12 | { 13 | static std::once_flag prepareOnceFlag; 14 | std::call_once(prepareOnceFlag, []() 15 | { 16 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 17 | }); 18 | } 19 | 20 | void HUD012::renderHUD() const 21 | { 22 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 23 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 24 | 25 | printBuilder() 26 | .fromRight() 27 | .fromBottom() 28 | .print(10, 10, "www.mbsoftworks.sk"); 29 | } 30 | 31 | } // namespace tutorial012 32 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /012-freetype-fonts-pt1/HUD012.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial012 { 9 | 10 | /** 11 | * HUD for tutorial 012. 12 | */ 13 | class HUD012 : public HUD 14 | { 15 | public: 16 | HUD012(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override; 22 | }; 23 | 24 | } // namespace tutorial012 25 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /012-freetype-fonts-pt1/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "012-freetype-fonts-pt1.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "012.) FreeType Fonts pt. 1 - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial012::OpenGLWindow012 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /013-blending-pt1/013-blending-pt1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial013 { 8 | 9 | class OpenGLWindow013 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial013 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /013-blending-pt1/HUD013.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD013.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial013 { 9 | 10 | HUD013::HUD013(const OpenGLWindow& window) 11 | : HUD(window) 12 | { 13 | static std::once_flag prepareOnceFlag; 14 | std::call_once(prepareOnceFlag, []() 15 | { 16 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 17 | }); 18 | } 19 | 20 | void HUD013::renderHUD(bool turnDepthMaskOff) const 21 | { 22 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 23 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 24 | printBuilder().print(10, 70, "Turn depth mask off? {} (Press F4 to toggle)", turnDepthMaskOff ? "Yes" : "No"); 25 | 26 | printBuilder() 27 | .fromRight() 28 | .fromBottom() 29 | .print(10, 10, "www.mbsoftworks.sk"); 30 | } 31 | 32 | } // namespace tutorial013 33 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /013-blending-pt1/HUD013.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial013 { 9 | 10 | /** 11 | * HUD for tutorial 013. 12 | */ 13 | class HUD013 : public HUD 14 | { 15 | public: 16 | HUD013(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(bool turnDepthMaskOff) const; 23 | }; 24 | 25 | } // namespace tutorial013 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /013-blending-pt1/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "013-blending-pt1.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "013.) Blending pt. 1 - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial013::OpenGLWindow013 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /014-normals-diffuse-lighting/014-normals-diffuse-lighting.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial014 { 8 | 9 | class OpenGLWindow014 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial014 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /014-normals-diffuse-lighting/HUD014.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/ambientLight.h" 8 | #include "../common_classes/shader_structs/diffuseLight.h" 9 | 10 | namespace opengl4_mbsoftworks { 11 | namespace tutorial014 { 12 | 13 | /** 14 | * HUD for tutorial 014. 15 | */ 16 | class HUD014 : public HUD 17 | { 18 | public: 19 | HUD014(const OpenGLWindow& window); 20 | 21 | /** 22 | * Renders HUD. 23 | */ 24 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 25 | void renderHUD(const shader_structs::AmbientLight& ambientLight, const shader_structs::DiffuseLight& diffuseLight) const; 26 | }; 27 | 28 | } // namespace tutorial014 29 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /014-normals-diffuse-lighting/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "014-normals-diffuse-lighting.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "014.) Normals and Diffuse Lighting - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial014::OpenGLWindow014 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /015-geometry-shaders/015-geometry-shaders.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial015 { 8 | 9 | class OpenGLWindow015 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial015 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /015-geometry-shaders/HUD015.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/ambientLight.h" 8 | #include "../common_classes/shader_structs/diffuseLight.h" 9 | 10 | namespace opengl4_mbsoftworks { 11 | namespace tutorial015 { 12 | 13 | /** 14 | * HUD for tutorial 015 (geometry shaders). 15 | */ 16 | class HUD015 : public HUD 17 | { 18 | public: 19 | HUD015(const OpenGLWindow& window); 20 | 21 | /** 22 | * Renders HUD. 23 | */ 24 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 25 | void renderHUD(const shader_structs::AmbientLight& ambientLight, const shader_structs::DiffuseLight& diffuseLight, const bool displayNormals, const float normalLength) const; 26 | }; 27 | 28 | } // namespace tutorial015 29 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /015-geometry-shaders/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "015-geometry-shaders.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "015.) Geometry Shaders - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial015::OpenGLWindow015 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /016-heightmap-pt1-random-terrain/016-heightmap-pt1-random-terrain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial016 { 8 | 9 | class OpenGLWindow016 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial016 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /016-heightmap-pt1-random-terrain/HUD016.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD016.h" 6 | 7 | #include "../common_classes/ostreamUtils.h" 8 | 9 | using namespace ostream_utils; 10 | 11 | namespace opengl4_mbsoftworks { 12 | namespace tutorial016 { 13 | 14 | HUD016::HUD016(const OpenGLWindow& window) 15 | : HUD(window) 16 | { 17 | static std::once_flag prepareOnceFlag; 18 | std::call_once(prepareOnceFlag, []() 19 | { 20 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 21 | }); 22 | } 23 | 24 | void HUD016::renderHUD(const bool displayNormals) const 25 | { 26 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 27 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 28 | 29 | // Print information about displaying normals 30 | printBuilder().print(10, 70, "Display Normals: {} (Press 'N' to toggle)", displayNormals ? "On" : "Off"); 31 | printBuilder().print(10, 100, "Press 'R' to generate new random heightmap"); 32 | 33 | printBuilder() 34 | .fromRight() 35 | .fromBottom() 36 | .print(10, 10, "www.mbsoftworks.sk"); 37 | } 38 | 39 | } // namespace tutorial016 40 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /016-heightmap-pt1-random-terrain/HUD016.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial016 { 9 | 10 | /** 11 | * HUD for tutorial 016 (heightmap pt.1 - random terrain). 12 | */ 13 | class HUD016 : public HUD 14 | { 15 | public: 16 | HUD016(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(const bool displayNormals) const; 23 | }; 24 | 25 | } // namespace tutorial016 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /016-heightmap-pt1-random-terrain/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "016-heightmap-pt1-random-terrain.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "016.) Heightmap Pt.1 - Random Terrain - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial016::OpenGLWindow016 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /017-heightmap-pt2-from-image-and-skybox/017-heightmap-pt2-from-image-and-skybox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial017 { 8 | 9 | class OpenGLWindow017 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial017 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /017-heightmap-pt2-from-image-and-skybox/HUD017.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD017.h" 6 | 7 | #include "../common_classes/ostreamUtils.h" 8 | 9 | using namespace ostream_utils; 10 | 11 | namespace opengl4_mbsoftworks { 12 | namespace tutorial017 { 13 | 14 | HUD017::HUD017(const OpenGLWindow& window) 15 | : HUD(window) 16 | { 17 | static std::once_flag prepareOnceFlag; 18 | std::call_once(prepareOnceFlag, []() 19 | { 20 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 21 | }); 22 | } 23 | 24 | void HUD017::renderHUD(const bool displayNormals) const 25 | { 26 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 27 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 28 | 29 | // Print information about displaying normals 30 | printBuilder().print(10, 70, "Display Normals: {} (Press 'N' to toggle)", displayNormals ? "On" : "Off"); 31 | 32 | printBuilder() 33 | .fromRight() 34 | .fromBottom() 35 | .print(10, 10, "www.mbsoftworks.sk"); 36 | } 37 | 38 | } // namespace tutorial017 39 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /017-heightmap-pt2-from-image-and-skybox/HUD017.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial017 { 9 | 10 | /** 11 | * HUD for tutorial 017 (heightmap pt.8 - terrain from image and skybox). 12 | */ 13 | class HUD017 : public HUD 14 | { 15 | public: 16 | HUD017(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(const bool displayNormals) const; 23 | }; 24 | 25 | } // namespace tutorial017 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /017-heightmap-pt2-from-image-and-skybox/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "017-heightmap-pt2-from-image-and-skybox.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "017.) Heightmap Pt.2 - From Image and Skybox - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial017::OpenGLWindow017 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /018-heightmap-pt3-multiple-layers/018-heightmap-pt3-multiple-layers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial018 { 8 | 9 | class OpenGLWindow018 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial018 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /018-heightmap-pt3-multiple-layers/HUD018.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD018.h" 6 | 7 | #include "../common_classes/ostreamUtils.h" 8 | 9 | using namespace ostream_utils; 10 | 11 | namespace opengl4_mbsoftworks { 12 | namespace tutorial018 { 13 | 14 | HUD018::HUD018(const OpenGLWindow& window) 15 | : HUD(window) 16 | { 17 | static std::once_flag prepareOnceFlag; 18 | std::call_once(prepareOnceFlag, []() 19 | { 20 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 21 | }); 22 | } 23 | 24 | void HUD018::renderHUD(const bool displayNormals) const 25 | { 26 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 27 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 28 | 29 | // Print information about displaying normals 30 | printBuilder().print(10, 70, "Display Normals: {} (Press 'N' to toggle)", displayNormals ? "On" : "Off"); 31 | 32 | printBuilder() 33 | .fromRight() 34 | .fromBottom() 35 | .print(10, 10, "www.mbsoftworks.sk"); 36 | } 37 | 38 | } // namespace tutorial018 39 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /018-heightmap-pt3-multiple-layers/HUD018.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial018 { 9 | 10 | /** 11 | * HUD for tutorial 018 (heightmap pt.1 - random terrain). 12 | */ 13 | class HUD018 : public HUD 14 | { 15 | public: 16 | HUD018(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(bool displayNormals) const; 23 | }; 24 | 25 | } // namespace tutorial018 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /018-heightmap-pt3-multiple-layers/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "018-heightmap-pt3-multiple-layers.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "018.) Heightmap Pt.3 - Multiple Layers - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial018::OpenGLWindow018 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /019-assimp-model-loading/019-assimp-model-loading.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial019 { 8 | 9 | class OpenGLWindow019 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial019 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /019-assimp-model-loading/HUD019.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD019.h" 6 | 7 | #include "../common_classes/ostreamUtils.h" 8 | 9 | using namespace ostream_utils; 10 | 11 | namespace opengl4_mbsoftworks { 12 | namespace tutorial019 { 13 | 14 | HUD019::HUD019(const OpenGLWindow& window) 15 | : HUD(window) 16 | { 17 | static std::once_flag prepareOnceFlag; 18 | std::call_once(prepareOnceFlag, []() 19 | { 20 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 21 | }); 22 | } 23 | 24 | void HUD019::renderHUD(const bool displayNormals) const 25 | { 26 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 27 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 28 | 29 | // Print information about displaying normals 30 | printBuilder().print(10, 70, "Display Normals: {} (Press 'N' to toggle)", displayNormals ? "On" : "Off"); 31 | 32 | printBuilder() 33 | .fromRight() 34 | .fromBottom() 35 | .print(10, 10, "www.mbsoftworks.sk"); 36 | } 37 | 38 | } // namespace tutorial019 39 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /019-assimp-model-loading/HUD019.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial019 { 9 | 10 | /** 11 | * HUD for tutorial 019 (assimp model loading). 12 | */ 13 | class HUD019 : public HUD 14 | { 15 | public: 16 | HUD019(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(const bool displayNormals) const; 23 | }; 24 | 25 | } // namespace tutorial019 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /019-assimp-model-loading/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "019-assimp-model-loading.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "019.) Assimp Model Loading - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial019::OpenGLWindow019 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /020-fog/020-fog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial020 { 8 | 9 | class OpenGLWindow020 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial020 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /020-fog/HUD020.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/fogParameters.h" 8 | 9 | namespace opengl4_mbsoftworks { 10 | namespace tutorial020 { 11 | 12 | /** 13 | * HUD for tutorial 020 (fog). 14 | */ 15 | class HUD020 : public HUD 16 | { 17 | public: 18 | HUD020(const OpenGLWindow& window); 19 | 20 | /** \brief Renders HUD. */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(const shader_structs::FogParameters& fogParameters) const; 23 | }; 24 | 25 | } // namespace tutorial020 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /020-fog/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "020-fog.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "020.) Fog - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial020::OpenGLWindow020 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /021-specular-highlight/021-specular-highlight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial021 { 8 | 9 | class OpenGLWindow021 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial021 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /021-specular-highlight/HUD021.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/material.h" 8 | 9 | namespace opengl4_mbsoftworks { 10 | namespace tutorial021 { 11 | 12 | /** 13 | * HUD for tutorial 021 (specular highlight). 14 | */ 15 | class HUD021 : public HUD 16 | { 17 | public: 18 | HUD021(const OpenGLWindow& window); 19 | 20 | /** 21 | * Renders HUD. 22 | */ 23 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 24 | void renderHUD(const shader_structs::Material& material, const glm::vec3& diffuseLightDirection) const; 25 | }; 26 | 27 | } // namespace tutorial021 28 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /021-specular-highlight/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "021-specular-highlight.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "021.) Specular Highlight - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial021::OpenGLWindow021 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /022-cylinder-and-sphere/022-cylinder-and-sphere.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial022 { 8 | 9 | class OpenGLWindow022 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial022 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /022-cylinder-and-sphere/HUD022.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial022 { 9 | 10 | /** 11 | * HUD for tutorial 022 (cylinder and sphere). 12 | */ 13 | class HUD022 : public HUD 14 | { 15 | public: 16 | HUD022(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(const glm::vec3& diffuseLightDirection, bool displayNormals, bool updateSpaceEntities, int sphereSlices, int sphereStacks) const; 23 | }; 24 | 25 | } // namespace tutorial022 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /022-cylinder-and-sphere/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "022-cylinder-and-sphere.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "022.) Cylinder And Sphere - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial022::OpenGLWindow022 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /023-point-lights/023-point-lights.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial023 { 8 | 9 | class OpenGLWindow023 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial023 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /023-point-lights/HUD023.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/ambientLight.h" 8 | #include "../common_classes/shader_structs/pointLight.h" 9 | 10 | namespace opengl4_mbsoftworks { 11 | namespace tutorial023 { 12 | 13 | /** 14 | * HUD for tutorial 023 (point lights). 15 | */ 16 | class HUD023 : public HUD 17 | { 18 | public: 19 | HUD023(const OpenGLWindow& window); 20 | 21 | /** 22 | * Renders HUD. 23 | */ 24 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 25 | void renderHUD(const shader_structs::AmbientLight& ambientLight, const shader_structs::PointLight& pointLight) const; 26 | }; 27 | 28 | } // namespace tutorial023 29 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /023-point-lights/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "023-point-lights.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "023.) Point Lights - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial023::OpenGLWindow023 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /024-uniform-buffer-object/024-uniform-buffer-object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial024 { 8 | 9 | class OpenGLWindow024 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial024 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /024-uniform-buffer-object/HUD024.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/ambientLight.h" 8 | #include "../common_classes/shader_structs/pointLight.h" 9 | 10 | namespace opengl4_mbsoftworks { 11 | namespace tutorial024 { 12 | 13 | /** 14 | * HUD for tutorial 024 (uniform buffer object). 15 | */ 16 | class HUD024 : public HUD 17 | { 18 | public: 19 | HUD024(const OpenGLWindow& window); 20 | 21 | /** 22 | * Renders HUD. 23 | */ 24 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 25 | void renderHUD(const shader_structs::AmbientLight& ambientLight, const shader_structs::PointLight& pointLight, const int numPointLights) const; 26 | }; 27 | 28 | } // namespace tutorial024 29 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /024-uniform-buffer-object/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "024-uniform-buffer-object.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "024.) Uniform Buffer Object - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial024::OpenGLWindow024 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /025-transform-feedback-particle-system/025-transform-feedback-particle-system.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial025 { 8 | 9 | class OpenGLWindow025 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial025 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /025-transform-feedback-particle-system/HUD025.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/shader_structs/ambientLight.h" 8 | 9 | namespace opengl4_mbsoftworks { 10 | namespace tutorial025 { 11 | 12 | /** 13 | * HUD for tutorial 025 (transform feedback particle system). 14 | */ 15 | class HUD025 : public HUD 16 | { 17 | public: 18 | HUD025(const OpenGLWindow& window, const shader_structs::AmbientLight& ambientLight); 19 | 20 | /** 21 | * Renders HUD. 22 | */ 23 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 24 | void renderHUD(int numFireParticlesOnScene, int numSnowParticlesOnScene, bool isFogEnabled, bool isFireDragged) const; 25 | 26 | private: 27 | const shader_structs::AmbientLight& ambientLight_; 28 | }; 29 | 30 | } // namespace tutorial025 31 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /025-transform-feedback-particle-system/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "025-transform-feedback-particle-system.h" 6 | 7 | /** 8 | * Application entry point function. 9 | * Uses MessageBox function on Windows systems to ask about fullscreen mode and console query on Unix systems. 10 | */ 11 | int main() 12 | { 13 | const std::string& windowTitle = "025.) Transform Feedback Particle System - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 14 | constexpr auto majorVersion = 4; 15 | constexpr auto minorVersion = 4; 16 | 17 | #ifdef _WIN32 18 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 19 | #else 20 | char answer; 21 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 22 | std::cin >> answer; 23 | const auto showFullscreen = tolower(answer) == 'y'; 24 | #endif 25 | 26 | opengl4_mbsoftworks::tutorial025::OpenGLWindow025 window; 27 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 28 | { 29 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 30 | return 1; 31 | } 32 | 33 | window.runApp(); 34 | 35 | if (window.hasErrorOccurred()) 36 | { 37 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 38 | std::cin.get(); 39 | return 1; 40 | } 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /025-transform-feedback-particle-system/snowCoveredPlainGround.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/static_meshes_3D/plainGround.h" 5 | #include "../common_classes/shader_structs/ambientLight.h" 6 | #include "../common_classes/shader_structs/diffuseLight.h" 7 | #include "../common_classes/shader_structs/pointLight.h" 8 | #include "../common_classes/shader_structs/fogParameters.h" 9 | 10 | namespace static_meshes_3D { 11 | 12 | /** 13 | * Plain ground static mesh covered with snow and pavement. 14 | */ 15 | class SnowCoveredPlainGround : public PlainGround 16 | { 17 | public: 18 | SnowCoveredPlainGround(const shader_structs::AmbientLight& ambientLight, const shader_structs::DiffuseLight& diffuseLight, const shader_structs::PointLight& firePointLight, const shader_structs::FogParameters& fogParameters, 19 | bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 20 | 21 | void render() const override; 22 | 23 | private: 24 | const shader_structs::AmbientLight& ambientLight_; 25 | const shader_structs::DiffuseLight& diffuseLight_; 26 | const shader_structs::PointLight& firePointLight_; 27 | const shader_structs::FogParameters& fogParameters_; 28 | }; 29 | 30 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /026-camera-pt3-orbit-camera/026-camera-pt3-orbit-camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial026 { 8 | 9 | class OpenGLWindow026 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | void onMouseWheelScroll(double scrollOffsetX, double scrollOffsetY) override; 17 | }; 18 | 19 | } // namespace tutorial026 20 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /026-camera-pt3-orbit-camera/HUD026.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | #include "../common_classes/orbitCamera.h" 8 | 9 | namespace opengl4_mbsoftworks { 10 | namespace tutorial026 { 11 | 12 | /** 13 | * HUD for tutorial 026 (orbit camera). 14 | */ 15 | class HUD026 : public HUD 16 | { 17 | public: 18 | HUD026(const OpenGLWindow& window); 19 | 20 | /** 21 | * Renders HUD. 22 | */ 23 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 24 | void renderHUD(const OrbitCamera& orbitCamera, bool isWireframeModeOn) const; 25 | }; 26 | 27 | } // namespace tutorial026 28 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /026-camera-pt3-orbit-camera/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "026-camera-pt3-orbit-camera.h" 6 | 7 | /** 8 | * Application entry point function. 9 | */ 10 | int main() 11 | { 12 | const std::string& windowTitle = "026.) Camera pt.3 - Orbit Camera - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 13 | constexpr auto majorVersion = 4; 14 | constexpr auto minorVersion = 4; 15 | 16 | #ifdef _WIN32 17 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 18 | #else 19 | char answer; 20 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 21 | std::cin >> answer; 22 | const auto showFullscreen = tolower(answer) == 'y'; 23 | #endif 24 | 25 | opengl4_mbsoftworks::tutorial026::OpenGLWindow026 window; 26 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 27 | { 28 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 29 | return 1; 30 | } 31 | 32 | window.runApp(); 33 | 34 | if (window.hasErrorOccurred()) 35 | { 36 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 37 | std::cin.get(); 38 | return 1; 39 | } 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /027-occlusion-query/027-occlusion-query.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial027 { 8 | 9 | class OpenGLWindow027 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial027 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /027-occlusion-query/HUD027.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial027 { 9 | 10 | /** 11 | * HUD for tutorial 027 (occlusion query). 12 | */ 13 | class HUD027 : public HUD 14 | { 15 | public: 16 | HUD027(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(size_t numObjects, size_t numVisibleObjects, bool isWireframeModeOn, bool visualizeOccluders) const; 23 | }; 24 | 25 | } // namespace tutorial027 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /027-occlusion-query/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "027-occlusion-query.h" 6 | 7 | /** 8 | * Application entry point function. 9 | */ 10 | int main() 11 | { 12 | const std::string& windowTitle = "027.) Occlusion Query - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 13 | constexpr auto majorVersion = 4; 14 | constexpr auto minorVersion = 4; 15 | 16 | #ifdef _WIN32 17 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 18 | #else 19 | char answer; 20 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 21 | std::cin >> answer; 22 | const auto showFullscreen = tolower(answer) == 'y'; 23 | #endif 24 | 25 | opengl4_mbsoftworks::tutorial027::OpenGLWindow027 window; 26 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 27 | { 28 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 29 | return 1; 30 | } 31 | 32 | window.runApp(); 33 | 34 | if (window.hasErrorOccurred()) 35 | { 36 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 37 | std::cin.get(); 38 | return 1; 39 | } 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /028-framebuffer-3D-color-picking/028-framebuffer-3D-color-picking.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial028 { 8 | 9 | class OpenGLWindow028 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | 17 | void onWindowSizeChanged(int width, int height) override; 18 | void onMouseButtonPressed(int button, int action) override; 19 | }; 20 | 21 | } // namespace tutorial028 22 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /028-framebuffer-3D-color-picking/HUD028.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial028 { 9 | 10 | /** 11 | * HUD for tutorial 028 (framebuffer 3D color picking). 12 | */ 13 | class HUD028 : public HUD 14 | { 15 | public: 16 | HUD028(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(bool isPixelPerfectSelectionMode, bool visualizeColorFrameBuffer, const std::string& selectedObjectDescription, bool updateCamera) const; 23 | }; 24 | 25 | } // namespace tutorial028 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /028-framebuffer-3D-color-picking/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "028-framebuffer-3D-color-picking.h" 6 | 7 | /** 8 | * Application entry point function. 9 | */ 10 | int main() 11 | { 12 | const std::string& windowTitle = "028.) Framebuffer 3D Color Picking - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 13 | constexpr auto majorVersion = 4; 14 | constexpr auto minorVersion = 4; 15 | 16 | #ifdef _WIN32 17 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 18 | #else 19 | char answer; 20 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 21 | std::cin >> answer; 22 | const auto showFullscreen = tolower(answer) == 'y'; 23 | #endif 24 | 25 | opengl4_mbsoftworks::tutorial028::OpenGLWindow028 window; 26 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 27 | { 28 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 29 | return 1; 30 | } 31 | 32 | window.runApp(); 33 | 34 | if (window.hasErrorOccurred()) 35 | { 36 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 37 | std::cin.get(); 38 | return 1; 39 | } 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /028-framebuffer-3D-color-picking/world.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // STL 4 | #include 5 | 6 | // Project 7 | #include "../common_classes/shaderProgram.h" 8 | #include "../common_classes/static_meshes_3D/primitives/cube.h" 9 | #include "../common_classes/static_meshes_3D/plainGround.h" 10 | 11 | namespace opengl4_mbsoftworks { 12 | namespace tutorial028 { 13 | 14 | class World 15 | { 16 | public: 17 | static World& getInstance(); 18 | 19 | /** 20 | * Initializes everything in this class. 21 | */ 22 | void initialize(); 23 | 24 | /** 25 | * Releases everything created in this class. 26 | */ 27 | void release(); 28 | 29 | /** 30 | * Renders ground. 31 | * 32 | * @param shaderProgram Shader program to render ground with 33 | */ 34 | void renderGround(ShaderProgram& shaderProgram) const; 35 | 36 | /** 37 | * Renders crates maze. 38 | * 39 | * @param shaderProgram Shader program to render crates maze with 40 | */ 41 | void renderCratesMaze(ShaderProgram& shaderProgram) const; 42 | 43 | private: 44 | World() = default; // Private constructor to make class truly singleton 45 | World(const World&) = delete; // No copy constructor allowed 46 | void operator=(const World&) = delete; // No copy assignment allowed 47 | 48 | std::unique_ptr plainGround_; // Plain ground used to render ground 49 | std::unique_ptr cube_; // Cube used to render crates maze 50 | }; 51 | 52 | } // namespace tutorial028 53 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /029-framebuffer-rendering-to-a-texture/029-framebuffer-rendering-to-a-texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial029 { 8 | 9 | class OpenGLWindow029 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial029 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /029-framebuffer-rendering-to-a-texture/HUD029.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "HUD029.h" 6 | 7 | #include "../common_classes/ostreamUtils.h" 8 | 9 | using namespace ostream_utils; 10 | 11 | namespace opengl4_mbsoftworks { 12 | namespace tutorial029 { 13 | 14 | HUD029::HUD029(const OpenGLWindow& window) 15 | : HUD(window) 16 | { 17 | static std::once_flag prepareOnceFlag; 18 | std::call_once(prepareOnceFlag, []() 19 | { 20 | FreeTypeFontManager::getInstance().loadSystemFreeTypeFont(DEFAULT_FONT_KEY, "arial.ttf", 24); 21 | }); 22 | } 23 | 24 | void HUD029::renderHUD(GLsizei currentTextureSize) const 25 | { 26 | printBuilder().print(10, 10, "FPS: {}", _window.getFPS()); 27 | printBuilder().print(10, 40, "Vertical Synchronization: {} (Press F3 to toggle)", _window.isVerticalSynchronizationEnabled() ? "On" : "Off"); 28 | 29 | // Print information about 3D color picking 30 | printBuilder().print(10, 100, "Current texture size: {}x{} (Press '+' and '-' to change)", currentTextureSize, currentTextureSize); 31 | printBuilder().print(10, 130, "Press 'X' to re-shuffle meshes on screens"); 32 | printBuilder().print(10, 160, "Press 'C' to re-shuffle textures on screens"); 33 | 34 | printBuilder() 35 | .fromRight() 36 | .fromBottom() 37 | .print(10, 10, "www.mbsoftworks.sk"); 38 | } 39 | 40 | } // namespace tutorial029 41 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /029-framebuffer-rendering-to-a-texture/HUD029.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial029 { 9 | 10 | /** 11 | * HUD for tutorial 029 (framebuffer rendering to a texture). 12 | */ 13 | class HUD029 : public HUD 14 | { 15 | public: 16 | HUD029(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override {} // Don't need this, but had to override, so that class is not abstract 22 | void renderHUD(GLsizei currentTextureSize) const; 23 | }; 24 | 25 | } // namespace tutorial029 26 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /029-framebuffer-rendering-to-a-texture/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "029-framebuffer-rendering-to-a-texture.h" 6 | 7 | /** 8 | * Application entry point function. 9 | */ 10 | int main() 11 | { 12 | const std::string& windowTitle = "029.) Framebuffer Rendering to a Texture - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 13 | constexpr auto majorVersion = 4; 14 | constexpr auto minorVersion = 4; 15 | 16 | #ifdef _WIN32 17 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 18 | #else 19 | char answer; 20 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 21 | std::cin >> answer; 22 | const auto showFullscreen = tolower(answer) == 'y'; 23 | #endif 24 | 25 | opengl4_mbsoftworks::tutorial029::OpenGLWindow029 window; 26 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 27 | { 28 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 29 | return 1; 30 | } 31 | 32 | window.runApp(); 33 | 34 | if (window.hasErrorOccurred()) 35 | { 36 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 37 | std::cin.get(); 38 | return 1; 39 | } 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /030-animation-pt1-keyframe-md2/030-animation-pt1-keyframe-md2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | 6 | namespace opengl4_mbsoftworks { 7 | namespace tutorial030 { 8 | 9 | class OpenGLWindow030 : public OpenGLWindow 10 | { 11 | public: 12 | void initializeScene() override; 13 | void renderScene() override; 14 | void updateScene() override; 15 | void releaseScene() override; 16 | }; 17 | 18 | } // namespace tutorial 030 19 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /030-animation-pt1-keyframe-md2/HUD030.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../common_classes/OpenGLWindow.h" 5 | #include "../common_classes/HUD.h" 6 | 7 | namespace opengl4_mbsoftworks { 8 | namespace tutorial030 { 9 | 10 | /** 11 | * HUD for tutorial 030 (Animation Part 1 Keyframe MD2). 12 | */ 13 | class HUD030 : public HUD 14 | { 15 | public: 16 | HUD030(const OpenGLWindow& window); 17 | 18 | /** 19 | * Renders HUD. 20 | */ 21 | void renderHUD() const override; 22 | }; 23 | 24 | } // namespace tutorial030 25 | } // namespace opengl4_mbsoftworks -------------------------------------------------------------------------------- /030-animation-pt1-keyframe-md2/main.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "030-animation-pt1-keyframe-md2.h" 6 | 7 | /** 8 | * Application entry point function. 9 | */ 10 | int main() 11 | { 12 | const std::string& windowTitle = "030.) Animation pt.1 - Keyframe MD2 - Tutorial by Michal Bubnar (www.mbsoftworks.sk)"; 13 | constexpr auto majorVersion = 4; 14 | constexpr auto minorVersion = 4; 15 | 16 | #ifdef _WIN32 17 | const auto showFullscreen = MessageBox(nullptr, "Would you like to run in fullscreen mode?", "Fullscreen", MB_ICONQUESTION | MB_YESNO) == IDYES; 18 | #else 19 | char answer; 20 | std::cout << "Would you like to run in fullscreen mode? (y/n): "; 21 | std::cin >> answer; 22 | const auto showFullscreen = tolower(answer) == 'y'; 23 | #endif 24 | 25 | opengl4_mbsoftworks::tutorial030::OpenGLWindow030 window; 26 | if (!window.createOpenGLWindow(windowTitle, majorVersion, minorVersion, showFullscreen)) 27 | { 28 | std::cout << "Failed to create window with OpenGL context " << majorVersion << "." << minorVersion << "! Shutting down..." << std::endl; 29 | return 1; 30 | } 31 | 32 | window.runApp(); 33 | 34 | if (window.hasErrorOccurred()) 35 | { 36 | std::cout << std::endl << std::endl << "Program could not start because of the above errors! Press ENTER to quit..." << std::endl; 37 | std::cin.get(); 38 | return 1; 39 | } 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Michal Bubnár 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/data/heightmaps/tut017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/heightmaps/tut017.png -------------------------------------------------------------------------------- /bin/data/heightmaps/tut018.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/heightmaps/tut018.png -------------------------------------------------------------------------------- /bin/data/heightmaps/tut019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/heightmaps/tut019.png -------------------------------------------------------------------------------- /bin/data/models/animated/md2/blade/blade.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/animated/md2/blade/blade.jpg -------------------------------------------------------------------------------- /bin/data/models/animated/md2/blade/blade.md2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/animated/md2/blade/blade.md2 -------------------------------------------------------------------------------- /bin/data/models/animated/md2/samourai/samourai.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/animated/md2/samourai/samourai.jpg -------------------------------------------------------------------------------- /bin/data/models/animated/md2/samourai/samourai.md2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/animated/md2/samourai/samourai.md2 -------------------------------------------------------------------------------- /bin/data/models/animated/md2/warrior/Readme.txt: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // 3 | // Copyright (C) 2004-2011 by W. Sitters 4 | // 5 | // This model is free software, and has an double licence. 6 | // You can redistribute it and/or modify it under the terms of the 7 | // GNU General Public License as published by the Free Software Foundation, 8 | // either version 2 of the License, or any later version, 9 | // or you can redistribut it and/or modify it under the terms of 10 | // creative commons license CC-Attribution/by (http://creativecommons.org/licenses/by/3.0/). 11 | // 12 | // 13 | // This model is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | // You can choose your own licence ( GNU or CC-attribution/by ) for redistribute and/or modify, 17 | // but give credit to the orginal autor ( w. sitters ). 18 | // 19 | // 20 | // You should have received a copy of the GNU General Public License and CC_attribution licence 21 | // along with the model ; if not, write to the Free Software 22 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 23 | // 02111-1307, USA or go to the website http://creativecommons.org/licenses/by/3.0/. 24 | // 25 | // 26 | // 27 | // 28 | // DESCRIPTION: 3D model's' and textures 29 | // 30 | //----------------------------------------------------------------------------- 31 | -------------------------------------------------------------------------------- /bin/data/models/animated/md2/warrior/warrior.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/animated/md2/warrior/warrior.jpg -------------------------------------------------------------------------------- /bin/data/models/animated/md2/warrior/warrior.md2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/animated/md2/warrior/warrior.md2 -------------------------------------------------------------------------------- /bin/data/models/house/house.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/house/house.3ds -------------------------------------------------------------------------------- /bin/data/models/house/house.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/house/house.jpg -------------------------------------------------------------------------------- /bin/data/models/medieval_house/medieval_house_diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/medieval_house/medieval_house_diff.png -------------------------------------------------------------------------------- /bin/data/models/medieval_house/medieval_house_normals.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/medieval_house/medieval_house_normals.png -------------------------------------------------------------------------------- /bin/data/models/medieval_house/medieval_house_spec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/medieval_house/medieval_house_spec.png -------------------------------------------------------------------------------- /bin/data/models/scheune_3ds/scheune.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/scheune_3ds/scheune.3ds -------------------------------------------------------------------------------- /bin/data/models/scheune_3ds/scheune2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/scheune_3ds/scheune2.jpg -------------------------------------------------------------------------------- /bin/data/models/scheune_3ds/stroh1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/scheune_3ds/stroh1.jpg -------------------------------------------------------------------------------- /bin/data/models/scheune_3ds/wood.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/models/scheune_3ds/wood.jpg -------------------------------------------------------------------------------- /bin/data/shaders/fog/fog.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include_part 4 | 5 | struct FogParameters 6 | { 7 | vec3 color; // Color to be used with fog, usually grayish 8 | float linearStart; // This is where linear fog starts (valid for linear equation only) 9 | float linearEnd; // This is where linear fog ends (valid for linear equation only) 10 | float density; // Density of the fog, used by exp and exp2 equation 11 | 12 | int equation; // Used fog equation, 3 options are valid - 0 = linear, 1 = exp, 2 = exp2 13 | bool isEnabled; // Flag telling if fog is enabled or not 14 | }; 15 | 16 | float getFogFactor(FogParameters params, float fogCoordinate); 17 | 18 | #definition_part 19 | 20 | float getFogFactor(FogParameters params, float fogCoordinate) 21 | { 22 | float result = 0.0; 23 | if(params.equation == 0) 24 | { 25 | float fogLength = params.linearEnd - params.linearStart; 26 | result = (params.linearEnd - fogCoordinate) / fogLength; 27 | } 28 | else if(params.equation == 1) { 29 | result = exp(-params.density * fogCoordinate); 30 | } 31 | else if(params.equation == 2) { 32 | result = exp(-pow(params.density * fogCoordinate, 2.0)); 33 | } 34 | 35 | result = 1.0 - clamp(result, 0.0, 1.0); 36 | return result; 37 | } -------------------------------------------------------------------------------- /bin/data/shaders/heightmap/multilayer.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | smooth out float ioHeight; 18 | 19 | void main() 20 | { 21 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.viewMatrix * matrices.modelMatrix; 22 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 23 | 24 | ioVertexTexCoord = vertexTexCoord; 25 | ioVertexNormal = matrices.normalMatrix*vertexNormal; 26 | ioHeight = vertexPosition.y; 27 | } -------------------------------------------------------------------------------- /bin/data/shaders/heightmap/multilayer_fog.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | smooth out float ioHeight; 18 | smooth out vec4 ioEyeSpacePosition; 19 | 20 | void main() 21 | { 22 | mat4 mvMatrix = matrices.viewMatrix * matrices.modelMatrix; 23 | mat4 mvpMatrix = matrices.projectionMatrix * mvMatrix; 24 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 25 | 26 | ioVertexTexCoord = vertexTexCoord; 27 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 28 | ioHeight = vertexPosition.y; 29 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 30 | } -------------------------------------------------------------------------------- /bin/data/shaders/lighting/ambientLight.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include_part 4 | 5 | struct AmbientLight 6 | { 7 | vec3 color; 8 | bool isOn; 9 | }; 10 | 11 | vec3 getAmbientLightColor(AmbientLight ambientLight); 12 | 13 | #definition_part 14 | 15 | vec3 getAmbientLightColor(AmbientLight ambientLight) 16 | { 17 | return ambientLight.isOn ? ambientLight.color : vec3(0.0, 0.0, 0.0); 18 | } -------------------------------------------------------------------------------- /bin/data/shaders/lighting/diffuseLight.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include_part 4 | 5 | struct DiffuseLight 6 | { 7 | vec3 color; 8 | vec3 direction; 9 | float factor; 10 | bool isOn; 11 | }; 12 | 13 | vec3 getDiffuseLightColor(DiffuseLight diffuseLight, vec3 normal); 14 | 15 | #definition_part 16 | 17 | vec3 getDiffuseLightColor(DiffuseLight diffuseLight, vec3 normal) 18 | { 19 | if(!diffuseLight.isOn) { 20 | return vec3(0.0, 0.0, 0.0); 21 | } 22 | 23 | float finalIntensity = max(0.0, dot(normal, -diffuseLight.direction)); 24 | finalIntensity = clamp(finalIntensity*diffuseLight.factor, 0.0, 1.0); 25 | return vec3(diffuseLight.color*finalIntensity); 26 | } -------------------------------------------------------------------------------- /bin/data/shaders/lighting/pointLight.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include_part 4 | 5 | struct PointLight 6 | { 7 | vec3 position; 8 | vec3 color; 9 | 10 | float ambientFactor; 11 | 12 | float constantAttenuation; 13 | float linearAttenuation; 14 | float exponentialAttenuation; 15 | 16 | bool isOn; 17 | }; 18 | 19 | vec3 getPointLightColor(const PointLight pointLight, const vec3 worldPosition, const vec3 normal); 20 | 21 | #definition_part 22 | 23 | vec3 getPointLightColor(const PointLight pointLight, const vec3 worldPosition, const vec3 normal) 24 | { 25 | if(!pointLight.isOn) { 26 | return vec3(0.0); 27 | } 28 | 29 | vec3 positionToLightVector = worldPosition - pointLight.position; 30 | float distance = length(positionToLightVector); 31 | positionToLightVector = normalize(positionToLightVector); 32 | 33 | float diffuseFactor = max(0.0, dot(normal, -positionToLightVector)); 34 | float totalAttenuation = pointLight.constantAttenuation 35 | + pointLight.linearAttenuation * distance 36 | + pointLight.exponentialAttenuation * pow(distance, 2.0); 37 | 38 | return pointLight.color * (pointLight.ambientFactor + diffuseFactor) / totalAttenuation; 39 | } -------------------------------------------------------------------------------- /bin/data/shaders/lighting/specularHighlight.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "diffuseLight.frag" 4 | 5 | #include_part 6 | 7 | struct Material 8 | { 9 | bool isEnabled; 10 | float specularIntensity; 11 | float specularPower; 12 | }; 13 | 14 | vec3 getSpecularHighlightColor(vec3 worldPosition, vec3 normal, vec3 eyePosition, Material material, DiffuseLight diffuseLight); 15 | 16 | #definition_part 17 | 18 | vec3 getSpecularHighlightColor(vec3 worldPosition, vec3 normal, vec3 eyePosition, Material material, DiffuseLight diffuseLight) 19 | { 20 | if(!material.isEnabled) { 21 | return vec3(0.0); 22 | } 23 | 24 | vec3 reflectedVector = normalize(reflect(diffuseLight.direction, normal)); 25 | vec3 worldToEyeVector = normalize(eyePosition - worldPosition); 26 | float specularFactor = dot(worldToEyeVector, reflectedVector); 27 | 28 | if (specularFactor > 0) 29 | { 30 | specularFactor = pow(specularFactor, material.specularPower); 31 | return diffuseLight.color * material.specularIntensity * specularFactor; 32 | } 33 | 34 | return vec3(0.0); 35 | } -------------------------------------------------------------------------------- /bin/data/shaders/normals/normals.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | out vec4 outputColor; 4 | 5 | void main() 6 | { 7 | outputColor = vec4(1.0, 1.0, 1.0, 1.0); 8 | } -------------------------------------------------------------------------------- /bin/data/shaders/normals/normals.geom: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(points) in; 12 | layout(line_strip, max_vertices = 2) out; 13 | 14 | in vec3 ioVertexPosition[]; 15 | in vec3 ioVertexNormal[]; 16 | 17 | uniform float normalLength; 18 | 19 | void main() 20 | { 21 | mat4 mpMatrix = matrices.projectionMatrix * matrices.viewMatrix; 22 | vec4 firstNormalPoint = matrices.modelMatrix*vec4(ioVertexPosition[0], 1.0); 23 | gl_Position = mpMatrix * firstNormalPoint; 24 | EmitVertex(); 25 | 26 | vec3 transformedNormal = normalize(matrices.normalMatrix*ioVertexNormal[0]); 27 | vec3 normalWithLength = transformedNormal * normalLength; 28 | 29 | vec4 secondNormalPoint = firstNormalPoint + vec4(normalWithLength, 0.0); 30 | gl_Position = mpMatrix*secondNormalPoint; 31 | EmitVertex(); 32 | 33 | EndPrimitive(); 34 | } -------------------------------------------------------------------------------- /bin/data/shaders/normals/normals.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout (location = 0) in vec3 vertexPosition; 4 | layout (location = 2) in vec3 vertexNormal; 5 | 6 | out vec3 ioVertexPosition; 7 | out vec3 ioVertexNormal; 8 | 9 | void main() 10 | { 11 | ioVertexPosition = vertexPosition; 12 | ioVertexNormal = vertexNormal; 13 | } -------------------------------------------------------------------------------- /bin/data/shaders/single-color/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | uniform vec4 color; 6 | 7 | void main() 8 | { 9 | outputColor = color; 10 | } -------------------------------------------------------------------------------- /bin/data/shaders/single-color/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | } matrices; 9 | 10 | layout(location = 0) in vec3 vertexPosition; 11 | 12 | void main() 13 | { 14 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.viewMatrix * matrices.modelMatrix; 15 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 16 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut002/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | void main() 6 | { 7 | outputColor = vec4(1.0, 1.0, 1.0, 1.0); 8 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut002/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) in vec3 vertexPosition; 4 | 5 | void main() 6 | { 7 | gl_Position = vec4(vertexPosition, 1.0); 8 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut003/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | smooth in vec3 ioVertexColor; 6 | 7 | void main() 8 | { 9 | outputColor = vec4(ioVertexColor, 1.0); 10 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut003/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) in vec3 vertexPosition; 4 | layout(location = 1) in vec3 vertexColor; 5 | 6 | smooth out vec3 ioVertexColor; 7 | 8 | void main() 9 | { 10 | gl_Position = vec4(vertexPosition, 1.0); 11 | ioVertexColor = vertexColor; 12 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut004/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | smooth in vec3 ioVertexColor; 6 | 7 | void main() 8 | { 9 | outputColor = vec4(ioVertexColor, 1.0); 10 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut004/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | } matrices; 9 | 10 | layout(location = 0) in vec3 vertexPosition; 11 | layout(location = 1) in vec3 vertexColor; 12 | 13 | smooth out vec3 ioVertexColor; 14 | 15 | void main() 16 | { 17 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.viewMatrix * matrices.modelMatrix; 18 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 19 | ioVertexColor = vertexColor; 20 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut007/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | smooth in vec2 ioVertexTexCoord; 6 | 7 | uniform sampler2D sampler; 8 | uniform vec4 color; 9 | 10 | void main() 11 | { 12 | vec4 texColor = texture(sampler, ioVertexTexCoord); 13 | outputColor = texColor*color; 14 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut007/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | } matrices; 9 | 10 | layout(location = 0) in vec3 vertexPosition; 11 | layout(location = 1) in vec2 vertexTexCoord; 12 | 13 | smooth out vec2 ioVertexTexCoord; 14 | 15 | void main() 16 | { 17 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.viewMatrix * matrices.modelMatrix; 18 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 19 | ioVertexTexCoord = vertexTexCoord; 20 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut008/ground_shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | smooth in vec2 ioVertexTexCoord; 6 | 7 | uniform sampler2D snowSampler; 8 | uniform sampler2D pathSampler; 9 | uniform sampler2D pavementSampler; 10 | 11 | void main() 12 | { 13 | vec4 snowTexel = texture(snowSampler, ioVertexTexCoord); 14 | vec4 pathTexel = texture(pathSampler, ioVertexTexCoord / 20.0f); 15 | vec4 pavementTexel = texture(pavementSampler, ioVertexTexCoord); 16 | float pathWeight = pathTexel.r; 17 | float snowWeight = 1.0-pathWeight; 18 | outputColor = pavementTexel*pathWeight + snowTexel*snowWeight; 19 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut008/ground_shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | } matrices; 9 | 10 | layout(location = 0) in vec3 vertexPosition; 11 | layout(location = 1) in vec2 vertexTexCoord; 12 | 13 | smooth out vec2 ioVertexTexCoord; 14 | 15 | void main() 16 | { 17 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.viewMatrix * matrices.modelMatrix; 18 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 19 | ioVertexTexCoord = vertexTexCoord; 20 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut009/ortho2D.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | smooth in vec2 ioVertexTexCoord; 6 | 7 | uniform sampler2D sampler; 8 | uniform vec4 color; 9 | 10 | void main() 11 | { 12 | vec4 texel = texture(sampler, ioVertexTexCoord); 13 | if(texel.a == 0.0) 14 | discard; 15 | outputColor = texel*color; 16 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut009/ortho2D.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 modelMatrix; 7 | } matrices; 8 | 9 | layout(location = 0) in vec2 vertexPosition; 10 | layout(location = 1) in vec2 vertexTexCoord; 11 | 12 | smooth out vec2 ioVertexTexCoord; 13 | 14 | void main() 15 | { 16 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.modelMatrix; 17 | gl_Position = mvpMatrix * vec4(vertexPosition, 0.0, 1.0); 18 | ioVertexTexCoord = vertexTexCoord; 19 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut012/font2D.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(location = 0) out vec4 outputColor; 4 | 5 | smooth in vec2 ioVertexTexCoord; 6 | 7 | uniform sampler2D sampler; 8 | uniform vec4 color; 9 | 10 | void main() 11 | { 12 | vec4 texel = texture(sampler, ioVertexTexCoord); 13 | texel = vec4(texel.r, texel.r, texel.r, texel.r); 14 | if(texel.a == 0.0) { 15 | discard; 16 | } 17 | outputColor = texel*color; 18 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut012/font2D.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 modelMatrix; 7 | } matrices; 8 | 9 | layout(location = 0) in vec2 vertexPosition; 10 | layout(location = 1) in vec2 vertexTexCoord; 11 | 12 | smooth out vec2 ioVertexTexCoord; 13 | 14 | void main() 15 | { 16 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.modelMatrix; 17 | gl_Position = mvpMatrix * vec4(vertexPosition, 0.0, 1.0); 18 | ioVertexTexCoord = vertexTexCoord; 19 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut014-diffuse-lighting/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../lighting/ambientLight.frag" 4 | #include "../lighting/diffuseLight.frag" 5 | 6 | layout(location = 0) out vec4 outputColor; 7 | 8 | smooth in vec2 ioVertexTexCoord; 9 | smooth in vec3 ioVertexNormal; 10 | 11 | uniform sampler2D sampler; 12 | uniform vec4 color; 13 | 14 | uniform AmbientLight ambientLight; 15 | uniform DiffuseLight diffuseLight; 16 | 17 | void main() 18 | { 19 | vec3 normal = normalize(ioVertexNormal); 20 | vec4 textureColor = texture(sampler, ioVertexTexCoord); 21 | vec4 objectColor = textureColor*color; 22 | vec3 lightColor = getAmbientLightColor(ambientLight) + getDiffuseLightColor(diffuseLight, normal); 23 | 24 | outputColor = objectColor*vec4(lightColor, 1.0); 25 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut014-diffuse-lighting/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | 18 | void main() 19 | { 20 | mat4 mvpMatrix = matrices.projectionMatrix * matrices.viewMatrix * matrices.modelMatrix; 21 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 22 | ioVertexTexCoord = vertexTexCoord; 23 | ioVertexNormal = matrices.normalMatrix*vertexNormal; 24 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut020-fog/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../lighting/ambientLight.frag" 4 | #include "../lighting/diffuseLight.frag" 5 | #include "../fog/fog.frag" 6 | 7 | layout(location = 0) out vec4 outputColor; 8 | 9 | smooth in vec2 ioVertexTexCoord; 10 | smooth in vec3 ioVertexNormal; 11 | smooth in vec4 ioEyeSpacePosition; 12 | 13 | uniform sampler2D sampler; 14 | uniform vec4 color; 15 | 16 | uniform AmbientLight ambientLight; 17 | uniform DiffuseLight diffuseLight; 18 | uniform FogParameters fogParams; 19 | 20 | void main() 21 | { 22 | vec3 normal = normalize(ioVertexNormal); 23 | vec4 textureColor = texture(sampler, ioVertexTexCoord); 24 | vec4 objectColor = textureColor*color; 25 | vec3 lightColor = getAmbientLightColor(ambientLight) + getDiffuseLightColor(diffuseLight, normal); 26 | 27 | outputColor = objectColor*vec4(lightColor, 1.0); 28 | 29 | // Apply fog calculation only if fog is enabled 30 | if(fogParams.isEnabled) 31 | { 32 | float fogCoordinate = abs(ioEyeSpacePosition.z / ioEyeSpacePosition.w); 33 | outputColor = mix(outputColor, vec4(fogParams.color, 1.0), getFogFactor(fogParams, fogCoordinate)); 34 | } 35 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut020-fog/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | smooth out vec4 ioEyeSpacePosition; 18 | 19 | void main() 20 | { 21 | mat4 mvMatrix = matrices.viewMatrix * matrices.modelMatrix; 22 | mat4 mvpMatrix = matrices.projectionMatrix * mvMatrix; 23 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 24 | 25 | // Output all out variables 26 | ioVertexTexCoord = vertexTexCoord; 27 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 28 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 29 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut021-specular-highlight/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../lighting/ambientLight.frag" 4 | #include "../lighting/diffuseLight.frag" 5 | #include "../lighting/specularHighlight.frag" 6 | 7 | layout(location = 0) out vec4 outputColor; 8 | 9 | smooth in vec2 ioVertexTexCoord; 10 | smooth in vec3 ioVertexNormal; 11 | smooth in vec4 ioWorldPosition; 12 | smooth in vec4 ioEyeSpacePosition; 13 | 14 | uniform sampler2D sampler; 15 | uniform vec4 color; 16 | 17 | uniform AmbientLight ambientLight; 18 | uniform DiffuseLight diffuseLight; 19 | uniform Material material; 20 | uniform vec3 eyePosition; 21 | 22 | void main() 23 | { 24 | vec3 normal = normalize(ioVertexNormal); 25 | vec4 textureColor = texture(sampler, ioVertexTexCoord); 26 | vec4 objectColor = textureColor*color; 27 | vec3 ambientColor = getAmbientLightColor(ambientLight); 28 | vec3 diffuseColor = getDiffuseLightColor(diffuseLight, normal); 29 | vec3 specularHighlightColor = getSpecularHighlightColor(ioWorldPosition.xyz, normal, eyePosition, material, diffuseLight); 30 | vec3 lightColor = ambientColor + diffuseColor + specularHighlightColor; 31 | 32 | outputColor = objectColor * vec4(lightColor, 1.0); 33 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut021-specular-highlight/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | smooth out vec4 ioWorldPosition; 18 | smooth out vec4 ioEyeSpacePosition; 19 | 20 | void main() 21 | { 22 | mat4 mvMatrix = matrices.viewMatrix * matrices.modelMatrix; 23 | mat4 mvpMatrix = matrices.projectionMatrix * mvMatrix; 24 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 25 | 26 | // Output all out variables 27 | ioVertexTexCoord = vertexTexCoord; 28 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 29 | ioWorldPosition = matrices.modelMatrix * vec4(vertexPosition, 1.0); 30 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 31 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut023-point-lights/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../lighting/ambientLight.frag" 4 | #include "../lighting/diffuseLight.frag" 5 | #include "../lighting/specularHighlight.frag" 6 | #include "../lighting/pointLight.frag" 7 | 8 | layout(location = 0) out vec4 outputColor; 9 | 10 | smooth in vec2 ioVertexTexCoord; 11 | smooth in vec3 ioVertexNormal; 12 | smooth in vec4 ioWorldPosition; 13 | smooth in vec4 ioEyeSpacePosition; 14 | 15 | uniform sampler2D sampler; 16 | uniform vec4 color; 17 | 18 | uniform AmbientLight ambientLight; 19 | uniform DiffuseLight diffuseLight; 20 | uniform Material material; 21 | uniform PointLight pointLightA; 22 | uniform PointLight pointLightB; 23 | uniform vec3 eyePosition; 24 | 25 | void main() 26 | { 27 | vec3 normal = normalize(ioVertexNormal); 28 | vec4 textureColor = texture(sampler, ioVertexTexCoord); 29 | vec4 objectColor = textureColor*color; 30 | vec3 ambientColor = getAmbientLightColor(ambientLight); 31 | vec3 diffuseColor = getDiffuseLightColor(diffuseLight, normal); 32 | vec3 specularHighlightColor = getSpecularHighlightColor(ioWorldPosition.xyz, normal, eyePosition, material, diffuseLight); 33 | vec3 pointLightColorA = getPointLightColor(pointLightA, ioWorldPosition.xyz, normal); 34 | vec3 pointLightColorB = getPointLightColor(pointLightB, ioWorldPosition.xyz, normal); 35 | vec3 lightColor = ambientColor + diffuseColor + specularHighlightColor + pointLightColorA + pointLightColorB; 36 | 37 | outputColor = objectColor * vec4(lightColor, 1.0); 38 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut023-point-lights/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | smooth out vec4 ioWorldPosition; 18 | smooth out vec4 ioEyeSpacePosition; 19 | 20 | void main() 21 | { 22 | mat4 mvMatrix = matrices.viewMatrix * matrices.modelMatrix; 23 | mat4 mvpMatrix = matrices.projectionMatrix * mvMatrix; 24 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 25 | 26 | // Output all out variables 27 | ioVertexTexCoord = vertexTexCoord; 28 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 29 | ioWorldPosition = matrices.modelMatrix * vec4(vertexPosition, 1.0); 30 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 31 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut024-ubos/multilayer_heightmap.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(std140, binding = 0) uniform MatricesBlock 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | } block_matrices; 8 | 9 | uniform struct 10 | { 11 | mat4 modelMatrix; 12 | mat3 normalMatrix; 13 | } matrices; 14 | 15 | layout(location = 0) in vec3 vertexPosition; 16 | layout(location = 1) in vec2 vertexTexCoord; 17 | layout(location = 2) in vec3 vertexNormal; 18 | 19 | smooth out vec2 ioVertexTexCoord; 20 | smooth out vec3 ioVertexNormal; 21 | smooth out vec4 ioWorldPosition; 22 | smooth out float ioHeight; 23 | 24 | void main() 25 | { 26 | mat4 mvpMatrix = block_matrices.projectionMatrix * block_matrices.viewMatrix * matrices.modelMatrix; 27 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 28 | 29 | ioVertexTexCoord = vertexTexCoord; 30 | ioVertexNormal = matrices.normalMatrix*vertexNormal; 31 | ioHeight = vertexPosition.y; 32 | ioWorldPosition = matrices.modelMatrix * vec4(vertexPosition, 1.0); 33 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut024-ubos/shader.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../lighting/ambientLight.frag" 4 | #include "../lighting/diffuseLight.frag" 5 | #include "../lighting/specularHighlight.frag" 6 | #include "../lighting/pointLight.frag" 7 | 8 | layout(location = 0) out vec4 outputColor; 9 | 10 | smooth in vec2 ioVertexTexCoord; 11 | smooth in vec3 ioVertexNormal; 12 | smooth in vec4 ioWorldPosition; 13 | smooth in vec4 ioEyeSpacePosition; 14 | 15 | uniform sampler2D sampler; 16 | uniform vec4 color; 17 | 18 | uniform AmbientLight ambientLight; 19 | uniform DiffuseLight diffuseLight; 20 | uniform Material material; 21 | uniform vec3 eyePosition; 22 | 23 | uniform int numPointLights; 24 | layout(std140, binding = 1) uniform PointLightsBlock 25 | { 26 | PointLight lights[20]; 27 | } block_pointLights; 28 | 29 | void main() 30 | { 31 | vec3 normal = normalize(ioVertexNormal); 32 | vec4 textureColor = texture(sampler, ioVertexTexCoord); 33 | vec4 objectColor = textureColor*color; 34 | vec3 ambientColor = getAmbientLightColor(ambientLight); 35 | vec3 diffuseColor = getDiffuseLightColor(diffuseLight, normal); 36 | vec3 specularHighlightColor = getSpecularHighlightColor(ioWorldPosition.xyz, normal, eyePosition, material, diffuseLight); 37 | vec3 lightColor = ambientColor + diffuseColor + specularHighlightColor; 38 | for(int i = 0; i < numPointLights; i++) { 39 | lightColor += getPointLightColor(block_pointLights.lights[i], ioWorldPosition.xyz, normal); 40 | } 41 | 42 | outputColor = objectColor * vec4(lightColor, 1.0); 43 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut024-ubos/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(std140, binding = 0) uniform MatricesBlock 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | } block_matrices; 8 | 9 | uniform struct 10 | { 11 | mat4 modelMatrix; 12 | mat3 normalMatrix; 13 | } matrices; 14 | 15 | layout(location = 0) in vec3 vertexPosition; 16 | layout(location = 1) in vec2 vertexTexCoord; 17 | layout(location = 2) in vec3 vertexNormal; 18 | 19 | smooth out vec2 ioVertexTexCoord; 20 | smooth out vec3 ioVertexNormal; 21 | smooth out vec4 ioWorldPosition; 22 | smooth out vec4 ioEyeSpacePosition; 23 | 24 | void main() 25 | { 26 | mat4 mvMatrix = block_matrices.viewMatrix * matrices.modelMatrix; 27 | mat4 mvpMatrix = block_matrices.projectionMatrix * mvMatrix; 28 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 29 | 30 | // Output all out variables 31 | ioVertexTexCoord = vertexTexCoord; 32 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 33 | ioWorldPosition = matrices.modelMatrix * vec4(vertexPosition, 1.0); 34 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 35 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/fire_render.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../fog/fog.frag" 4 | 5 | smooth in vec2 ioTexCoord; 6 | smooth in vec4 ioEyeSpacePosition; 7 | flat in vec4 ioColor; 8 | 9 | uniform sampler2D sampler; 10 | uniform FogParameters fogParams; 11 | 12 | out vec4 outputColor; 13 | 14 | void main() 15 | { 16 | vec4 textureColor = texture(sampler, ioTexCoord); 17 | vec4 inputColor = ioColor; 18 | 19 | // If fog is enabled, mix input color with fog 20 | if(fogParams.isEnabled) 21 | { 22 | float fogCoordinate = abs(ioEyeSpacePosition.z / ioEyeSpacePosition.w); 23 | float fogFactor = getFogFactor(fogParams, fogCoordinate); 24 | inputColor = vec4(mix(ioColor.xyz, fogParams.color, fogFactor), ioColor.a * (1.0 - fogFactor)); 25 | } 26 | 27 | outputColor = vec4(textureColor.xyz, 1.0) * inputColor; 28 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/fire_render.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout (location = 1) in vec3 inPosition; 4 | layout (location = 3) in float inLifetime; 5 | layout (location = 4) in float inSize; 6 | 7 | out float ioLifetime; 8 | out float ioSize; 9 | 10 | void main() 11 | { 12 | gl_Position = vec4(inPosition, 1.0); 13 | ioLifetime = inLifetime; 14 | ioSize = inSize; 15 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/fire_update.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout (location = 0) in int inType; 4 | layout (location = 1) in vec3 inPosition; 5 | layout (location = 2) in vec3 inVelocity; 6 | layout (location = 3) in float inLifetime; 7 | layout (location = 4) in float inSize; 8 | 9 | out int ioType; 10 | out vec3 ioPosition; 11 | out vec3 ioVelocity; 12 | out float ioLifetime; 13 | out float ioSize; 14 | 15 | void main() 16 | { 17 | ioType = inType; 18 | ioPosition = inPosition; 19 | ioVelocity = inVelocity; 20 | ioLifetime = inLifetime; 21 | ioSize = inSize; 22 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/ground_shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout(location = 0) in vec3 vertexPosition; 12 | layout(location = 1) in vec2 vertexTexCoord; 13 | layout(location = 2) in vec3 vertexNormal; 14 | 15 | smooth out vec2 ioVertexTexCoord; 16 | smooth out vec3 ioVertexNormal; 17 | smooth out vec4 ioWorldPosition; 18 | smooth out vec4 ioEyeSpacePosition; 19 | 20 | void main() 21 | { 22 | mat4 mvMatrix = matrices.viewMatrix * matrices.modelMatrix; 23 | mat4 mvpMatrix = matrices.projectionMatrix * mvMatrix; 24 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 25 | ioVertexTexCoord = vertexTexCoord; 26 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 27 | ioWorldPosition = matrices.modelMatrix * vec4(vertexPosition, 1.0); 28 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 29 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/shader.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout(std140, binding = 0) uniform MatricesBlock 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | } block_matrices; 8 | 9 | uniform struct 10 | { 11 | mat4 modelMatrix; 12 | mat3 normalMatrix; 13 | } matrices; 14 | 15 | layout(location = 0) in vec3 vertexPosition; 16 | layout(location = 1) in vec2 vertexTexCoord; 17 | layout(location = 2) in vec3 vertexNormal; 18 | 19 | smooth out vec2 ioVertexTexCoord; 20 | smooth out vec3 ioVertexNormal; 21 | smooth out vec4 ioWorldPosition; 22 | smooth out vec4 ioEyeSpacePosition; 23 | 24 | void main() 25 | { 26 | mat4 mvMatrix = block_matrices.viewMatrix * matrices.modelMatrix; 27 | mat4 mvpMatrix = block_matrices.projectionMatrix * mvMatrix; 28 | gl_Position = mvpMatrix * vec4(vertexPosition, 1.0); 29 | 30 | // Output all out variables 31 | ioVertexTexCoord = vertexTexCoord; 32 | ioVertexNormal = matrices.normalMatrix * vertexNormal; 33 | ioWorldPosition = matrices.modelMatrix * vec4(vertexPosition, 1.0); 34 | ioEyeSpacePosition = mvMatrix * vec4(vertexPosition, 1.0); 35 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/snow_render.frag: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | #include "../fog/fog.frag" 4 | 5 | uniform sampler2D gSampler; 6 | uniform FogParameters fogParams; 7 | 8 | smooth in vec2 ioTexCoord; 9 | smooth in vec4 ioEyeSpacePosition; 10 | flat in vec4 ioColor; 11 | 12 | out vec4 outputColor; 13 | 14 | void main() 15 | { 16 | vec4 vTexColor = texture(gSampler, ioTexCoord); 17 | vec4 inputColor = ioColor; 18 | 19 | // If fog is enabled, mix input color with fog 20 | if(fogParams.isEnabled) 21 | { 22 | float fogCoordinate = abs(ioEyeSpacePosition.z / ioEyeSpacePosition.w); 23 | float fogFactor = getFogFactor(fogParams, fogCoordinate); 24 | inputColor = vec4(mix(ioColor.xyz, fogParams.color, fogFactor), ioColor.a * (1.0-fogFactor)); 25 | } 26 | 27 | outputColor = vec4(vTexColor.xyz, 1.0) * inputColor; 28 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/snow_render.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout (location = 1) in vec3 inPosition; 4 | layout (location = 2) in float inSize; 5 | layout (location = 3) in float inAlpha; 6 | layout (location = 4) in int inSnowflakeIndex; 7 | 8 | out float ioSize; 9 | out float ioAlpha; 10 | out int ioSnowflakeIndex; 11 | 12 | void main() 13 | { 14 | gl_Position = vec4(inPosition, 1.0); 15 | ioSize = inSize; 16 | ioAlpha = inAlpha; 17 | ioSnowflakeIndex = inSnowflakeIndex; 18 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut025-particle-system-tf/snow_update.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | layout (location = 0) in int inType; 4 | layout (location = 1) in vec3 inPosition; 5 | layout (location = 2) in float inSize; 6 | layout (location = 3) in float inAlpha; 7 | layout (location = 4) in int inSnowflakeIndex; 8 | 9 | out int ioType; 10 | out vec3 ioPosition; 11 | out float ioSize; 12 | out float ioAlpha; 13 | out int ioSnowflakeIndex; 14 | 15 | void main() 16 | { 17 | ioType = inType; 18 | ioPosition = inPosition; 19 | ioSize = inSize; 20 | ioAlpha = inAlpha; 21 | ioSnowflakeIndex = inSnowflakeIndex; 22 | } -------------------------------------------------------------------------------- /bin/data/shaders/tut030-animation-pt1-keyframe-md2/md2anim.vert: -------------------------------------------------------------------------------- 1 | #version 440 core 2 | 3 | uniform struct 4 | { 5 | mat4 projectionMatrix; 6 | mat4 viewMatrix; 7 | mat4 modelMatrix; 8 | mat3 normalMatrix; 9 | } matrices; 10 | 11 | layout (location = 0) in vec3 vertexPosition; 12 | layout (location = 1) in vec2 vertexTexCoord; 13 | layout (location = 2) in vec3 vertexNormal; 14 | layout (location = 3) in vec3 nextVertexPosition; 15 | layout (location = 4) in vec3 nextVertexNormal; 16 | 17 | smooth out vec2 ioVertexTexCoord; 18 | smooth out vec3 ioVertexNormal; 19 | smooth out vec4 ioWorldPosition; 20 | smooth out vec4 ioEyeSpacePosition; 21 | 22 | uniform float interpolationFactor; 23 | 24 | void main() 25 | { 26 | mat4 mvMatrix = matrices.viewMatrix * matrices.modelMatrix; 27 | mat4 mvpMatrix = matrices.projectionMatrix * mvMatrix; 28 | 29 | vec4 interpolatedPosition = vec4(vertexPosition + (nextVertexPosition - vertexPosition)*interpolationFactor, 1.0); 30 | vec3 interpolatedNormal = vertexNormal + (nextVertexNormal - vertexNormal)*interpolationFactor; 31 | gl_Position = mvpMatrix*interpolatedPosition; 32 | ioVertexTexCoord = vertexTexCoord; 33 | ioEyeSpacePosition = mvMatrix * interpolatedPosition; 34 | ioVertexNormal = matrices.normalMatrix * interpolatedNormal; 35 | ioWorldPosition = matrices.modelMatrix * interpolatedPosition; 36 | } -------------------------------------------------------------------------------- /bin/data/skyboxes/desert/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/desert/back.png -------------------------------------------------------------------------------- /bin/data/skyboxes/desert/front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/desert/front.png -------------------------------------------------------------------------------- /bin/data/skyboxes/desert/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/desert/left.png -------------------------------------------------------------------------------- /bin/data/skyboxes/desert/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/desert/right.png -------------------------------------------------------------------------------- /bin/data/skyboxes/desert/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/desert/top.png -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlake1/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlake1/back.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlake1/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlake1/bottom.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlake1/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlake1/front.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlake1/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlake1/left.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlake1/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlake1/right.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlake1/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlake1/top.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlands1/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlands1/back.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlands1/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlands1/bottom.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlands1/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlands1/front.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlands1/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlands1/left.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlands1/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlands1/right.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajlands1/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajlands1/top.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsnow1/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsnow1/back.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsnow1/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsnow1/bottom.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsnow1/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsnow1/front.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsnow1/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsnow1/left.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsnow1/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsnow1/right.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsnow1/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsnow1/top.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsundown1/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsundown1/back.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsundown1/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsundown1/bottom.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsundown1/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsundown1/front.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsundown1/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsundown1/left.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsundown1/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsundown1/right.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/jajsundown1/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/jajsundown1/top.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/README.txt: -------------------------------------------------------------------------------- 1 | All textures have been downloaded from this website: 2 | 3 | https://opengameart.org/content/space-skyboxes-0 4 | 5 | So all credits goes to the guys there :) According to what's written there, it's free for anything. 6 | 7 | I've also downsampled to 1024x1024 and converted to JPG to reduce file sizes. -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/space_lightblue/back.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/bottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/space_lightblue/bottom.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/space_lightblue/front.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/space_lightblue/left.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/space_lightblue/right.jpg -------------------------------------------------------------------------------- /bin/data/skyboxes/space_lightblue/top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/skyboxes/space_lightblue/top.jpg -------------------------------------------------------------------------------- /bin/data/textures/brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/brick.png -------------------------------------------------------------------------------- /bin/data/textures/clay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/clay.png -------------------------------------------------------------------------------- /bin/data/textures/cobblestone_mossy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/cobblestone_mossy.png -------------------------------------------------------------------------------- /bin/data/textures/crate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/crate.png -------------------------------------------------------------------------------- /bin/data/textures/diamond.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/diamond.png -------------------------------------------------------------------------------- /bin/data/textures/grass.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/grass.jpg -------------------------------------------------------------------------------- /bin/data/textures/ice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/ice.png -------------------------------------------------------------------------------- /bin/data/textures/metal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/metal.png -------------------------------------------------------------------------------- /bin/data/textures/particles/fire.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/particles/fire.bmp -------------------------------------------------------------------------------- /bin/data/textures/particles/snowflakes.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/particles/snowflakes.bmp -------------------------------------------------------------------------------- /bin/data/textures/pavement.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/pavement.jpg -------------------------------------------------------------------------------- /bin/data/textures/prismarine_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/prismarine_dark.png -------------------------------------------------------------------------------- /bin/data/textures/rocky_terrain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/rocky_terrain.jpg -------------------------------------------------------------------------------- /bin/data/textures/sand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/sand.png -------------------------------------------------------------------------------- /bin/data/textures/scifi_metal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/scifi_metal.jpg -------------------------------------------------------------------------------- /bin/data/textures/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/snow.png -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_earth_daymap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_earth_daymap.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_jupiter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_jupiter.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_mars.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_mars.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_mercury.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_mercury.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_neptune.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_neptune.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_saturn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_saturn.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_sun.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_sun.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_uranus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_uranus.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/2k_venus_surface.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/solar_system/2k_venus_surface.jpg -------------------------------------------------------------------------------- /bin/data/textures/solar_system/README.txt: -------------------------------------------------------------------------------- 1 | All textures have been downloaded from this website: 2 | 3 | https://www.solarsystemscope.com/textures/ 4 | 5 | So all credits goes to the guys there :) According to the licensing, it can be used, adapted and shared freely for any purpose. -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_linear_min_linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_linear_min_linear.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_linear_min_linear_mipmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_linear_min_linear_mipmap.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_linear_min_linear_mipmap_linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_linear_min_linear_mipmap_linear.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_linear_min_nearest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_linear_min_nearest.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_linear_min_nearest_mipmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_linear_min_nearest_mipmap.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_nearest_min_bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_nearest_min_bilinear.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_nearest_min_linear_mipmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_nearest_min_linear_mipmap.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_nearest_min_linear_mipmap_linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_nearest_min_linear_mipmap_linear.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_nearest_min_nearest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_nearest_min_nearest.png -------------------------------------------------------------------------------- /bin/data/textures/tut007/mag_nearest_min_nearest_mipmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut007/mag_nearest_min_nearest_mipmap.png -------------------------------------------------------------------------------- /bin/data/textures/tut008/house_texture_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut008/house_texture_front.png -------------------------------------------------------------------------------- /bin/data/textures/tut008/house_texture_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut008/house_texture_side.png -------------------------------------------------------------------------------- /bin/data/textures/tut008/path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut008/path.png -------------------------------------------------------------------------------- /bin/data/textures/tut009/christmas_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut009/christmas_tree.png -------------------------------------------------------------------------------- /bin/data/textures/tut009/snowflake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/tut009/snowflake.png -------------------------------------------------------------------------------- /bin/data/textures/white_marble.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/white_marble.jpg -------------------------------------------------------------------------------- /bin/data/textures/wood.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/bin/data/textures/wood.jpg -------------------------------------------------------------------------------- /common_classes/gldebug.h: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | namespace gldebug { 5 | 6 | inline void ClearOpenGLError() 7 | { 8 | GLenum err; 9 | while ((err = glGetError()) != GL_NO_ERROR) 10 | { 11 | std::cout << "Cleared OpenGL error " << std::hex << err << std::dec << std::endl; 12 | } 13 | } 14 | 15 | inline void CheckOpenGLError(const char* stmt, const char* fname, int line) 16 | { 17 | GLenum err = glGetError(); 18 | if (err == GL_NO_ERROR) { 19 | return; 20 | } 21 | std::cout << "OpenGL error " << std::hex << err << std::dec << " at " << fname << ":" << line << " - " << stmt << std::endl; 22 | } 23 | 24 | } // namespace gldebug 25 | 26 | #ifdef _DEBUG 27 | #define GL_CHECK(stmt) { \ 28 | gldebug::ClearOpenGLError(); \ 29 | stmt; \ 30 | gldebug::CheckOpenGLError(#stmt, __FILE__, __LINE__); \ 31 | } 32 | #else 33 | #define GL_CHECK(stmt) stmt 34 | #endif -------------------------------------------------------------------------------- /common_classes/matrixManager.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "matrixManager.h" 3 | 4 | MatrixManager& MatrixManager::getInstance() 5 | { 6 | static MatrixManager mm; 7 | return mm; 8 | } 9 | 10 | const glm::mat4& MatrixManager::getProjectionMatrix() const 11 | { 12 | return _projectionMatrix; 13 | } 14 | 15 | const glm::mat4& MatrixManager::getOrthoProjectionMatrix() const 16 | { 17 | return _orthoProjectionMatrix; 18 | } 19 | 20 | const glm::mat4& MatrixManager::getViewMatrix() const 21 | { 22 | return _viewMatrix; 23 | } 24 | 25 | void MatrixManager::setProjectionMatrix(const glm::mat4& projectionMatrix) 26 | { 27 | _projectionMatrix = projectionMatrix; 28 | } 29 | 30 | void MatrixManager::setOrthoProjectionMatrix(const glm::mat4& orthoProjectionMatrix) 31 | { 32 | _orthoProjectionMatrix = orthoProjectionMatrix; 33 | } 34 | 35 | void MatrixManager::setViewMatrix(const glm::mat4& viewMatrix) 36 | { 37 | _viewMatrix = viewMatrix; 38 | } 39 | -------------------------------------------------------------------------------- /common_classes/occlusionQuery.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "occlusionQuery.h" 6 | 7 | OcclusionQuery::OcclusionQuery() 8 | { 9 | glGenQueries(1, &queryID_); 10 | std::cout << "Created occlusion query with ID " << queryID_ << std::endl; 11 | } 12 | 13 | OcclusionQuery::~OcclusionQuery() 14 | { 15 | glDeleteQueries(1, &queryID_); 16 | std::cout << "Deleted occlusion query with ID " << queryID_ << std::endl; 17 | queryID_ = 0; 18 | } 19 | 20 | void OcclusionQuery::beginQuery() const 21 | { 22 | glBeginQuery(GL_SAMPLES_PASSED, queryID_); 23 | } 24 | 25 | void OcclusionQuery::endQuery() 26 | { 27 | glEndQuery(GL_SAMPLES_PASSED); 28 | glGetQueryObjectiv(queryID_, GL_QUERY_RESULT, &samplesPassed_); 29 | } 30 | 31 | GLint OcclusionQuery::getNumSamplesPassed() const 32 | { 33 | return samplesPassed_; 34 | } 35 | 36 | bool OcclusionQuery::anySamplesPassed() const 37 | { 38 | return samplesPassed_ > 0; 39 | } 40 | -------------------------------------------------------------------------------- /common_classes/occlusionQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // GLAD 4 | #include 5 | 6 | /** 7 | * Provides convenient access to occlusion query functionality. 8 | */ 9 | class OcclusionQuery 10 | { 11 | public: 12 | OcclusionQuery(); 13 | ~OcclusionQuery(); 14 | 15 | /** 16 | * Begins occlusion query. Until the query is ended, samples 17 | * that pass the rendering pipeline are counted. 18 | */ 19 | void beginQuery() const; 20 | 21 | /** 22 | * Ends occlusion query and caches the result - number 23 | * of samples that passed the rendering pipeline. 24 | */ 25 | void endQuery(); 26 | 27 | /** 28 | * Gets number of samples that have passed the rendering pipeline. 29 | */ 30 | GLint getNumSamplesPassed() const; 31 | 32 | /** 33 | * Helper method that returns if any samples have passed the rendering pipeline. 34 | */ 35 | bool anySamplesPassed() const; 36 | 37 | private: 38 | GLuint queryID_{ 0 }; // OpenGL query object ID 39 | GLint samplesPassed_{ 0 }; // Number of samples passed in last query 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /common_classes/ostreamUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // STL 4 | #include 5 | #include 6 | 7 | // GLM 8 | #include 9 | 10 | namespace ostream_utils { 11 | 12 | /** 13 | * Outputs glm::vec3 in the output stream. 14 | */ 15 | std::ostream &operator<<(std::ostream &o, const glm::vec3& vec3) 16 | { 17 | return o << std::setprecision(3) << "[" << vec3.x << ", " << vec3.y << ", " << vec3.z << "]"; 18 | } 19 | 20 | } // namespace ostream_utils -------------------------------------------------------------------------------- /common_classes/random.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "random.h" 3 | 4 | std::random_device Random::rd_; 5 | std::mt19937_64 Random::generator_{rd_()}; 6 | 7 | int Random::nextInt(int bound) 8 | { 9 | std::uniform_int_distribution distribution(0, bound - 1); 10 | return distribution(generator_); 11 | } 12 | 13 | glm::vec3 Random::getRandomVectorFromRectangleXZ(const glm::vec3& minPosition, const glm::vec3& maxPosition) 14 | { 15 | std::uniform_real_distribution distributionX(minPosition.x, maxPosition.x); 16 | std::uniform_real_distribution distributionZ(minPosition.z, maxPosition.z); 17 | 18 | return glm::vec3(distributionX(generator_), minPosition.y, distributionZ(generator_)); 19 | } 20 | -------------------------------------------------------------------------------- /common_classes/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // STL 4 | #include 5 | 6 | // GLM 7 | #include 8 | 9 | /** 10 | * Helper class that makes using C++11's random very convenient. 11 | */ 12 | class Random 13 | { 14 | public: 15 | /** 16 | * Gets random integer from range <0 ... bound-1>. 17 | * 18 | * @param bound Upper bound for randomly generated integer (not inclusive). 19 | */ 20 | static int nextInt(int bound); 21 | 22 | /** 23 | * Generates random vec3 at XZ plane. 24 | * 25 | * @param minPosition Minimal vertex position that can be generated 26 | * @param maxPosition Maximal vertex position that can be generated 27 | */ 28 | static glm::vec3 getRandomVectorFromRectangleXZ(const glm::vec3& minPosition, const glm::vec3& maxPosition); 29 | 30 | private: 31 | static std::random_device rd_; // STD random number generator for non-deterministic random numbers 32 | static std::mt19937_64 generator_; // 64-bit Mersenne Twister random number engine 33 | }; 34 | -------------------------------------------------------------------------------- /common_classes/samplerManager.cpp: -------------------------------------------------------------------------------- 1 | // STL 2 | #include 3 | 4 | // Project 5 | #include "samplerManager.h" 6 | 7 | SamplerManager& SamplerManager::getInstance() 8 | { 9 | static SamplerManager sm; 10 | return sm; 11 | } 12 | 13 | Sampler& SamplerManager::createSampler(const std::string& key, const MagnificationFilter magnificationFilter, const MinificationFilter minificationFilter) 14 | { 15 | if (containsSampler(key)) 16 | { 17 | const auto msg = "Sampler with key '" + key + "' already exists!"; 18 | throw std::runtime_error(msg.c_str()); 19 | } 20 | 21 | std::unique_ptr sampler = std::make_unique(); 22 | sampler->create(); 23 | sampler->bind(); 24 | sampler->setMagnificationFilter(magnificationFilter); 25 | sampler->setMinificationFilter(minificationFilter); 26 | _samplerCache[key] = std::move(sampler); 27 | 28 | return getSampler(key); 29 | } 30 | 31 | Sampler& SamplerManager::getSampler(const std::string& key) const 32 | { 33 | if (!containsSampler(key)) 34 | { 35 | const auto msg = "Attempting to get non-existing sampler with key '" + key + "'!"; 36 | throw std::runtime_error(msg.c_str()); 37 | } 38 | 39 | return *_samplerCache.at(key); 40 | } 41 | 42 | void SamplerManager::clearSamplerCache() 43 | { 44 | _samplerCache.clear(); 45 | } 46 | 47 | bool SamplerManager::containsSampler(const std::string & key) const 48 | { 49 | return _samplerCache.count(key) > 0; 50 | } 51 | -------------------------------------------------------------------------------- /common_classes/shader_structs/ambientLight.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "ambientLight.h" 3 | 4 | namespace shader_structs { 5 | 6 | AmbientLight::AmbientLight(const glm::vec3& color, const bool isOn) 7 | : color(color) 8 | , isOn(isOn) 9 | { 10 | } 11 | 12 | void AmbientLight::setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const 13 | { 14 | shaderProgram[constructAttributeName(uniformName, "color")] = color; 15 | shaderProgram[constructAttributeName(uniformName, "isOn")] = isOn; 16 | } 17 | 18 | glm::vec3 AmbientLight::getColorContribution() const 19 | { 20 | return isOn ? color : glm::vec3(0.0f); 21 | } 22 | 23 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/ambientLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "shaderStruct.h" 5 | 6 | namespace shader_structs { 7 | 8 | /** 9 | * Represents ambient light in a shader. 10 | */ 11 | struct AmbientLight : ShaderStruct 12 | { 13 | AmbientLight(const glm::vec3& color, const bool isOn = true); 14 | 15 | /** 16 | * Sets ambient light in a shader program. 17 | */ 18 | void setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const override; 19 | 20 | /** 21 | * Gets the final contributed color of this ambient light (depending if light is on or off). 22 | * The ambient light color contribution. 23 | */ 24 | glm::vec3 getColorContribution() const; 25 | 26 | glm::vec3 color; // Color of the ambient light 27 | bool isOn; // Flag telling, if the light is on 28 | }; 29 | 30 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/diffuseLight.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "diffuseLight.h" 3 | 4 | namespace shader_structs { 5 | 6 | DiffuseLight::DiffuseLight(const glm::vec3& color, const glm::vec3& direction, const float factor, const bool isOn) 7 | : color(color) 8 | , direction(direction) 9 | , factor(factor) 10 | , isOn(isOn) 11 | { 12 | } 13 | 14 | void DiffuseLight::setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const 15 | { 16 | shaderProgram[constructAttributeName(uniformName, "color")] = color; 17 | shaderProgram[constructAttributeName(uniformName, "direction")] = direction; 18 | shaderProgram[constructAttributeName(uniformName, "factor")] = factor; 19 | shaderProgram[constructAttributeName(uniformName, "isOn")] = isOn; 20 | } 21 | 22 | const DiffuseLight& DiffuseLight::none() 23 | { 24 | static DiffuseLight noneDiffuseLight(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 0.0f, false); 25 | return noneDiffuseLight; 26 | } 27 | 28 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/diffuseLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "shaderStruct.h" 5 | 6 | namespace shader_structs { 7 | 8 | /** 9 | * Represents diffuse light in a shader. 10 | */ 11 | struct DiffuseLight : ShaderStruct 12 | { 13 | DiffuseLight(const glm::vec3& color, const glm::vec3& direction, const float factor, const bool isOn = true); 14 | 15 | /** 16 | * Sets diffuse light in a shader program. 17 | */ 18 | void setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const override; 19 | 20 | /** 21 | * Returns a diffuse light that is off and does not contribute at all. 22 | */ 23 | static const DiffuseLight& none(); 24 | 25 | glm::vec3 color; // Color of the diffuse light 26 | glm::vec3 direction; // Direction of the diffuse light 27 | float factor; // Factor to multiply dot product with (strength of light) 28 | bool isOn; // Flag telling, if the light is on 29 | }; 30 | 31 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/material.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "material.h" 3 | 4 | namespace shader_structs { 5 | 6 | Material::Material(const float specularIntensity, const float specularPower, const bool isEnabled) 7 | : specularIntensity(specularIntensity) 8 | , specularPower(specularPower) 9 | , isEnabled(isEnabled) 10 | { 11 | } 12 | 13 | const Material& Material::none() 14 | { 15 | static Material noMaterial(0.0f, 0.0f, false); 16 | return noMaterial; 17 | } 18 | 19 | void Material::setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const 20 | { 21 | shaderProgram[constructAttributeName(uniformName, "isEnabled")] = isEnabled; 22 | if (!isEnabled) { 23 | return; // Skip settings other parameters if material is not enabled 24 | } 25 | 26 | shaderProgram[constructAttributeName(uniformName, "specularIntensity")] = specularIntensity; 27 | shaderProgram[constructAttributeName(uniformName, "specularPower")] = specularPower; 28 | } 29 | 30 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/material.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "shaderStruct.h" 5 | 6 | namespace shader_structs { 7 | 8 | /** 9 | * Represents material in a shader. 10 | */ 11 | struct Material : ShaderStruct 12 | { 13 | Material(const float specularIntensity, const float specularPower, const bool isEnabled = true); 14 | 15 | /** 16 | * Material that does no calculations (is not enabled). 17 | */ 18 | static const Material& none(); 19 | 20 | /** 21 | * Sets material structure in a shader program. 22 | * 23 | * @param shaderProgram Shader program to set material in 24 | * @param uniformName Name of the uniform variable 25 | */ 26 | void setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const override; 27 | 28 | bool isEnabled; // Flag telling if calculations with material are enabled 29 | float specularIntensity; // Factor to multiply specular highlight by 30 | float specularPower; // Number to raise calculated specular factor to 31 | }; 32 | 33 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/shaderStruct.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "shaderStruct.h" 3 | 4 | namespace shader_structs { 5 | 6 | std::string ShaderStruct::constructAttributeName(const std::string& uniformName, const std::string& attributeName) 7 | { 8 | return uniformName + "." + attributeName; 9 | } 10 | 11 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/shader_structs/shaderStruct.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../shaderProgram.h" 5 | 6 | namespace shader_structs { 7 | 8 | /** 9 | * Base class for uniform shader structures in shader program. 10 | */ 11 | struct ShaderStruct 12 | { 13 | public: 14 | /** 15 | * Sets this shader structure as uniform variable. 16 | * 17 | * @param shaderProgram Shader program to set uniform variable in 18 | * @param uniformName Name of the uniform variable 19 | */ 20 | virtual void setUniform(ShaderProgram& shaderProgram, const std::string& uniformName) const = 0; 21 | 22 | virtual void* getDataPointer() const { return nullptr; } 23 | 24 | protected: 25 | /** 26 | * Constructs full uniform name containing of structure name and attribute name. 27 | * 28 | * @param uniformName Name of the uniform variable 29 | * @param attributeName Name of the attribute in that structure 30 | * 31 | * @return Full uniform name. 32 | */ 33 | static std::string constructAttributeName(const std::string& uniformName, const std::string& attributeName); 34 | }; 35 | 36 | } // namespace shader_structs -------------------------------------------------------------------------------- /common_classes/staticGeometry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // GLM 4 | #include 5 | 6 | namespace static_geometry 7 | { 8 | // A simple cube with unit size 9 | extern glm::vec3 cubeVertices[36]; 10 | extern glm::vec2 cubeTexCoords[6]; 11 | extern glm::vec3 cubeFaceColors[6]; 12 | 13 | // A simple pyramid with unit size 14 | extern glm::vec3 pyramidVertices[12]; 15 | extern glm::vec2 pyramidTexCoords[3]; 16 | extern glm::vec3 pyramidFaceColors[3]; 17 | 18 | // Ground, that has greenish color 19 | extern glm::vec3 plainGroundVertices[4]; 20 | extern glm::vec2 plainGroundTexCoords[4]; 21 | extern glm::vec3 plainGroundColors[4]; 22 | 23 | // 2D quad of unit size, anchored in lower-left point (same as texture coordinates, render with triangle strip) 24 | extern glm::vec2 quad2D[4]; 25 | } 26 | -------------------------------------------------------------------------------- /common_classes/static_meshes_2D/primitives/quad.cpp: -------------------------------------------------------------------------------- 1 | // GLM 2 | #include 3 | 4 | // Project 5 | #include "quad.h" 6 | 7 | namespace static_meshes_2D { 8 | 9 | glm::vec2 Quad::vertices[4] = 10 | { 11 | glm::vec2(0.0f, 1.0f), // Top-left point 12 | glm::vec2(0.0f, 0.0f), // Bottom-left point 13 | glm::vec2(1.0f, 1.0f), // Top-right point 14 | glm::vec2(1.0f, 0.0f) // Bottom-right point 15 | }; 16 | 17 | Quad::Quad(bool withPositions, bool withTextureCoordinates) 18 | : StaticMesh2D(withPositions, withTextureCoordinates) 19 | { 20 | initializeData(); 21 | } 22 | 23 | void Quad::render() const 24 | { 25 | if (!_isInitialized) { 26 | return; 27 | } 28 | 29 | glBindVertexArray(_vao); 30 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 31 | } 32 | 33 | void Quad::initializeData() 34 | { 35 | if (_isInitialized) { 36 | return; 37 | } 38 | 39 | glGenVertexArrays(1, &_vao); 40 | glBindVertexArray(_vao); 41 | 42 | const int numVertices = 4; 43 | int vertexByteSize = getVertexByteSize(); 44 | _vbo.createVBO(vertexByteSize * numVertices); 45 | _vbo.bindVBO(); 46 | 47 | if (hasPositions()) 48 | { 49 | _vbo.addRawData(vertices, sizeof(glm::vec2)*numVertices); 50 | } 51 | 52 | if (hasTextureCoordinates()) 53 | { 54 | _vbo.addRawData(vertices, sizeof(glm::vec2)*numVertices); 55 | } 56 | 57 | _vbo.uploadDataToGPU(GL_STATIC_DRAW); 58 | setVertexAttributesPointers(numVertices); 59 | _isInitialized = true; 60 | } 61 | 62 | } // namespace static_meshes_2D -------------------------------------------------------------------------------- /common_classes/static_meshes_2D/primitives/quad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // GLAD 4 | #include 5 | 6 | // GLM 7 | #include 8 | 9 | // Project 10 | #include "../staticMesh2D.h" 11 | 12 | namespace static_meshes_2D { 13 | 14 | /** 15 | * Quad static mesh of unit size. 16 | */ 17 | class Quad : public StaticMesh2D 18 | { 19 | public: 20 | Quad(bool withPositions = true, bool withTextureCoordinates = true); 21 | 22 | void render() const override; 23 | 24 | static glm::vec2 vertices[4]; // Array of mesh vertices (and texture coordinates as well) 25 | 26 | private: 27 | void initializeData() override; 28 | }; 29 | 30 | } // namespace static_meshes_2D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/heightmapWithFog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "heightmap.h" 5 | 6 | namespace static_meshes_3D { 7 | 8 | /** 9 | *Same as heightmap class, but renders terrain with a fog. 10 | */ 11 | class HeightmapWithFog : public Heightmap 12 | { 13 | public: 14 | static const std::string MULTILAYER_SHADER_PROGRAM_WITH_FOG_KEY; // Holds a key for multilayer heightmap shader program with a fog (used as shaders key too) 15 | 16 | HeightmapWithFog(const HillAlgorithmParameters& params, bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 17 | HeightmapWithFog(const std::string& fileName, bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 18 | 19 | static void prepareMultiLayerShaderProgramWithFog(); 20 | static ShaderProgram& getMultiLayerShaderProgramWithFog(); 21 | 22 | /** 23 | * Renders heightmap with multiple layers. 24 | * @param textureKeys Contains which textures should be used (ordered from bottom-most to top-most layer) 25 | * @param levels Contains where within the heightmap should layer transitions start / stop 26 | */ 27 | void renderMultilayered(const std::vector& textureKeys, const std::vector levels) const; 28 | }; 29 | 30 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/house.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // STL 4 | #include 5 | 6 | // GLM 7 | #include 8 | 9 | // Project 10 | #include "staticMesh3D.h" 11 | #include "primitives/cube.h" 12 | #include "primitives/pyramid.h" 13 | 14 | namespace static_meshes_3D { 15 | 16 | /** 17 | * House static mesh, using scaled cube and pyramid for rendering. 18 | */ 19 | class House : public StaticMesh3D 20 | { 21 | public: 22 | static const std::string WALLS_TEXTURE_KEY; // Key to store house walls texture with 23 | static const std::string DOOR_WALL_TEXTURE_KEY; // Key to store house door wall texture with 24 | static const std::string WINDOWS_WALL_TEXTURE_KEY; // Key to store house windows wall texture with 25 | static const std::string ROOF_TEXTURE_KEY; // Key to store house roof texture with 26 | 27 | House(bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 28 | 29 | void render() const override; 30 | void render(const glm::vec3& position, float rotationAngle) const; 31 | 32 | protected: 33 | void initializeData() override {} 34 | 35 | private: 36 | Cube cube; // Cube static mesh used to render house with 37 | Pyramid pyramid; // Pyramid static mesh used to render house with 38 | }; 39 | 40 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/plainGround.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // GLM 4 | #include 5 | 6 | // Project 7 | #include "staticMesh3D.h" 8 | 9 | namespace static_meshes_3D { 10 | 11 | /** 12 | * Plain ground static mesh. 13 | */ 14 | class PlainGround : public StaticMesh3D 15 | { 16 | public: 17 | PlainGround(bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 18 | 19 | static glm::vec3 vertices[4]; // Array of mesh vertices 20 | static glm::vec2 textureCoordinates[4]; // Array of mesh texture coordinates 21 | 22 | void render() const override; 23 | 24 | protected: 25 | void initializeData() override; 26 | }; 27 | 28 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/primitives/cube.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // GLM 4 | #include 5 | 6 | // Project 7 | #include "../staticMesh3D.h" 8 | 9 | namespace static_meshes_3D { 10 | 11 | const int CUBE_FRONT_FACE = 1; // Bitmask to render cube front face 12 | const int CUBE_BACK_FACE = 1 << 1; // Bitmask to render cube back face 13 | const int CUBE_LEFT_FACE = 1 << 2; // Bitmask to render cube left face 14 | const int CUBE_RIGHT_FACE = 1 << 3; // Bitmask to render cube right face 15 | const int CUBE_TOP_FACE = 1 << 4; // Bitmask to render cube top face 16 | const int CUBE_BOTTOM_FACE = 1 << 5; // Bitmask to render cube bottom face 17 | const int CUBE_ALLFACES = (1 << 6) - 1; // Bitmask to render cube bottom face 18 | 19 | /** 20 | * Cube static mesh of unit size. 21 | */ 22 | class Cube : public StaticMesh3D 23 | { 24 | public: 25 | Cube(bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 26 | 27 | void render() const override; 28 | void renderPoints() const override; 29 | void renderFaces(int facesBitmask) const; 30 | 31 | static glm::vec3 vertices[36]; // Array of mesh vertices 32 | static glm::vec2 textureCoordinates[6]; // Array of mesh texture coordinates 33 | static glm::vec3 normals[6]; // Array of mesh normals 34 | 35 | private: 36 | void initializeData() override; 37 | }; 38 | 39 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/primitives/cylinder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../staticMesh3D.h" 5 | 6 | namespace static_meshes_3D { 7 | 8 | /** 9 | * Cylinder static mesh with given radius, number of slices and height. 10 | */ 11 | class Cylinder : public StaticMesh3D 12 | { 13 | public: 14 | Cylinder(float radius, int numSlices, float height, 15 | bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 16 | 17 | void render() const override; 18 | void renderPoints() const override; 19 | 20 | /** 21 | * Gets cylinder radius. 22 | */ 23 | float getRadius() const; 24 | 25 | /** 26 | * Gets number of cylinder slices. 27 | */ 28 | int getSlices() const; 29 | 30 | /** 31 | * Gets cylinder height. 32 | */ 33 | float getHeight() const; 34 | 35 | private: 36 | float _radius; // Cylinder radius (distance from the center of cylinder to surface) 37 | int _numSlices; // Number of cylinder slices 38 | float _height; // Height of the cylinder 39 | 40 | int _numVerticesSide; // How many vertices to render side of the cylinder 41 | int _numVerticesTopBottom; // How many vertices to render top / bottom of the cylinder 42 | int _numVerticesTotal; // Just a sum of both numbers above 43 | 44 | void initializeData() override; 45 | }; 46 | 47 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/primitives/pyramid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // GLM 4 | #include 5 | 6 | // Project 7 | #include "../staticMesh3D.h" 8 | 9 | namespace static_meshes_3D { 10 | 11 | /** 12 | * Pyramid static mesh of unit size. 13 | */ 14 | class Pyramid : public StaticMesh3D 15 | { 16 | public: 17 | Pyramid(bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 18 | 19 | void render() const override; 20 | void renderPoints() const override; 21 | 22 | static glm::vec3 vertices[12]; // Array of mesh vertices 23 | static glm::vec2 textureCoordinates[3]; // Array of mesh texture coordinates 24 | 25 | private: 26 | void initializeData() override; 27 | }; 28 | 29 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/primitives/torus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "../staticMeshIndexed3D.h" 5 | 6 | namespace static_meshes_3D { 7 | 8 | /** 9 | * Torus static mesh with given subdivisions and radii. 10 | */ 11 | class Torus : public StaticMeshIndexed3D 12 | { 13 | public: 14 | Torus(int mainSegments, int tubeSegments, float mainRadius, float tubeRadius, 15 | bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 16 | 17 | void render() const override; 18 | void renderPoints() const override; 19 | 20 | /** 21 | * Gets main torus radius. 22 | */ 23 | float getMainRadius() const; 24 | 25 | /** 26 | * Gets torus tube radius. 27 | */ 28 | float getTubeRadius() const; 29 | 30 | private: 31 | int _mainSegments; // Number of main subdivisons (around whole torus) 32 | int _tubeSegments; // Number of tube subdivisions 33 | float _mainRadius; // Radius of torus (distance from center of torus to the center of tube) 34 | float _tubeRadius; // Radius of tube 35 | 36 | void initializeData() override; 37 | }; 38 | 39 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/snowCoveredPlainGround.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "plainGround.h" 5 | 6 | namespace static_meshes_3D { 7 | 8 | /** 9 | * Plain ground static mesh covered with snow and pavement. 10 | */ 11 | class SnowCoveredPlainGround : public PlainGround 12 | { 13 | public: 14 | SnowCoveredPlainGround(bool withPositions = true, bool withTextureCoordinates = true, bool withNormals = true); 15 | 16 | void render() const override; 17 | }; 18 | 19 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/staticMeshIndexed3D.cpp: -------------------------------------------------------------------------------- 1 | // Project 2 | #include "staticMeshIndexed3D.h" 3 | 4 | namespace static_meshes_3D { 5 | 6 | StaticMeshIndexed3D::StaticMeshIndexed3D(bool withPositions, bool withTextureCoordinates, bool withNormals) 7 | : StaticMesh3D(withPositions, withTextureCoordinates, withNormals) {} 8 | 9 | StaticMeshIndexed3D::~StaticMeshIndexed3D() 10 | { 11 | if (_isInitialized) { 12 | // It's enough to delete indices VBO here, rest of stuff is destructed in super destructor 13 | _indicesVBO.deleteVBO(); 14 | } 15 | } 16 | 17 | void StaticMeshIndexed3D::deleteMesh() 18 | { 19 | if (_isInitialized) { 20 | _indicesVBO.deleteVBO(); 21 | StaticMesh3D::deleteMesh(); 22 | } 23 | } 24 | 25 | } // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_classes/static_meshes_3D/staticMeshIndexed3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Project 4 | #include "staticMesh3D.h" 5 | 6 | namespace static_meshes_3D { 7 | 8 | /** 9 | * Represents generic 3D static mesh rendered with indexed rendering. 10 | */ 11 | class StaticMeshIndexed3D : public StaticMesh3D 12 | { 13 | public: 14 | StaticMeshIndexed3D(bool withPositions, bool withTextureCoordinates, bool withNormals); 15 | virtual ~StaticMeshIndexed3D(); 16 | 17 | void deleteMesh() override; 18 | 19 | protected: 20 | VertexBufferObject _indicesVBO; // Our VBO wrapper class holding indices data 21 | 22 | int _numVertices = 0; // Holds the total number of generated vertices 23 | int _numIndices = 0; // Holds the number of generated indices used for rendering 24 | int _primitiveRestartIndex = 0; // Index of primitive restart 25 | }; 26 | 27 | }; // namespace static_meshes_3D -------------------------------------------------------------------------------- /common_properties_debug.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | $(SolutionDir)dependencies\glm;$(SolutionDir)dependencies\glad\include;$(SolutionDir)dependencies\stb;$(IncludePath) 8 | $(LibraryPath) 9 | $(ProjectName)_d 10 | 11 | 12 | 13 | glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /common_properties_debug64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | $(SolutionDir)dependencies\glm;$(SolutionDir)dependencies\glad\include;$(SolutionDir)dependencies\stb;$(IncludePath) 8 | $(LibraryPath) 9 | $(ProjectName)_d64 10 | 11 | 12 | 13 | glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /common_properties_release.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | $(SolutionDir)dependencies\glm;$(SolutionDir)dependencies\glad\include;$(SolutionDir)dependencies\stb;$(IncludePath) 8 | $(LibraryPath) 9 | $(ProjectName) 10 | 11 | 12 | 13 | glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /common_properties_release64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)bin\ 7 | $(SolutionDir)dependencies\glm;$(SolutionDir)dependencies\glad\include;$(SolutionDir)dependencies\stb;$(IncludePath) 8 | $(LibraryPath) 9 | $(ProjectName)_64 10 | 11 | 12 | 13 | glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2017/assimp_properties_debug.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2017\libs32\debug;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2017_debug 9 | 10 | 11 | 12 | zlibstaticd.lib;IrrXMLd.lib;assimp-vc141-mtd.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2017/assimp_properties_debug64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2017\libs64\debug;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2017_debug64 9 | 10 | 11 | 12 | zlibstaticd.lib;IrrXMLd.lib;assimp-vc141-mtd.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2017/assimp_properties_release.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2017\libs32\release;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2017_release 9 | 10 | 11 | 12 | zlibstatic.lib;IrrXML.lib;assimp-vc141-mt.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2017/assimp_properties_release64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2017\libs64\release;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2017_release64 9 | 10 | 11 | 12 | zlibstatic.lib;IrrXML.lib;assimp-vc141-mt.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2019/assimp_properties_debug.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2019\libs32\debug;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2019_debug 9 | 10 | 11 | 12 | zlibstaticd.lib;IrrXMLd.lib;assimp-vc142-mtd.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2019/assimp_properties_debug64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2019\libs64\debug;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2019_debug64 9 | 10 | 11 | 12 | zlibstaticd.lib;IrrXMLd.lib;assimp-vc142-mtd.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2019/assimp_properties_release.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2019\libs32\release;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2019_release 9 | 10 | 11 | 12 | zlibstatic.lib;IrrXML.lib;assimp-vc142-mt.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/assimp-prebuilt/vs2019/assimp_properties_release64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\assimp\include;$(SolutionDir)dependencies\assimp-prebuilt\include;$(IncludePath) 7 | $(SolutionDir)dependencies\assimp-prebuilt\vs2019\libs64\release;$(LibraryPath) 8 | <_PropertySheetDisplayName>assimp_vs2019_release64 9 | 10 | 11 | 12 | zlibstatic.lib;IrrXML.lib;assimp-vc142-mt.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /dependencies/freetype2-prebuilt/vs2017/freetype2_properties.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\freetype2\include;$(IncludePath) 7 | $(SolutionDir)dependencies\freetype2-prebuilt\vs2017\libs32;$(LibraryPath) 8 | 9 | 10 | 11 | freetype2.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dependencies/freetype2-prebuilt/vs2017/freetype2_properties64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\freetype2\include;$(IncludePath) 7 | $(SolutionDir)dependencies\freetype2-prebuilt\vs2017\libs64;$(LibraryPath) 8 | 9 | 10 | 11 | freetype2_64.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dependencies/freetype2-prebuilt/vs2019/freetype2_properties.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\freetype2\include;$(IncludePath) 7 | $(SolutionDir)dependencies\freetype2-prebuilt\vs2019\libs32;$(LibraryPath) 8 | 9 | 10 | 11 | freetype.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dependencies/freetype2-prebuilt/vs2019/freetype2_properties64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\freetype2\include;$(IncludePath) 7 | $(SolutionDir)dependencies\freetype2-prebuilt\vs2019\libs64;$(LibraryPath) 8 | 9 | 10 | 11 | freetype.lib;glfw3.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2017/glfw_properties.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\glfw\include;$(IncludePath) 7 | $(SolutionDir)dependencies\glfw-prebuilt\vs2017\libs32;$(LibraryPath) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2017/glfw_properties64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\glfw\include;$(IncludePath) 7 | $(SolutionDir)dependencies\glfw-prebuilt\vs2017\libs64;$(LibraryPath) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2017/libs32/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/dependencies/glfw-prebuilt/vs2017/libs32/glfw3.lib -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2017/libs64/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/dependencies/glfw-prebuilt/vs2017/libs64/glfw3.lib -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2019/glfw_properties.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\glfw\include;$(IncludePath) 7 | $(SolutionDir)dependencies\glfw-prebuilt\vs2019\libs32;$(LibraryPath) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2019/glfw_properties64.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)dependencies\glfw\include;$(IncludePath) 7 | $(SolutionDir)dependencies\glfw-prebuilt\vs2019\libs64;$(LibraryPath) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2019/libs32/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/dependencies/glfw-prebuilt/vs2019/libs32/glfw3.lib -------------------------------------------------------------------------------- /dependencies/glfw-prebuilt/vs2019/libs64/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michalbb1/opengl4-tutorials-mbsoftworks/85909d0d22f51a4ebff5f22ac3f7456d77a6058a/dependencies/glfw-prebuilt/vs2019/libs64/glfw3.lib -------------------------------------------------------------------------------- /unix_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # First, download all submodules and repositories 4 | echo "Downloading all the submodules / repositories..." 5 | git submodule update --init --recursive 6 | 7 | # Update packages repository 8 | apt-get update 9 | 10 | # Install pkg-config for CMake to work properly 11 | echo "Installing pkg-config..." 12 | apt-get install -y pkg-config 13 | 14 | # Install doxygen - needed for build & install of GLFW 15 | echo "Installing doxygen..." 16 | apt-get install -y doxygen 17 | 18 | # Install xorg-dev - needed for build & install of GLFW 19 | echo "Installing xorg-dev..." 20 | apt-get install -y xorg-dev 21 | 22 | # Now we can build and install GLFW 23 | echo "Building and installing GLFW..." 24 | mkdir -p dependencies/glfw/build 25 | (cd dependencies/glfw/build && cmake .. && make -j4 && make install) 26 | 27 | # Same goes for Assimp 28 | echo "Building and installing Assimp..." 29 | mkdir -p dependencies/assimp/build 30 | (cd dependencies/assimp/build && cmake .. && make -j4 && make install) 31 | 32 | # Now go back to the root folder and now we can finally build the tutorials! 33 | echo "Building tutorials..." 34 | mkdir build 35 | (cd build && cmake .. && make -j4) --------------------------------------------------------------------------------