|
@@ -26,7 +26,9 @@
|
|
|
#include <camera.h>
|
|
|
|
|
|
bool isRunning = true;
|
|
|
+
|
|
|
int previousFrameTime = 0;
|
|
|
+double deltaTime = 0;
|
|
|
|
|
|
typedef enum displayMode_t
|
|
|
{
|
|
@@ -43,7 +45,6 @@ bool doZBuffer = true;
|
|
|
enum displayMode_t currentDisplayMode = DISPLAY_MODE_SOLID;
|
|
|
matrix4_t projectionMatrix;
|
|
|
matrix4_t viewMatrix;
|
|
|
-
|
|
|
light_t globalLight;
|
|
|
double updateTime, renderTime, waitTime;
|
|
|
int trianglesCount, trianglesTotal;
|
|
@@ -197,16 +198,19 @@ void update()
|
|
|
{
|
|
|
SDL_Delay(timeToWait);
|
|
|
}
|
|
|
+ deltaTime = (SDL_GetTicks() - previousFrameTime) / 1000.0;
|
|
|
previousFrameTime = SDL_GetTicks();
|
|
|
|
|
|
waitTime = (waitTime + (getMicroSecTime() - ticks) / 1000.) / 2.0;
|
|
|
ticks = getMicroSecTime();
|
|
|
|
|
|
- //mesh.rotation.x += 0.02;
|
|
|
- mesh.translation.z = 4;
|
|
|
+ mesh.rotation.x += 0.6 * deltaTime;
|
|
|
+ mesh.rotation.y += 0.6 * deltaTime;
|
|
|
+ mesh.rotation.z += 0.6 * deltaTime;
|
|
|
+ mesh.translation.z = 5;
|
|
|
|
|
|
- camera.position.x += 0.008;
|
|
|
- camera.position.y += 0.008;
|
|
|
+ camera.position.x += 0.0 * deltaTime;
|
|
|
+ camera.position.y += 0.0 * deltaTime;
|
|
|
|
|
|
viewMatrix = mat4LookAt(camera.position, target, up);
|
|
|
|
|
@@ -380,7 +384,7 @@ void render()
|
|
|
drawText(5, 5, 0x11FF22, "Wait time: %02.2f ms", waitTime);
|
|
|
drawText(5, 17, 0x11FF22, "Update time: %02.2f ms", updateTime);
|
|
|
drawText(5, 29, 0x11FF22, "Render time: %02.2f ms", renderTime);
|
|
|
- drawText(5, 41, 0x11FF22, "FPS: %.2f", 1000 / (waitTime + updateTime + renderTime));
|
|
|
+ drawText(5, 41, 0x11FF22, "FPS: %.1f | dT: %.3f", 1000 / (waitTime + updateTime + renderTime), deltaTime);
|
|
|
drawText(5, 53, 0x11FF22, "Triangles: %d / %d", triangleCount, trianglesTotal);
|
|
|
drawText(5, 65, 0x11FF22, "Cull: %s | PeCo: %s | ZB: %s",
|
|
|
doNotCull?"N":"Y", doPerpectiveCorrection?"Y":"N", doZBuffer?"Y":"N");
|