From ab855ca5afeaa3cbfb7394239ae5ed03c43a5ba5 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Tue, 6 Mar 2018 21:35:14 +0100 Subject: [PATCH 01/12] 1.0.6 Update header --- include/sre/BlendType.hpp | 2 +- include/sre/Camera.hpp | 2 +- include/sre/Color.hpp | 2 +- include/sre/Framebuffer.hpp | 2 +- include/sre/Inspector.hpp | 2 +- include/sre/Light.hpp | 2 +- include/sre/LightType.hpp | 2 +- include/sre/Log.hpp | 2 +- include/sre/Material.hpp | 2 +- include/sre/Mesh.hpp | 2 +- include/sre/MeshTopology.hpp | 2 +- include/sre/ModelImporter.hpp | 2 +- include/sre/RenderPass.hpp | 2 +- include/sre/RenderStats.hpp | 2 +- include/sre/Renderer.hpp | 4 ++-- include/sre/SDLRenderer.hpp | 2 +- include/sre/Shader.hpp | 2 +- include/sre/Sprite.hpp | 2 +- include/sre/SpriteAtlas.hpp | 2 +- include/sre/SpriteBatch.hpp | 2 +- include/sre/Texture.hpp | 2 +- include/sre/VR.hpp | 2 +- include/sre/WorldLights.hpp | 2 +- include/sre/imgui_sre.hpp | 2 +- include/sre/impl/CPPShim.hpp | 2 +- include/sre/impl/Export.hpp | 2 +- include/sre/impl/GL.hpp | 2 +- include/sre/impl/GL.inl | 4 ++-- src/sre/Camera.cpp | 2 +- src/sre/Color.cpp | 2 +- src/sre/Framebuffer.cpp | 2 +- src/sre/Inspector.cpp | 2 +- src/sre/Light.cpp | 2 +- src/sre/Log.cpp | 2 +- src/sre/Material.cpp | 2 +- src/sre/Mesh.cpp | 2 +- src/sre/ModelImporter.cpp | 2 +- src/sre/RenderPass.cpp | 2 +- src/sre/Renderer.cpp | 2 +- src/sre/SDLRenderer.cpp | 2 +- src/sre/Shader.cpp | 2 +- src/sre/Sprite.cpp | 2 +- src/sre/SpriteAtlas.cpp | 2 +- src/sre/SpriteBatch.cpp | 2 +- src/sre/Texture.cpp | 2 +- src/sre/VR.cpp | 7 +++++++ src/sre/WorldLights.cpp | 2 +- version-history.md | 1 + 48 files changed, 56 insertions(+), 48 deletions(-) diff --git a/include/sre/BlendType.hpp b/include/sre/BlendType.hpp index 2167c4d0..291e4c04 100755 --- a/include/sre/BlendType.hpp +++ b/include/sre/BlendType.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Camera.hpp b/include/sre/Camera.hpp index a12cf622..c76804c3 100755 --- a/include/sre/Camera.hpp +++ b/include/sre/Camera.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Color.hpp b/include/sre/Color.hpp index fb1de4a9..b822da44 100644 --- a/include/sre/Color.hpp +++ b/include/sre/Color.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Framebuffer.hpp b/include/sre/Framebuffer.hpp index be0145a9..d28cdf47 100644 --- a/include/sre/Framebuffer.hpp +++ b/include/sre/Framebuffer.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Inspector.hpp b/include/sre/Inspector.hpp index f3a1a25f..f9f10664 100644 --- a/include/sre/Inspector.hpp +++ b/include/sre/Inspector.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Light.hpp b/include/sre/Light.hpp index 9151bc53..ccefcadc 100755 --- a/include/sre/Light.hpp +++ b/include/sre/Light.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/LightType.hpp b/include/sre/LightType.hpp index 389225de..0e7ff7f7 100755 --- a/include/sre/LightType.hpp +++ b/include/sre/LightType.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Log.hpp b/include/sre/Log.hpp index 71798750..92504cb7 100644 --- a/include/sre/Log.hpp +++ b/include/sre/Log.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ #pragma once diff --git a/include/sre/Material.hpp b/include/sre/Material.hpp index c4f8e7d1..7420169a 100755 --- a/include/sre/Material.hpp +++ b/include/sre/Material.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Mesh.hpp b/include/sre/Mesh.hpp index 7ce37bf4..8ca0f517 100755 --- a/include/sre/Mesh.hpp +++ b/include/sre/Mesh.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/MeshTopology.hpp b/include/sre/MeshTopology.hpp index 0e848b40..2985303f 100755 --- a/include/sre/MeshTopology.hpp +++ b/include/sre/MeshTopology.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/ModelImporter.hpp b/include/sre/ModelImporter.hpp index 0a57a44d..de877d04 100644 --- a/include/sre/ModelImporter.hpp +++ b/include/sre/ModelImporter.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/RenderPass.hpp b/include/sre/RenderPass.hpp index 9d1b7f76..a2e4120b 100755 --- a/include/sre/RenderPass.hpp +++ b/include/sre/RenderPass.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/RenderStats.hpp b/include/sre/RenderStats.hpp index 15a6be25..52001471 100755 --- a/include/sre/RenderStats.hpp +++ b/include/sre/RenderStats.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Renderer.hpp b/include/sre/Renderer.hpp index d42cfcd3..f95eb24b 100755 --- a/include/sre/Renderer.hpp +++ b/include/sre/Renderer.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ @@ -71,7 +71,7 @@ namespace sre { ~Renderer(); static constexpr int sre_version_major = 1; static constexpr int sre_version_minor = 0; - static constexpr int sre_version_point = 5; + static constexpr int sre_version_point = 6; glm::ivec2 getWindowSize(); // Return the current size of the window diff --git a/include/sre/SDLRenderer.hpp b/include/sre/SDLRenderer.hpp index e510390e..60d4e790 100755 --- a/include/sre/SDLRenderer.hpp +++ b/include/sre/SDLRenderer.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Shader.hpp b/include/sre/Shader.hpp index 0efab490..c656501b 100755 --- a/include/sre/Shader.hpp +++ b/include/sre/Shader.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Sprite.hpp b/include/sre/Sprite.hpp index d1b1c040..f6040923 100644 --- a/include/sre/Sprite.hpp +++ b/include/sre/Sprite.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/SpriteAtlas.hpp b/include/sre/SpriteAtlas.hpp index 923f25c2..3cee7e74 100644 --- a/include/sre/SpriteAtlas.hpp +++ b/include/sre/SpriteAtlas.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/SpriteBatch.hpp b/include/sre/SpriteBatch.hpp index c72189c6..e558b0b8 100644 --- a/include/sre/SpriteBatch.hpp +++ b/include/sre/SpriteBatch.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/Texture.hpp b/include/sre/Texture.hpp index 3c6b2515..dc7ff7ca 100755 --- a/include/sre/Texture.hpp +++ b/include/sre/Texture.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/VR.hpp b/include/sre/VR.hpp index 914486cc..ecc4e468 100644 --- a/include/sre/VR.hpp +++ b/include/sre/VR.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-J�rgensen ( http://www.nobel-joergensen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/WorldLights.hpp b/include/sre/WorldLights.hpp index d4516366..a8e0b678 100755 --- a/include/sre/WorldLights.hpp +++ b/include/sre/WorldLights.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/imgui_sre.hpp b/include/sre/imgui_sre.hpp index d218256f..cee8ea32 100755 --- a/include/sre/imgui_sre.hpp +++ b/include/sre/imgui_sre.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/impl/CPPShim.hpp b/include/sre/impl/CPPShim.hpp index 6242f148..93b25e6e 100755 --- a/include/sre/impl/CPPShim.hpp +++ b/include/sre/impl/CPPShim.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/impl/Export.hpp b/include/sre/impl/Export.hpp index 3604f41c..13e4585f 100755 --- a/include/sre/impl/Export.hpp +++ b/include/sre/impl/Export.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/impl/GL.hpp b/include/sre/impl/GL.hpp index ca79754e..f073e618 100755 --- a/include/sre/impl/GL.hpp +++ b/include/sre/impl/GL.hpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/include/sre/impl/GL.inl b/include/sre/impl/GL.inl index 0688806a..75b96658 100755 --- a/include/sre/impl/GL.inl +++ b/include/sre/impl/GL.inl @@ -1,7 +1,7 @@ /* - * SimpleRenderEngine + * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Camera.cpp b/src/sre/Camera.cpp index 31eb10f9..2e6b7452 100755 --- a/src/sre/Camera.cpp +++ b/src/sre/Camera.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Color.cpp b/src/sre/Color.cpp index 58677a27..4636432a 100644 --- a/src/sre/Color.cpp +++ b/src/sre/Color.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Framebuffer.cpp b/src/sre/Framebuffer.cpp index 6ca9b850..fbc7e549 100644 --- a/src/sre/Framebuffer.cpp +++ b/src/sre/Framebuffer.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Inspector.cpp b/src/sre/Inspector.cpp index 66811ebb..a09109d5 100644 --- a/src/sre/Inspector.cpp +++ b/src/sre/Inspector.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ #include "sre/Inspector.hpp" diff --git a/src/sre/Light.cpp b/src/sre/Light.cpp index b5023b60..3aa2c22d 100755 --- a/src/sre/Light.cpp +++ b/src/sre/Light.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Log.cpp b/src/sre/Log.cpp index 5364276f..874d375e 100644 --- a/src/sre/Log.cpp +++ b/src/sre/Log.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Material.cpp b/src/sre/Material.cpp index e2984276..ebf215ce 100755 --- a/src/sre/Material.cpp +++ b/src/sre/Material.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Mesh.cpp b/src/sre/Mesh.cpp index 1974ec7e..ce15b620 100755 --- a/src/sre/Mesh.cpp +++ b/src/sre/Mesh.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/ModelImporter.cpp b/src/sre/ModelImporter.cpp index 0f2384c4..b86954fb 100644 --- a/src/sre/ModelImporter.cpp +++ b/src/sre/ModelImporter.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/RenderPass.cpp b/src/sre/RenderPass.cpp index a62322d7..a7313ce6 100755 --- a/src/sre/RenderPass.cpp +++ b/src/sre/RenderPass.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Renderer.cpp b/src/sre/Renderer.cpp index 1cbb7922..04b0111d 100755 --- a/src/sre/Renderer.cpp +++ b/src/sre/Renderer.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/SDLRenderer.cpp b/src/sre/SDLRenderer.cpp index e933735b..a3136261 100755 --- a/src/sre/SDLRenderer.cpp +++ b/src/sre/SDLRenderer.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Shader.cpp b/src/sre/Shader.cpp index b737726d..a91d3577 100755 --- a/src/sre/Shader.cpp +++ b/src/sre/Shader.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Sprite.cpp b/src/sre/Sprite.cpp index 502daf8b..343091d7 100644 --- a/src/sre/Sprite.cpp +++ b/src/sre/Sprite.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/SpriteAtlas.cpp b/src/sre/SpriteAtlas.cpp index df5a6093..eda56372 100644 --- a/src/sre/SpriteAtlas.cpp +++ b/src/sre/SpriteAtlas.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/SpriteBatch.cpp b/src/sre/SpriteBatch.cpp index b653d4a1..591f13d4 100644 --- a/src/sre/SpriteBatch.cpp +++ b/src/sre/SpriteBatch.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/Texture.cpp b/src/sre/Texture.cpp index 64e35607..d800e95e 100755 --- a/src/sre/Texture.cpp +++ b/src/sre/Texture.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/src/sre/VR.cpp b/src/sre/VR.cpp index 7730cd49..732f4371 100644 --- a/src/sre/VR.cpp +++ b/src/sre/VR.cpp @@ -1,3 +1,10 @@ +/* + * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) + * + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) + * License: MIT + */ + #include "sre/VR.hpp" #include "sre/Log.hpp" #include diff --git a/src/sre/WorldLights.cpp b/src/sre/WorldLights.cpp index d0e98450..45b68834 100755 --- a/src/sre/WorldLights.cpp +++ b/src/sre/WorldLights.cpp @@ -1,7 +1,7 @@ /* * SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine) * - * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergnesen.com/ ) + * Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ ) * License: MIT */ diff --git a/version-history.md b/version-history.md index d3e63bb2..08850c8f 100644 --- a/version-history.md +++ b/version-history.md @@ -1,5 +1,6 @@ ## Version history + * 1.0.6 * 1.0.5 Improve indexed mesh performance. * 1.0.4 WebGL 2 support. Fix WebGL shader warnings. * 1.0.3 Add RenderPass.blit(). Add depth/stencil as Texture type and add support for depth attachment in Framebuffer. From 69e62beed3774041ec4c24371fef7007e25d43d0 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Thu, 8 Mar 2018 14:06:40 +0100 Subject: [PATCH 02/12] 1.0.6 Cleanup shader --- src/sre/Shader.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/sre/Shader.cpp b/src/sre/Shader.cpp index a91d3577..20e8e4f2 100755 --- a/src/sre/Shader.cpp +++ b/src/sre/Shader.cpp @@ -719,30 +719,41 @@ namespace sre { unsigned int oldShaderProgramId = shaderProgramId; shaderProgramId = glCreateProgram(); assert(shaderProgramId != 0); + std::vector shaders; + + auto cleanupShaders = [&](){ + for (auto id : shaders){ + glDeleteShader(id); + } + }; + for (ShaderType i=ShaderType::Vertex;isecond, shader, s, errors); - if (!res){ + if (!res) { + cleanupShaders(); glDeleteProgram( shaderProgramId ); shaderProgramId = oldShaderProgramId; return false; + } else { + shaders.push_back(s); } glAttachShader(shaderProgramId, s); } } bool linked = linkProgram(shaderProgramId, errors); - if (!linked){ + cleanupShaders(); + if (!linked) { glDeleteProgram( shaderProgramId ); - shaderProgramId = oldShaderProgramId; + shaderProgramId = oldShaderProgramId; // revert to old shader return false; } if (oldShaderProgramId != 0){ - glDeleteProgram( oldShaderProgramId ); + glDeleteProgram( oldShaderProgramId ); // delete old shader if any } updateUniformsAndAttributes(); return true; From 852eb35b7ee8665fb3ce7224dcaedb3c6677e963 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Wed, 14 Mar 2018 10:53:25 +0100 Subject: [PATCH 03/12] 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. --- include/sre/Mesh.hpp | 2 + include/sre/Shader.hpp | 1 + src/sre/Inspector.cpp | 112 ++++++++++++++++++------------- src/sre/Mesh.cpp | 4 ++ src/sre/Shader.cpp | 3 + test/CMakeLists.txt | 2 +- test/custom-mesh-layout-ints.cpp | 103 ++++++++++++++++++++++++++++ version-history.md | 2 +- 8 files changed, 181 insertions(+), 48 deletions(-) create mode 100644 test/custom-mesh-layout-ints.cpp diff --git a/include/sre/Mesh.hpp b/include/sre/Mesh.hpp index 8ca0f517..6c309f07 100755 --- a/include/sre/Mesh.hpp +++ b/include/sre/Mesh.hpp @@ -165,6 +165,8 @@ namespace sre { friend class RenderPass; friend class Inspector; + + bool hasAttribute(std::string name); }; template<> diff --git a/include/sre/Shader.hpp b/include/sre/Shader.hpp index c656501b..ae47d4d0 100755 --- a/include/sre/Shader.hpp +++ b/include/sre/Shader.hpp @@ -35,6 +35,7 @@ namespace sre { Mat4, Vec3, Vec4, + IVec4, Texture, TextureCube, Invalid diff --git a/src/sre/Inspector.cpp b/src/sre/Inspector.cpp index a09109d5..84c6b657 100644 --- a/src/sre/Inspector.cpp +++ b/src/sre/Inspector.cpp @@ -39,6 +39,9 @@ namespace sre { case GL_FLOAT: typeStr = "float"; break; + case GL_INT: + typeStr = "int"; + break; case GL_FLOAT_VEC2: typeStr = "vec2"; break; @@ -54,11 +57,9 @@ namespace sre { case GL_FLOAT_MAT3: typeStr = "mat3"; break; -#ifndef EMSCRIPTEN case GL_INT_VEC4: typeStr = "ivec4"; break; -#endif default: typeStr = "invalid"; } @@ -146,7 +147,7 @@ namespace sre { auto type = mesh->getType(a); std::string typeStr = glEnumToString(type.first); typeStr = appendSize(typeStr, type.second); - ImGui::LabelText(a.c_str(), typeStr.c_str()); + ImGui::LabelText(a.c_str(), "%s (%i)",typeStr.c_str(),type.first); } ImGui::TreePop(); } @@ -180,16 +181,29 @@ namespace sre { auto offset = att.second.offset; auto offsetStr = std::to_string(offset); ImGui::LabelText("offset", offsetStr.c_str()); - - for (int j=0;jvertexCount); j++){ - std::string value = ""; - for (int i=0;itotalBytesPerVertex)/sizeof(float)]; - value += std::to_string(data)+" "; + if (dataType == GL_INT){ + for (int j=0;jvertexCount); j++){ + std::string value = ""; + for (int i=0;itotalBytesPerVertex)/sizeof(float)]; + int* dataInt = reinterpret_cast(data); + value += std::to_string(*dataInt)+" "; + } + std::string label = "Value "; + label+= std::to_string(j); + ImGui::LabelText(label.c_str(), value.c_str()); + } + } else { + for (int j=0;jvertexCount); j++){ + std::string value = ""; + for (int i=0;itotalBytesPerVertex)/sizeof(float)]; + value += std::to_string(data)+" "; + } + std::string label = "Value "; + label+= std::to_string(j); + ImGui::LabelText(label.c_str(), value.c_str()); } - std::string label = "Value "; - label+= std::to_string(j); - ImGui::LabelText(label.c_str(), value.c_str()); } ImGui::TreePop(); @@ -201,42 +215,46 @@ namespace sre { ImGui::TreePop(); } - initFramebuffer(); - - Camera camera; - camera.setPerspectiveProjection(60,0.1,10); - camera.lookAt({0,0,4},{0,0,0},{0,1,0}); - auto offscreenTexture = getTmpTexture(); - framebuffer->setColorTexture(offscreenTexture); - - auto renderToTexturePass = RenderPass::create() - .withCamera(camera) - .withWorldLights(&worldLights) - .withFramebuffer(framebuffer) - .withClearColor(true, {0, 0, 0, 1}) - .withGUI(false) - .build(); - static auto litMat = Shader::getStandardBlinnPhong()->createMaterial(); - static auto unlitMat = Shader::getUnlit()->createMaterial(); - - bool hasNormals = mesh->getNormals().size()>0; - auto mat = hasNormals ? litMat : unlitMat; - auto sharedPtrMesh = mesh->shared_from_this(); - float rotationSpeed = 0.001f; - - auto bounds = mesh->getBoundsMinMax(); - auto center = (bounds[1] + bounds[0])*0.5f; - auto offset = -center; - auto scale = bounds[1]-bounds[0]; - float maxS = std::max({scale.x,scale.y,scale.z}); + if (mesh->hasAttribute("position")){ + initFramebuffer(); + + Camera camera; + camera.setPerspectiveProjection(60,0.1,10); + camera.lookAt({0,0,4},{0,0,0},{0,1,0}); + auto offscreenTexture = getTmpTexture(); + framebuffer->setColorTexture(offscreenTexture); + + auto renderToTexturePass = RenderPass::create() + .withCamera(camera) + .withWorldLights(&worldLights) + .withFramebuffer(framebuffer) + .withClearColor(true, {0, 0, 0, 1}) + .withGUI(false) + .build(); + static auto litMat = Shader::getStandardBlinnPhong()->createMaterial(); + static auto unlitMat = Shader::getUnlit()->createMaterial(); + + bool hasNormals = mesh->getNormals().size()>0; + auto mat = hasNormals ? litMat : unlitMat; + auto sharedPtrMesh = mesh->shared_from_this(); + float rotationSpeed = 0.001f; + + auto bounds = mesh->getBoundsMinMax(); + auto center = (bounds[1] + bounds[0])*0.5f; + auto offset = -center; + auto scale = bounds[1]-bounds[0]; + float maxS = std::max({scale.x,scale.y,scale.z}); + + std::vector> mats; + for (int m = 0;mgetIndexSets());m++){ + mats.push_back(mat); + } + renderToTexturePass.draw(sharedPtrMesh, glm::eulerAngleY(time*rotationSpeed)*glm::scale(glm::vec3{2.0f/maxS,2.0f/maxS,2.0f/maxS})*glm::translate(offset), mats); - std::vector> mats; - for (int m = 0;mgetIndexSets());m++){ - mats.push_back(mat); + ImGui::Image(reinterpret_cast(offscreenTexture->textureId), ImVec2(previewSize, previewSize),{0,1},{1,0},{1,1,1,1},{0,0,0,1}); + } else { + ImGui::LabelText("", "No preview - missing position attribute"); } - renderToTexturePass.draw(sharedPtrMesh, glm::eulerAngleY(time*rotationSpeed)*glm::scale(glm::vec3{2.0f/maxS,2.0f/maxS,2.0f/maxS})*glm::translate(offset), mats); - - ImGui::Image(reinterpret_cast(offscreenTexture->textureId), ImVec2(previewSize, previewSize),{0,1},{1,0},{1,1,1,1},{0,0,0,1}); ImGui::TreePop(); } } @@ -341,6 +359,8 @@ namespace sre { return "vec3"; case UniformType::Vec4: return "vec4"; + case UniformType::IVec4: + return "ivec4"; case UniformType::Invalid: return "Unsupported"; diff --git a/src/sre/Mesh.cpp b/src/sre/Mesh.cpp index ce15b620..fbbf7718 100755 --- a/src/sre/Mesh.cpp +++ b/src/sre/Mesh.cpp @@ -418,6 +418,10 @@ namespace sre { boundsMinMax = minMax; } + bool Mesh::hasAttribute(std::string name) { + return attributeByName.find(name) != attributeByName.end(); + } + Mesh::MeshBuilder &Mesh::MeshBuilder::withPositions(const std::vector &vertexPositions) { withAttribute("position", vertexPositions); return *this; diff --git a/src/sre/Shader.cpp b/src/sre/Shader.cpp index 20e8e4f2..a3188f77 100755 --- a/src/sre/Shader.cpp +++ b/src/sre/Shader.cpp @@ -380,6 +380,9 @@ namespace sre { case GL_FLOAT_VEC4: uniformType = UniformType::Vec4; break; + case GL_INT_VEC4: + uniformType = UniformType::IVec4; + break; case GL_INT: uniformType = UniformType::Int; break; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a1bf2f44..e466e809 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ # List of single-file tests -SET(scr_files multiple-materials render-depth spinning-sphere-cubemap particle-test polygon-offset-example multiple-lights particle-sprite sprite-test multi-cameras static_vertex_attribute custom-mesh-layout-default-values imgui_demo texture-test screen-point-to-ray pbr-test gamma primitives-test imgui-color-test) +SET(scr_files custom-mesh-layout-ints multiple-materials render-depth spinning-sphere-cubemap particle-test polygon-offset-example multiple-lights particle-sprite sprite-test multi-cameras static_vertex_attribute custom-mesh-layout-default-values imgui_demo texture-test screen-point-to-ray pbr-test gamma primitives-test imgui-color-test) # Create custom build targets FOREACH(scr_file ${scr_files}) diff --git a/test/custom-mesh-layout-ints.cpp b/test/custom-mesh-layout-ints.cpp new file mode 100644 index 00000000..615afe64 --- /dev/null +++ b/test/custom-mesh-layout-ints.cpp @@ -0,0 +1,103 @@ +#include + +#include "sre/Texture.hpp" +#include "sre/Renderer.hpp" +#include "sre/Material.hpp" +#include "sre/Inspector.hpp" + +#include +#include +#include +#include + +using namespace sre; + +class CustomMeshLayoutExample{ +public: + CustomMeshLayoutExample(){ + r.init(); + + + std::vector positions({ + {0, 1,0,1}, + {0, 0,0,1}, + {1, 0,0,1} + }); + std::vector colors({ + {1, 0,0,1}, + {0, 1,0,1}, + {0, 0,1,1}, + + }); + + mesh = Mesh::create() + .withAttribute("posxyzw",positions) + .withAttribute("color",colors) + .build(); + + std::string vertexShaderSource = R"(#version 140 +in ivec4 posxyzw; +in vec4 color; +out vec4 vColor; + +uniform mat4 g_model; +uniform mat4 g_view; +uniform mat4 g_projection; + +void main(void) { + gl_Position = g_projection * g_view * g_model * vec4(posxyzw); + vColor = color; +} +)"; + std::string fragmentShaderSource = R"(#version 140 +out vec4 fragColor; +in vec4 vColor; + +void main(void) +{ + fragColor = vColor; +} +)"; + + mat1 = Shader::create() + .withSourceString(vertexShaderSource,ShaderType::Vertex) + .withSourceString(fragmentShaderSource, ShaderType::Fragment) + .build()->createMaterial(); + + std::string info; + bool isValid = mat1->getShader()->validateMesh(mesh.get(), info); + std::cout << "Mesh is valid: "< mesh; + std::shared_ptr mat1; +}; + +int main() { + new CustomMeshLayoutExample(); + + return 0; +} + diff --git a/version-history.md b/version-history.md index 08850c8f..39c14459 100644 --- a/version-history.md +++ b/version-history.md @@ -1,6 +1,6 @@ ## Version history - * 1.0.6 + * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. * 1.0.5 Improve indexed mesh performance. * 1.0.4 WebGL 2 support. Fix WebGL shader warnings. * 1.0.3 Add RenderPass.blit(). Add depth/stencil as Texture type and add support for depth attachment in Framebuffer. From 8cd2743c0d9f3053af626f086429f6c9e508d2d4 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Wed, 14 Mar 2018 11:06:58 +0100 Subject: [PATCH 04/12] 1.0.6 Remove imgui.ini --- imgui.ini | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 imgui.ini diff --git a/imgui.ini b/imgui.ini deleted file mode 100644 index 8ef0db16..00000000 --- a/imgui.ini +++ /dev/null @@ -1,30 +0,0 @@ -[Window][Debug##Default] -Pos=323,277 -Size=455,324 -Collapsed=0 - -[Window][PBR] -Pos=0,0 -Size=266,600 -Collapsed=0 - -[Window][SRE Renderer] -Pos=45,28 -Size=744,811 -Collapsed=0 - -[Window][Standard] -Pos=63,29 -Size=680,544 -Collapsed=0 - -[Window][Unlit] -Pos=60,60 -Size=913,610 -Collapsed=0 - -[Window][StandardBlinnPhong] -Pos=668,175 -Size=819,638 -Collapsed=0 - From c7dde4ec4d124bbee11576bfc51f371e4652706e Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Wed, 14 Mar 2018 11:07:49 +0100 Subject: [PATCH 05/12] 1.0.6 Remove imgui.ini --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f9046912..c003afaf 100644 --- a/.gitignore +++ b/.gitignore @@ -138,4 +138,5 @@ App_Data/*.mdf App_Data/*.ldf .idea/ -project/ \ No newline at end of file +project/ +imgui.ini \ No newline at end of file From 76d15b056168cd3d38ea24a9c85367041835f156 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Wed, 14 Mar 2018 11:26:25 +0100 Subject: [PATCH 06/12] Inspector: Navigate mesh data (vertex attributes). --- src/sre/Inspector.cpp | 17 +++++++++++++++-- version-history.md | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/sre/Inspector.cpp b/src/sre/Inspector.cpp index 84c6b657..19ece1be 100644 --- a/src/sre/Inspector.cpp +++ b/src/sre/Inspector.cpp @@ -181,8 +181,21 @@ namespace sre { auto offset = att.second.offset; auto offsetStr = std::to_string(offset); ImGui::LabelText("offset", offsetStr.c_str()); + static int vertexOffset = 0; + if (ImGui::Button("<<")){ + vertexOffset = 0; + } + ImGui::SameLine(); + if (ImGui::Button("<")){ + vertexOffset = std::max(0,vertexOffset-5); + } + ImGui::SameLine(); + if (ImGui::Button(">")){ + vertexOffset = std::min(vertexOffset+5,mesh->vertexCount-(mesh->vertexCount%5)); + } + if (dataType == GL_INT){ - for (int j=0;jvertexCount); j++){ + for (int j=vertexOffset;jvertexCount); j++){ std::string value = ""; for (int i=0;itotalBytesPerVertex)/sizeof(float)]; @@ -194,7 +207,7 @@ namespace sre { ImGui::LabelText(label.c_str(), value.c_str()); } } else { - for (int j=0;jvertexCount); j++){ + for (int j=vertexOffset;jvertexCount); j++){ std::string value = ""; for (int i=0;itotalBytesPerVertex)/sizeof(float)]; diff --git a/version-history.md b/version-history.md index 39c14459..099045b0 100644 --- a/version-history.md +++ b/version-history.md @@ -1,6 +1,6 @@ ## Version history - * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. + * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. Inspector: Navigate mesh data (vertex attributes). * 1.0.5 Improve indexed mesh performance. * 1.0.4 WebGL 2 support. Fix WebGL shader warnings. * 1.0.3 Add RenderPass.blit(). Add depth/stencil as Texture type and add support for depth attachment in Framebuffer. From 27e92236eb1188eb41ebfe9169d3b1d23bd8d69a Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Thu, 15 Mar 2018 13:59:46 +0100 Subject: [PATCH 07/12] Improve framebuffer depth on WebGL/ES --- src/sre/Framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sre/Framebuffer.cpp b/src/sre/Framebuffer.cpp index fbc7e549..22bba9b1 100644 --- a/src/sre/Framebuffer.cpp +++ b/src/sre/Framebuffer.cpp @@ -198,7 +198,7 @@ namespace sre{ glGenRenderbuffers(1,&framebuffer->renderBufferDepth); // Create a renderbuffer object glBindRenderbuffer(GL_RENDERBUFFER, framebuffer->renderBufferDepth); glRenderbufferStorage(GL_RENDERBUFFER, - renderInfo().graphicsAPIVersionMinor<=2?GL_DEPTH_COMPONENT16:GL_DEPTH_COMPONENT24 + renderInfo().graphicsAPIVersionMajor<=2?GL_DEPTH_COMPONENT16:GL_DEPTH_COMPONENT24 , size.x, size.y); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, From 30f18814aee3165afd7df1903a76bb60bc8823ff Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Thu, 15 Mar 2018 14:18:50 +0100 Subject: [PATCH 08/12] Fix binding of integer attributes --- em-build.sh | 2 +- include/sre/Mesh.hpp | 2 +- include/sre/Renderer.hpp | 2 +- src/sre/Mesh.cpp | 17 +++++++++++++++-- src/sre/Shader.cpp | 6 ++++-- test/custom-mesh-layout-ints.cpp | 4 ++++ version-history.md | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/em-build.sh b/em-build.sh index a6b961de..911a7d68 100755 --- a/em-build.sh +++ b/em-build.sh @@ -8,7 +8,7 @@ fi source ${EMSDK}/emsdk_env.sh -for FILENAME in multiple-materials multiple-lights imgui-color-test pbr-test custom-mesh-layout-default-values imgui_demo multi-cameras particle-sprite particle-test polygon-offset-example spinning-sphere-cubemap sprite-test static_vertex_attribute texture-test +for FILENAME in custom-mesh-layout-ints multiple-materials multiple-lights imgui-color-test pbr-test custom-mesh-layout-default-values imgui_demo multi-cameras particle-sprite particle-test polygon-offset-example spinning-sphere-cubemap sprite-test static_vertex_attribute texture-test do echo $FILENAME emcc -Iinclude src/imgui/imgui.cpp \ diff --git a/include/sre/Mesh.hpp b/include/sre/Mesh.hpp index 6c309f07..13ff5087 100755 --- a/include/sre/Mesh.hpp +++ b/include/sre/Mesh.hpp @@ -65,7 +65,7 @@ namespace sre { MeshBuilder& withAttribute(std::string name, const std::vector &values); // Set a named vertex attribute of vec2 MeshBuilder& withAttribute(std::string name, const std::vector &values); // Set a named vertex attribute of vec3 MeshBuilder& withAttribute(std::string name, const std::vector &values); // Set a named vertex attribute of vec4 - MeshBuilder& withAttribute(std::string name, const std::vector &values);// Set a named vertex attribute of i32vec4 + MeshBuilder& withAttribute(std::string name, const std::vector &values);// Set a named vertex attribute of i32vec4. On platforms not supporting i32vec4 the values are converted to vec4 // other MeshBuilder& withName(const std::string& name); // Defines the name of the mesh diff --git a/include/sre/Renderer.hpp b/include/sre/Renderer.hpp index f95eb24b..4d9b4e98 100755 --- a/include/sre/Renderer.hpp +++ b/include/sre/Renderer.hpp @@ -89,7 +89,7 @@ namespace sre { int getMaxSceneLights(); // Get maximum amout of scenelights per object - DEPRECATED("Use sre::renderInfo() instead of getRenderInfo()") + DEPRECATED("Use sre::renderInfo() instead of Renderer::getRenderInfo()") const RenderInfo& getRenderInfo(); // Get info about the renderer private: int maxSceneLights = 4; // Maximum of scene lights diff --git a/src/sre/Mesh.cpp b/src/sre/Mesh.cpp index fbbf7718..1934ca31 100755 --- a/src/sre/Mesh.cpp +++ b/src/sre/Mesh.cpp @@ -189,7 +189,11 @@ namespace sre { ); if (attributeFoundInMesh && equalType && shaderAttribute.second.arraySize == 1) { glEnableVertexAttribArray(shaderAttribute.second.position); - glVertexAttribPointer(shaderAttribute.second.position, meshAttribute->second.elementCount, meshAttribute->second.dataType, GL_FALSE, totalBytesPerVertex, BUFFER_OFFSET(meshAttribute->second.offset)); + if ((shaderAttribute.second.type >= GL_INT_VEC2 && shaderAttribute.second.type <= GL_INT_VEC4 && shaderAttribute.second.type>= meshAttribute->second.attributeType)){ + glVertexAttribIPointer(shaderAttribute.second.position, meshAttribute->second.elementCount, meshAttribute->second.dataType, totalBytesPerVertex, BUFFER_OFFSET(meshAttribute->second.offset)); + } else { + glVertexAttribPointer(shaderAttribute.second.position, meshAttribute->second.elementCount, meshAttribute->second.dataType, GL_FALSE, totalBytesPerVertex, BUFFER_OFFSET(meshAttribute->second.offset)); + } vertexAttribArray++; } else { assert(shaderAttribute.second.arraySize == 1 && "Constant vertex attributes not supported as arrays"); @@ -865,7 +869,16 @@ namespace sre { } Mesh::MeshBuilder &Mesh::MeshBuilder::withAttribute(std::string name, const std::vector &values) { - if (updateMesh != nullptr && attributesIVec4.find(name) == attributesIVec4.end()){ + auto& info = renderInfo(); + if (info.graphicsAPIVersionES && info.graphicsAPIVersionMajor <= 2){ + LOG_INFO("Converting attribute %s to vec4. ES %i Version %i",name.c_str(),info.graphicsAPIVersionES,info.graphicsAPIVersionMajor); + std::vector convertedVec4(values.size(), glm::vec4(0)); + for (int i=0;i bool map_compare (Map const &lhs, Map const &rhs) { @@ -599,15 +597,18 @@ namespace sre { LOG_ERROR("Invalid blend value - was %i",(int)blend); break; } + auto& info = renderInfo(); if (offset.x == 0 && offset.y==0){ glDisable(GL_POLYGON_OFFSET_FILL); #ifndef GL_ES_VERSION_2_0 + // GL_POLYGON_OFFSET_LINE and GL_POLYGON_OFFSET_POINT nor defined in ES 2.x or ES 3.x glDisable(GL_POLYGON_OFFSET_LINE); glDisable(GL_POLYGON_OFFSET_POINT); #endif } else { glEnable(GL_POLYGON_OFFSET_FILL); #ifndef GL_ES_VERSION_2_0 + // GL_POLYGON_OFFSET_LINE and GL_POLYGON_OFFSET_POINT nor defined in ES 2.x or ES 3.x glEnable(GL_POLYGON_OFFSET_LINE); glEnable(GL_POLYGON_OFFSET_POINT); #endif @@ -907,6 +908,7 @@ namespace sre { if (parent){ return parent->getAllSpecializationConstants(); } + static std::regex SPECIALIZATION_CONSTANT_PATTERN("(S_[A-Z_0-9]+)"); std::set res; for (auto& source : shaderSources){ string s = getSource(source.second); diff --git a/test/custom-mesh-layout-ints.cpp b/test/custom-mesh-layout-ints.cpp index 615afe64..450a61e0 100644 --- a/test/custom-mesh-layout-ints.cpp +++ b/test/custom-mesh-layout-ints.cpp @@ -36,7 +36,11 @@ class CustomMeshLayoutExample{ .build(); std::string vertexShaderSource = R"(#version 140 +#if defined(GL_ES) && __VERSION__ == 100 +in vec4 posxyzw; +#else in ivec4 posxyzw; +#endif in vec4 color; out vec4 vColor; diff --git a/version-history.md b/version-history.md index 099045b0..4ac22e5f 100644 --- a/version-history.md +++ b/version-history.md @@ -1,6 +1,6 @@ ## Version history - * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. Inspector: Navigate mesh data (vertex attributes). + * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. Inspector: Navigate mesh data (vertex attributes). Fix binding of integer attributes. * 1.0.5 Improve indexed mesh performance. * 1.0.4 WebGL 2 support. Fix WebGL shader warnings. * 1.0.3 Add RenderPass.blit(). Add depth/stencil as Texture type and add support for depth attachment in Framebuffer. From b881b30584d415cc28256cedfb33b723b50e1569 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Thu, 15 Mar 2018 15:15:16 +0100 Subject: [PATCH 09/12] Matrix arrays as uniforms. --- include/sre/Material.hpp | 6 +- src/sre/Material.cpp | 50 ++++++++++++++- test/CMakeLists.txt | 2 +- test/matrix-uniforms.cpp | 128 +++++++++++++++++++++++++++++++++++++++ version-history.md | 2 +- 5 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 test/matrix-uniforms.cpp diff --git a/include/sre/Material.hpp b/include/sre/Material.hpp index 7420169a..f23b5887 100755 --- a/include/sre/Material.hpp +++ b/include/sre/Material.hpp @@ -78,7 +78,9 @@ namespace sre { bool set(std::string uniformName, glm::vec4 value); bool set(std::string uniformName, float value); - bool set(std::string uniformName, std::shared_ptr); + bool set(std::string uniformName, std::shared_ptr value); + bool set(std::string uniformName, std::shared_ptr> value); + bool set(std::string uniformName, std::shared_ptr> value); bool set(std::string uniformName, Color value); template @@ -98,6 +100,8 @@ namespace sre { std::vector>> textureValues; std::vector> vectorValues; + std::vector>>> mat4Values; + std::vector>>> mat3Values; std::vector> floatValues; friend class Shader; diff --git a/src/sre/Material.cpp b/src/sre/Material.cpp index ebf215ce..1d48eb18 100755 --- a/src/sre/Material.cpp +++ b/src/sre/Material.cpp @@ -33,12 +33,22 @@ namespace sre { glUniform1i(t.id, textureSlot); textureSlot++; } - for (auto t : vectorValues) { + for (auto& t : vectorValues) { glUniform4fv(t.id, 1, glm::value_ptr(t.value)); } - for (auto t : floatValues) { + for (auto& t : floatValues) { glUniform1f(t.id, t.value); } + for (auto& t : mat3Values) { + if (t.value.get()) { + glUniformMatrix3fv(t.id, static_cast(t.value->size()), GL_FALSE, glm::value_ptr((*t.value)[0])); + } + } + for (auto& t : mat4Values) { + if (t.value.get()){ + glUniformMatrix4fv(t.id, static_cast(t.value->size()), GL_FALSE, glm::value_ptr((*t.value)[0])); + } + } } std::shared_ptr Material::getShader() { @@ -86,6 +96,20 @@ namespace sre { floatValues.push_back(uniform); } break; + case UniformType::Mat3: + { + Uniform>> uniform; + uniform.id = u.id; + mat3Values.push_back(uniform); + } + break; + case UniformType::Mat4: + { + Uniform>> uniform; + uniform.id = u.id; + mat4Values.push_back(uniform); + } + break; default: LOG_ERROR("'%s' Unsupported uniform type: %i. Only Vec4, Texture, TextureCube and Float is supported.", u.name.c_str(), (int)u.type); break; @@ -136,6 +160,28 @@ namespace sre { return false; } + bool Material::set(std::string uniformName, std::shared_ptr> value){ + auto type = shader->getUniformType(uniformName); + for (auto & v : mat3Values){ + if (v.id==type.id){ + v.value = value; + return true; + } + } + return false; + } + + bool Material::set(std::string uniformName, std::shared_ptr> value){ + auto type = shader->getUniformType(uniformName); + for (auto & v : mat4Values){ + if (v.id==type.id){ + v.value = value; + return true; + } + } + return false; + } + bool Material::set(std::string uniformName, Color value){ auto type = shader->getUniformType(uniformName); for (auto & v : vectorValues){ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e466e809..4f3de2c6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ # List of single-file tests -SET(scr_files custom-mesh-layout-ints multiple-materials render-depth spinning-sphere-cubemap particle-test polygon-offset-example multiple-lights particle-sprite sprite-test multi-cameras static_vertex_attribute custom-mesh-layout-default-values imgui_demo texture-test screen-point-to-ray pbr-test gamma primitives-test imgui-color-test) +SET(scr_files matrix-uniforms custom-mesh-layout-ints multiple-materials render-depth spinning-sphere-cubemap particle-test polygon-offset-example multiple-lights particle-sprite sprite-test multi-cameras static_vertex_attribute custom-mesh-layout-default-values imgui_demo texture-test screen-point-to-ray pbr-test gamma primitives-test imgui-color-test) # Create custom build targets FOREACH(scr_file ${scr_files}) diff --git a/test/matrix-uniforms.cpp b/test/matrix-uniforms.cpp new file mode 100644 index 00000000..ad463890 --- /dev/null +++ b/test/matrix-uniforms.cpp @@ -0,0 +1,128 @@ +#include + +#include "sre/Texture.hpp" +#include "sre/Renderer.hpp" +#include "sre/Material.hpp" +#include "sre/Inspector.hpp" + +#include +#include +#include +#include +#include + +using namespace sre; + +class CustomMeshLayoutExample{ +public: + CustomMeshLayoutExample(){ + r.init(); + + std::vector positions({ + {0, 1,0}, + {0, 0,0}, + {1, 0,0} + }); + std::vector colors({ + {1, 0,0,1}, + {0, 1,0,1}, + {0, 0,1,1}, + + }); + + mesh = Mesh::create() + .withPositions(positions) + .withAttribute("color",colors) + .build(); + + std::string vertexShaderSource = R"(#version 140 +in vec4 position; +in vec4 color; +out vec4 vColor; + +uniform mat4 customTransform4[2]; +uniform float customTransformIndex; +uniform mat4 g_model; +uniform mat4 g_view; +uniform mat4 g_projection; + +void main(void) { + int id = int(customTransformIndex); + gl_Position = g_projection * g_view * g_model * customTransform4[id]*vec4(position); + vColor = color; +} +)"; + std::string fragmentShaderSource = R"(#version 140 +out vec4 fragColor; +in vec4 vColor; + +void main(void) +{ + fragColor = vColor; +} +)"; + + mat1 = Shader::create() + .withSourceString(vertexShaderSource,ShaderType::Vertex) + .withSourceString(fragmentShaderSource, ShaderType::Fragment) + .build()->createMaterial(); + + std::string info; + bool isValid = mat1->getShader()->validateMesh(mesh.get(), info); + std::cout << "Mesh is valid: "<>(); + for (int i=0;i<2;i++){ + mats4->emplace_back(1); + } + + r.frameRender = [&](){ + render(); + }; + r.startEventLoop(); + } + + void render(){ + auto rp = RenderPass::create() + .withCamera(camera) + .withClearColor(true,{1,0,0,1}) + .build(); + + ImGui::DragInt("Id ",&id, 1,0,1); + ImGui::DragFloat3("Offset ",&offset[id].x,0.1f); + ImGui::DragFloat("Rotate ",&rotate[id],0.1f); + + // update matrix array + for (int i=0;i<2;i++){ + (*mats4)[i] = glm::translate(offset[i]) * glm::rotate(rotate[i],glm::vec3(0,0,1)); + } + // update uniforms + bool setIndex = mat1->set("customTransformIndex",(float)id); + bool setMatrix = mat1->set("customTransform4",mats4); + + rp.draw(mesh, glm::mat4(1), mat1); + + static Inspector inspector; + inspector.update(); + inspector.gui(); + + } +private: + float time; + SDLRenderer r; + Camera camera; + std::shared_ptr mesh; + std::shared_ptr mat1; + std::shared_ptr> mats4; + int id = 0; + glm::vec3 offset[2] = {{0,0,0},{0,0,0}}; + float rotate[2] = {0,0}; + +}; + +int main() { + new CustomMeshLayoutExample(); + + return 0; +} + diff --git a/version-history.md b/version-history.md index 4ac22e5f..24df7249 100644 --- a/version-history.md +++ b/version-history.md @@ -1,6 +1,6 @@ ## Version history - * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. Inspector: Navigate mesh data (vertex attributes). Fix binding of integer attributes. + * 1.0.6 Inspector: Correctly show integer attributes in Mesh and Shader. Inspector: Navigate mesh data (vertex attributes). Fix binding of integer attributes. Matrix arrays as uniforms. * 1.0.5 Improve indexed mesh performance. * 1.0.4 WebGL 2 support. Fix WebGL shader warnings. * 1.0.3 Add RenderPass.blit(). Add depth/stencil as Texture type and add support for depth attachment in Framebuffer. From 574d9a40b0c4e92b127778c4b84e02b0d8c6965d Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Thu, 15 Mar 2018 15:21:23 +0100 Subject: [PATCH 10/12] Matrix arrays as uniforms. --- em-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/em-build.sh b/em-build.sh index 911a7d68..123b103b 100755 --- a/em-build.sh +++ b/em-build.sh @@ -8,7 +8,7 @@ fi source ${EMSDK}/emsdk_env.sh -for FILENAME in custom-mesh-layout-ints multiple-materials multiple-lights imgui-color-test pbr-test custom-mesh-layout-default-values imgui_demo multi-cameras particle-sprite particle-test polygon-offset-example spinning-sphere-cubemap sprite-test static_vertex_attribute texture-test +for FILENAME in matrix-uniforms custom-mesh-layout-ints multiple-materials multiple-lights imgui-color-test pbr-test custom-mesh-layout-default-values imgui_demo multi-cameras particle-sprite particle-test polygon-offset-example spinning-sphere-cubemap sprite-test static_vertex_attribute texture-test do echo $FILENAME emcc -Iinclude src/imgui/imgui.cpp \ From 54f9d912d95dcbcf81e7bd9c6526eb79559c917c Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Sat, 17 Mar 2018 09:30:16 +0100 Subject: [PATCH 11/12] Update TextEditor to commit 6c69c306da0afb6c0b7ea51ec504aa0aae348aad --- include/TextEditor.h | 2 +- src/imgui/TextEditor.cpp | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/TextEditor.h b/include/TextEditor.h index 85c6424e..6d6eec9c 100755 --- a/include/TextEditor.h +++ b/include/TextEditor.h @@ -11,7 +11,7 @@ #include "imgui.h" /** - * https://github.com/BalazsJako/ImGuiColorTextEdit + * https://github.com/BalazsJako/ImGuiColorTextEdit (commit 6c69c306da0afb6c0b7ea51ec504aa0aae348aad) * * MIT License * diff --git a/src/imgui/TextEditor.cpp b/src/imgui/TextEditor.cpp index 4ce42f60..d03cc17b 100755 --- a/src/imgui/TextEditor.cpp +++ b/src/imgui/TextEditor.cpp @@ -7,7 +7,7 @@ #include "TextEditor.h" /** - * https://github.com/BalazsJako/ImGuiColorTextEdit + * https://github.com/BalazsJako/ImGuiColorTextEdit (commit 6c69c306da0afb6c0b7ea51ec504aa0aae348aad) */ static const int cTextStart = 7; @@ -104,7 +104,7 @@ TextEditor::Coordinates TextEditor::SanitizeCoordinates(const Coordinates & aVal auto line = aValue.mLine; auto column = aValue.mColumn; - if (line >= mLines.size()) + if (line >= (int)mLines.size()) { line = (int)mLines.size() - 1; column = mLines.empty() ? 0 : (int)mLines[line].size(); @@ -657,7 +657,8 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder) } } - snprintf(buf, 16, "%6d", lineNo + 1); + auto chars = snprintf(buf, 16, "%6d", lineNo + 1); + assert(chars >= 0 && chars < 16); drawList->AddText(ImVec2(lineStartScreenPos.x /*+ mCharAdvance.x * 1*/, lineStartScreenPos.y), mPalette[(int)PaletteIndex::LineNumber], buf); if (mState.mCursorPosition.mLine == lineNo) @@ -1027,8 +1028,11 @@ void TextEditor::MoveRight(int aAmount, bool aSelect, bool aWordMode) auto& line = mLines[mState.mCursorPosition.mLine]; if (mState.mCursorPosition.mColumn >= (int)line.size()) { - mState.mCursorPosition.mLine = std::max(0, std::min((int)mLines.size() - 1, mState.mCursorPosition.mLine + 1)); - mState.mCursorPosition.mColumn = 0; + if (mState.mCursorPosition.mLine < (int)mLines.size() - 1) + { + mState.mCursorPosition.mLine = std::max(0, std::min((int)mLines.size() - 1, mState.mCursorPosition.mLine + 1)); + mState.mCursorPosition.mColumn = 0; + } } else { From 0eaaeb34308b178a57b894e76aaeccee127cf830 Mon Sep 17 00:00:00 2001 From: Morten Nobel-Joergensen Date: Sat, 17 Mar 2018 21:42:50 +0100 Subject: [PATCH 12/12] Add heavy 64k benchmark --- em-build.sh | 2 +- include/sre/SDLRenderer.hpp | 2 + src/sre/SDLRenderer.cpp | 6 + test/CMakeLists.txt | 2 +- test/benchmark64k-heavy.cpp | 214 ++++++++++++++++++++++++++++++++++++ 5 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 test/benchmark64k-heavy.cpp diff --git a/em-build.sh b/em-build.sh index 123b103b..82d3ae40 100755 --- a/em-build.sh +++ b/em-build.sh @@ -8,7 +8,7 @@ fi source ${EMSDK}/emsdk_env.sh -for FILENAME in matrix-uniforms custom-mesh-layout-ints multiple-materials multiple-lights imgui-color-test pbr-test custom-mesh-layout-default-values imgui_demo multi-cameras particle-sprite particle-test polygon-offset-example spinning-sphere-cubemap sprite-test static_vertex_attribute texture-test +for FILENAME in benchmark64k-heavy matrix-uniforms custom-mesh-layout-ints multiple-materials multiple-lights imgui-color-test pbr-test custom-mesh-layout-default-values imgui_demo multi-cameras particle-sprite particle-test polygon-offset-example spinning-sphere-cubemap sprite-test static_vertex_attribute texture-test do echo $FILENAME emcc -Iinclude src/imgui/imgui.cpp \ diff --git a/include/sre/SDLRenderer.hpp b/include/sre/SDLRenderer.hpp index 60d4e790..77303dbc 100755 --- a/include/sre/SDLRenderer.hpp +++ b/include/sre/SDLRenderer.hpp @@ -101,6 +101,8 @@ class DllExport SDLRenderer { SDL_Window *getSDLWindow(); // Get a pointer to SDL_Window static SDLRenderer* instance; // Singleton reference to the engine after initialization. + + glm::vec3 getLastFrameStats(); // Returns delta time for last frame wrt event, update and render private: void frame(float deltaTimeSec); Renderer* r; diff --git a/src/sre/SDLRenderer.cpp b/src/sre/SDLRenderer.cpp index a3136261..eafb890e 100755 --- a/src/sre/SDLRenderer.cpp +++ b/src/sre/SDLRenderer.cpp @@ -315,6 +315,12 @@ namespace sre{ return SDLRenderer::InitBuilder(this); } + glm::vec3 SDLRenderer::getLastFrameStats() { + return { + deltaTimeEvent,deltaTimeUpdate,deltaTimeRender + }; + } + SDLRenderer::InitBuilder::~InitBuilder() { build(); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4f3de2c6..c83f0e84 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,5 @@ # List of single-file tests -SET(scr_files matrix-uniforms custom-mesh-layout-ints multiple-materials render-depth spinning-sphere-cubemap particle-test polygon-offset-example multiple-lights particle-sprite sprite-test multi-cameras static_vertex_attribute custom-mesh-layout-default-values imgui_demo texture-test screen-point-to-ray pbr-test gamma primitives-test imgui-color-test) +SET(scr_files benchmark64k-heavy matrix-uniforms custom-mesh-layout-ints multiple-materials render-depth spinning-sphere-cubemap particle-test polygon-offset-example multiple-lights particle-sprite sprite-test multi-cameras static_vertex_attribute custom-mesh-layout-default-values imgui_demo texture-test screen-point-to-ray pbr-test gamma primitives-test imgui-color-test) # Create custom build targets FOREACH(scr_file ${scr_files}) diff --git a/test/benchmark64k-heavy.cpp b/test/benchmark64k-heavy.cpp new file mode 100644 index 00000000..abaf873b --- /dev/null +++ b/test/benchmark64k-heavy.cpp @@ -0,0 +1,214 @@ +#include +#include +#include + +#include "sre/Texture.hpp" +#include "sre/Renderer.hpp" +#include "sre/Material.hpp" +#include "sre/SDLRenderer.hpp" + +#include +#include +#include +#include + +const int BOX_GRID_DIM = 40; +const int BENCHMARK_SIZE = 40; + +using namespace sre; + +float renderTimeGetter(void* data, int offset){ + float* floatData = static_cast(data); + int id = (int)cbrtf((float)offset); + return floatData[id]; +} +// +class Benchmark64KExample { +public: + Benchmark64KExample() { + r.init(); + + camera = new Camera(); + camera->setPerspectiveProjection(60,0.1,100); + + worldLights.addLight(Light::create().withDirectionalLight(glm::vec3(1,1,1)).withColor(Color(1,1,1),1).build()); + renderTime.resize(BOX_GRID_DIM+1,0); + stateChanges.resize(BOX_GRID_DIM+1,0); + drawCalls.resize(BOX_GRID_DIM+1,0); + meshes = { + Mesh::create().withCube(0.25f).build(), + Mesh::create().withSphere().build(), + Mesh::create().withTorus().build(), + Mesh::create().withQuad().build(), + Mesh::create().withCube(0.35f).build(), + }; + + + materials = { + Shader::getUnlit()->createMaterial(), + Shader::getStandardBlinnPhong()->createMaterial(), + Shader::getStandardPBR()->createMaterial(), + Shader::getUnlit()->createMaterial(), + Shader::getStandardBlinnPhong()->createMaterial(), + Shader::getStandardPBR()->createMaterial(), + Shader::getUnlit()->createMaterial(), + }; + + for (int i = 0;isetTexture(Texture::create().withFile("examples_data/test.png").withGenerateMipmaps(true).build()); + } else { + materials[i]->setTexture(Texture::create().withFile("examples_data/cartman.png").withGenerateMipmaps(true).build()); + } + } + + int boxI = 0; + float offset = -(gridSize / 2.0f); + for (int i = 0; i < BOX_GRID_DIM; ++i) { + for (int j = 0; j < BOX_GRID_DIM; ++j) { + for (int k = 0; k < BOX_GRID_DIM; ++k) { + box[i][j][k] = { + glm::rotate((float) (boxI / M_PI), glm::vec3(1,1,1)), + glm::translate(glm::vec3(i + offset, j + offset, k + offset)) + }; + boxI++; + } + } + } + r.frameUpdate = [&](float delta){ + update(delta); + }; + r.frameRender = [&](){ + render(); + }; + + r.startEventLoop(); + } + void update(float delta){ + static float totalTime = 0; + eyeRotation += 0.002; + eyePosition[0] = (float) (sin(eyeRotation) * eyeRadius); + eyePosition[2] = (float) (cos(eyeRotation) * eyeRadius); + if (cameraInCenter){ + camera->lookAt( {0, 0, 0}, glm::normalize(eyePosition),{0, 1, 0}); + } else { + camera->lookAt(eyePosition, {0, 0, 0}, {0, 1, 0}); + } + totalTime += delta; + for (int i = 0; i < gridSize; ++i) { + for (int j = 0; j < gridSize; ++j) { + for (int k = 0; k < gridSize; ++k) { + auto & boxRef = box[i][j][k]; + // update rotation + boxRef.rotationMatrix = glm::rotate(glm::mat4(1),0.02f*totalTime, glm::vec3(0,1,0)); + modelMatrix[i][j][k] = boxRef.translationMatrix * boxRef.rotationMatrix; + } + } + } + } + + void render(){ + if (benchmarkCount >=0){ + if (benchmarkCount>0 && benchmarkCount-1 < renderTime.size()){ + //Renderer::instance->getRenderStats().drawCalls; + renderTime[benchmarkCount-1] = SDLRenderer::instance->getLastFrameStats().z; + stateChanges[benchmarkCount-1] = Renderer::instance->getRenderStats().stateChangesMaterial + Renderer::instance->getRenderStats().stateChangesShader + Renderer::instance->getRenderStats().stateChangesMesh; + drawCalls[benchmarkCount-1] = Renderer::instance->getRenderStats().drawCalls; + } + if (benchmarkCount+1 == BOX_GRID_DIM){ + benchmarkCount = -1; + gridSize = BOX_GRID_DIM/3; + } else { + benchmarkCount++; + gridSize = benchmarkCount; + } + + } + auto renderPass = RenderPass::create() + .withCamera(*camera) + .withWorldLights(&worldLights) + .withClearColor(true, {0, 0, 0, 1}) + .build(); + int id=0; + for (int i = 0; i < gridSize; ++i) { + for (int j = 0; j < gridSize; ++j) { + for (int k = 0; k < gridSize; ++k) { + renderPass.draw(meshes[id%meshes.size()], modelMatrix[i][j][k], materials[id%materials.size()]); + id++; + } + } + } + i++; + static Inspector inspector; + inspector.update(); + + bool gridChanged = ImGui::SliderInt("Grid size",&gridSize,1,BOX_GRID_DIM); + if (gridChanged){ + float offset = -(gridSize / 2.0f); + for (int i = 0; i < gridSize; ++i) { + for (int j = 0; j < gridSize; ++j) { + for (int k = 0; k < gridSize; ++k) { + auto & boxRef = box[i][j][k]; + // update rotation + boxRef.translationMatrix = glm::translate(glm::vec3(i + offset, j + offset, k + offset)); + } + } + } + + } + ImGui::Checkbox("Camera in center",&cameraInCenter); + + if (benchmarkCount >= 0){ + ImGui::LabelText("","Benchmark running"); + } else { + if (ImGui::Button("Start benchmark")){ + benchmarkCount = 1; + for (auto & v : renderTime){ + v = 0; + } + for (auto &v : stateChanges){ + v = 0; + } + for (auto &v : drawCalls){ + v = 0; + } + + } + } + + + ImGui::PlotLines("Objects/Render time",&renderTimeGetter,renderTime.data(),(BENCHMARK_SIZE-1)*(BENCHMARK_SIZE-1)*(BENCHMARK_SIZE-1), 0, "Render time", FLT_MAX,FLT_MAX,ImVec2(ImGui::CalcItemWidth(),150)); + ImGui::PlotLines("Objects/State changes",&renderTimeGetter,stateChanges.data(),(BENCHMARK_SIZE-1)*(BENCHMARK_SIZE-1)*(BENCHMARK_SIZE-1), 0, "State changes", FLT_MAX,FLT_MAX,ImVec2(ImGui::CalcItemWidth(),150)); + ImGui::PlotLines("Objects/Draw calls",&renderTimeGetter,drawCalls.data(),(BENCHMARK_SIZE-1)*(BENCHMARK_SIZE-1)*(BENCHMARK_SIZE-1), 0, "Draw calls", FLT_MAX,FLT_MAX,ImVec2(ImGui::CalcItemWidth(),150)); + inspector.gui(); + + } +private: + int gridSize = BOX_GRID_DIM/2; + float eyeRadius = 30; + float eyeRotation = 0; + glm::vec3 eyePosition = {0, eyeRadius, 0}; + bool cameraInCenter = false; + SDLRenderer r; + Camera *camera; + WorldLights worldLights; + std::vector> meshes; + std::vector> materials; + std::vector renderTime; + std::vector stateChanges; + std::vector drawCalls; + int benchmarkCount = -1; + int i=0; + struct Box{ + glm::mat4 rotationMatrix; + glm::mat4 translationMatrix; + } box[BOX_GRID_DIM][BOX_GRID_DIM][BOX_GRID_DIM]; + glm::mat4 modelMatrix[BOX_GRID_DIM][BOX_GRID_DIM][BOX_GRID_DIM]; + +}; + +int main() { + new Benchmark64KExample(); + return 0; +}