@@ -332,14 +332,12 @@ void updateUniformBuffer() {
332332 static auto startTime = std::chrono::high_resolution_clock::now();
333333
334334 auto currentTime = std::chrono::high_resolution_clock::now();
335- float time = std::chrono::duration_cast< std::chrono::milliseconds >(currentTime - startTime).count() / 1000.0f ;
335+ float time = std::chrono::duration<float, std::chrono::seconds::period >(currentTime - startTime).count();
336336}
337337```
338338
339339The ` updateUniformBuffer ` function will start out with some logic to calculate
340- the time in seconds since rendering has started with millisecond accuracy. If
341- you need timing to be more precise, then you can use ` std::chrono::microseconds `
342- and divide by ` 1e6f ` , which is short for ` 1000000.0f ` .
340+ the time in seconds since rendering has started with floating point accuracy.
343341
344342We will now define the model, view and projection transformations in the
345343uniform buffer object. The model rotation will be a simple rotation around the
@@ -351,7 +349,7 @@ ubo.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0
351349```
352350
353351The `glm::rotate` function takes an existing transformation, rotation angle and
354- rotation axis as parameters. The `glm::mat4(1.0f)` constructor returns an
352+ rotation axis as parameters. The `glm::mat4(1.0f)` constructor returns an
355353identity matrix. Using a rotation angle of `time * glm::radians(90.0f)`
356354accomplishes the purpose of rotation 90 degrees per second.
357355
@@ -403,4 +401,4 @@ transformation data.
403401
404402[C++ code](/code/descriptor_layout.cpp) /
405403[Vertex shader](/code/shader_ubo.vert) /
406- [Fragment shader](/code/shader_ubo.frag)
404+ [Fragment shader](/code/shader_ubo.frag)
0 commit comments