mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-12-22 01:26:17 +01:00
Add FPS
This commit is contained in:
parent
d3e3112fdd
commit
4649c33832
1 changed files with 20 additions and 0 deletions
20
testSDL.c
20
testSDL.c
|
@ -6,6 +6,7 @@
|
|||
#include <SDL2/SDL.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
|
||||
//#define S3L_PRESET_HIGHEST_QUALITY
|
||||
|
||||
|
@ -164,6 +165,10 @@ else
|
|||
S3L_Transform3D modelTransform;
|
||||
S3L_DrawConfig conf;
|
||||
|
||||
clock_t nextT;
|
||||
|
||||
int fps = 0;
|
||||
|
||||
void draw()
|
||||
{
|
||||
S3L_newFrame();
|
||||
|
@ -181,6 +186,19 @@ void draw()
|
|||
|
||||
if (offScreenPixels > 0)
|
||||
printf("offscreen pixels: %d\n",offScreenPixels);
|
||||
|
||||
clock_t nowT = clock();
|
||||
|
||||
double timeDiff = ((double) (nowT - nextT)) / CLOCKS_PER_SEC;
|
||||
|
||||
fps++;
|
||||
|
||||
if (timeDiff >= 1.0)
|
||||
{
|
||||
nextT = nowT;
|
||||
printf("FPS: %d\n",fps);
|
||||
fps = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@ -191,6 +209,8 @@ int main()
|
|||
SDL_Surface *screenSurface = SDL_GetWindowSurface(window);
|
||||
SDL_Event event;
|
||||
|
||||
nextT = clock();
|
||||
|
||||
S3L_initCamera(&scene.camera);
|
||||
|
||||
// scene.camera.transform.translation.z = -S3L_FRACTIONS_PER_UNIT * 2;
|
||||
|
|
Loading…
Reference in a new issue