Code: Show/Hide double RecordFPS()
{ /* Source: http://cone3d.gamedev.net */ #define FPS_BUCKET_SIZE 20 #define FPS_AVERAGE_TIME 1000 static unsigned int bucket[FPS_BUCKET_SIZE]; static int now = 0, end = 0; int FPS = 0; unsigned int tick = glutGet(GLUT_ELAPSED_TIME); /* Add current time to bucket */ end++; if (end == FPS_BUCKET_SIZE) end = 0; bucket[end] = tick; /* If too high FPS, need a safe wrap around so FPS won't jump. * Bug from original source would have the time difference jump * down to near 0, causing the FPS for a couple of frames to show * up incorrectly by not using the whole bucket to search. */ if (end == now) { now = end + 1; if (now == FPS_BUCKET_SIZE) now = 0; } /* Loop through till we find time of at least X seconds ago */ if (tick < FPS_AVERAGE_TIME) tick = 0; else tick -= FPS_AVERAGE_TIME; while (bucket[now] < tick) { now++; if (now == FPS_BUCKET_SIZE) now = 0; } /* How much difference is between 'now' and 'end' is how many frames drawn in last 10 seconds */ FPS = end - now; if (end < now) FPS += FPS_BUCKET_SIZE; if (end == now) return 0.0; return FPS * 1000.0 / (double)(bucket[end] - bucket[now]); } |
Code: Show/Hide brad@brad-laptop:~/Desktop/pearlharbour/pearlharbour$ make gcc -O2 -s -DNDEBUG -Wall -fomit-frame-pointer main.o util.o graphics.o game.o -o pearlharbour -lSDL main.o: In function `main': main.c:(.text+0x19b): undefined reference to `Game_DrawShips' main.c:(.text+0x1a1): undefined reference to `Game_DrawMap' main.c:(.text+0x1a6): undefined reference to `Game_DrawWeapons' main.c:(.text+0x1ab): undefined reference to `Game_DrawPlanes' main.c:(.text+0x1b1): undefined reference to `Game_DrawAnims' game.o: In function `Game_DrawRadar': game.c:(.text+0xc0): undefined reference to `mapobjectset' game.c:(.text+0x16a): undefined reference to `shipobjectset' game.c:(.text+0x21c): undefined reference to `planeset' game.o: In function `Game_Update': game.c:(.text+0x475): undefined reference to `UpdatePlanes' game.c:(.text+0x47a): undefined reference to `UpdateWeapons' game.c:(.text+0x47f): undefined reference to `UpdateFlak' game.c:(.text+0x484): undefined reference to `UpdateShips' game.c:(.text+0x489): undefined reference to `UpdateAnims' game.o: In function `TryFireSecondary': game.c:(.text+0x59e): undefined reference to `AddWeapon' game.o: In function `TryFirePrimary': game.c:(.text+0x6f0): undefined reference to `AddWeapon' game.o: In function `CheckWin': game.c:(.text+0x760): undefined reference to `SpawnFighters' game.c:(.text+0x77f): undefined reference to `planeset' game.c:(.text+0x795): undefined reference to `SpawnBombers' game.o: In function `Game_CleaupLevel': game.c:(.text+0x7ae): undefined reference to `planeset' game.c:(.text+0x7ba): undefined reference to `planeset' game.c:(.text+0x7ce): undefined reference to `mapobjectset' game.c:(.text+0x7da): undefined reference to `mapobjectset' game.c:(.text+0x7ee): undefined reference to `shipobjectset' game.c:(.text+0x7fa): undefined reference to `shipobjectset' game.c:(.text+0x80e): undefined reference to `flakobjectset' game.c:(.text+0x81a): undefined reference to `flakobjectset' game.c:(.text+0x84e): undefined reference to `animset' game.c:(.text+0x85a): undefined reference to `animset' game.o: In function `Game_LoadLevel': game.c:(.text+0x87b): undefined reference to `planeset' game.c:(.text+0x88f): undefined reference to `mapobjectset' game.c:(.text+0x89b): undefined reference to `shipobjectset' game.c:(.text+0x8a7): undefined reference to `flakobjectset' game.c:(.text+0x8bf): undefined reference to `animset' game.c:(.text+0xc5e): undefined reference to `AddShip' game.c:(.text+0xc93): undefined reference to `AddShip' game.c:(.text+0xcc3): undefined reference to `AddShip' game.c:(.text+0xcf5): undefined reference to `AddShip' game.c:(.text+0xcfd): undefined reference to `AddFlakProtectShip' game.c:(.text+0xd2d): undefined reference to `AddShip' game.c:(.text+0xd5d): undefined reference to `AddShip' game.c:(.text+0xd8f): undefined reference to `AddShip' game.c:(.text+0xd97): undefined reference to `AddFlakProtectShip' game.c:(.text+0xdc7): undefined reference to `AddShip' game.c:(.text+0xde9): undefined reference to `AddIsland' game.c:(.text+0xe09): undefined reference to `AddFlakEmplacement' game.c:(.text+0xe1d): undefined reference to `AddJungle' game.c:(.text+0xe38): undefined reference to `AddIsland' game.c:(.text+0xe4c): undefined reference to `AddJungle' game.c:(.text+0xe60): undefined reference to `AddJungle' game.c:(.text+0xe74): undefined reference to `AddIsland' game.c:(.text+0xe94): undefined reference to `AddFlakEmplacement' game.c:(.text+0xeb4): undefined reference to `AddFlakEmplacement' game.c:(.text+0xec7): undefined reference to `SpawnEnemies' game.c:(.text+0xf1f): undefined reference to `AddPlane' game.c:(.text+0xf69): undefined reference to `AddPlane' game.c:(.text+0xfbb): undefined reference to `AddPlane' game.c:(.text+0x1005): undefined reference to `AddPlane' collect2: ld returned 1 exit status make: *** [pearlharbour] Error 1 |
Smong wrote: |
Updates were done on windows so the makefile is now outdated and no linux binary is provided. |