diff --git a/cw_8/grk-cw8.vcxproj b/cw_8/grk-cw8.vcxproj index 5a10a58..d712d67 100644 --- a/cw_8/grk-cw8.vcxproj +++ b/cw_8/grk-cw8.vcxproj @@ -37,6 +37,8 @@ + + diff --git a/cw_8/grk-cw8.vcxproj.filters b/cw_8/grk-cw8.vcxproj.filters index 23c9dba..a93d698 100644 --- a/cw_8/grk-cw8.vcxproj.filters +++ b/cw_8/grk-cw8.vcxproj.filters @@ -103,5 +103,11 @@ Shader Files + + Shader Files + + + Shader Files + \ No newline at end of file diff --git a/cw_8/shaders/part.frag b/cw_8/shaders/part.frag new file mode 100644 index 0000000..e69de29 diff --git a/cw_8/shaders/part.vert b/cw_8/shaders/part.vert new file mode 100644 index 0000000..e69de29 diff --git a/cw_8/src/projekt.hpp b/cw_8/src/projekt.hpp index c3869dd..e714c37 100644 --- a/cw_8/src/projekt.hpp +++ b/cw_8/src/projekt.hpp @@ -12,6 +12,7 @@ GLuint program; GLuint programSun; +GLuint programParticle; Core::Shader_Loader shaderLoader; @@ -82,12 +83,17 @@ glm::vec3 cameraDir; glm::vec3 spaceshipPos = glm::vec3(-4.0f, 0.0f, 0.0f); glm::vec3 spaceshipDir = glm::vec3(1.0f, 0.0f, 0.0f); +float lastTime = -1.f; +float deltaTime = 0.f; + //declarations of functions void loadModelToContext(std::string path, Core::RenderContext& context); void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow* window); void shutdown(GLFWwindow* window); +void updateDeltaTime(float time); + glm::mat4 createPerspectiveMatrix(); glm::mat4 createCameraMatrix(); @@ -102,6 +108,7 @@ void init(GLFWwindow* window) program = shaderLoader.CreateProgram("shaders/pbr.vert", "shaders/pbr.frag"); programSun = shaderLoader.CreateProgram("shaders/sun.vert", "shaders/sun.frag"); + //programParticle = shaderLoader.CreateProgram("shaders/part.vert", "shaders/part.frag"); //load models here @@ -168,6 +175,7 @@ void renderScene(GLFWwindow* window){ glUseProgram(program); float time = glfwGetTime(); + updateDeltaTime(time); //desired objects go here drawObjectSun(sunContext, glm::scale(glm::vec3(0.1f)) * glm::eulerAngleY(time/10)); @@ -208,7 +216,7 @@ void processInput(GLFWwindow* window) if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); - float cameraSpeed = 0.1f; + float cameraSpeed = 0.1f * deltaTime * 30; if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) spaceshipPos += cameraSpeed * spaceshipDir; if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) @@ -331,4 +339,15 @@ glm::mat4 createCameraMatrix() glm::mat4 cameraMatrix = cameraRotrationMatrix * glm::translate(-cameraPos); return cameraMatrix; +} + +void updateDeltaTime(float time) { + if (lastTime < 0) { + lastTime = time; + return; + } + + deltaTime = time - lastTime; + if (deltaTime > 0.1) deltaTime = 0.1; + lastTime = time; } \ No newline at end of file diff --git a/cw_8/textures/ship/albedo.png b/cw_8/textures/ship/albedo.png index 65b8e2d..68fc997 100644 Binary files a/cw_8/textures/ship/albedo.png and b/cw_8/textures/ship/albedo.png differ diff --git a/grk-cw.sln b/grk-cw.sln index 5351dca..124132f 100644 --- a/grk-cw.sln +++ b/grk-cw.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 17.1.32319.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw8", "cw_8\grk-cw8.vcxproj", "{6D813233-7D21-4888-944E-8E3CCAC3EFD3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw4", "..\cw 4\grk-cw4.vcxproj", "{D7858112-9412-4E7E-AB73-A911604592EC}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -17,10 +15,6 @@ Global {6D813233-7D21-4888-944E-8E3CCAC3EFD3}.Debug|x86.Build.0 = Debug|Win32 {6D813233-7D21-4888-944E-8E3CCAC3EFD3}.Release|x86.ActiveCfg = Release|Win32 {6D813233-7D21-4888-944E-8E3CCAC3EFD3}.Release|x86.Build.0 = Release|Win32 - {D7858112-9412-4E7E-AB73-A911604592EC}.Debug|x86.ActiveCfg = Debug|Win32 - {D7858112-9412-4E7E-AB73-A911604592EC}.Debug|x86.Build.0 = Debug|Win32 - {D7858112-9412-4E7E-AB73-A911604592EC}.Release|x86.ActiveCfg = Release|Win32 - {D7858112-9412-4E7E-AB73-A911604592EC}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE