measure fps
This commit is contained in:
parent
667e2e640f
commit
6855ce19f2
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <libgba-sprite-engine/gba/tonc_memdef.h>
|
#include <libgba-sprite-engine/gba/tonc_memdef.h>
|
||||||
#include <libgba-sprite-engine/gba_engine.h>
|
#include <libgba-sprite-engine/gba_engine.h>
|
||||||
|
#include <libgba-sprite-engine/background/text_stream.h>
|
||||||
#include "wirescene.h"
|
#include "wirescene.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ Camera WireScene::camera() {
|
||||||
return Camera(VectorFx::fromInt(0, 0, 10), VectorFx::fromInt(0, 0, 0));
|
return Camera(VectorFx::fromInt(0, 0, 10), VectorFx::fromInt(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int msecs = 1;
|
||||||
void WireScene::load() {
|
void WireScene::load() {
|
||||||
foregroundPalette = std::unique_ptr<ForegroundPaletteManager>(new ForegroundPaletteManager());
|
foregroundPalette = std::unique_ptr<ForegroundPaletteManager>(new ForegroundPaletteManager());
|
||||||
backgroundPalette = std::unique_ptr<BackgroundPaletteManager>(new BackgroundPaletteManager(pal, sizeof(pal)));
|
backgroundPalette = std::unique_ptr<BackgroundPaletteManager>(new BackgroundPaletteManager(pal, sizeof(pal)));
|
||||||
|
@ -46,9 +48,17 @@ void WireScene::load() {
|
||||||
cube->addFace({ 0, 4, 7});
|
cube->addFace({ 0, 4, 7});
|
||||||
cube->addFace({ 4, 5, 6});
|
cube->addFace({ 4, 5, 6});
|
||||||
cube->addFace({ 4, 6, 7});
|
cube->addFace({ 4, 6, 7});
|
||||||
|
|
||||||
|
engine->getTimer()->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireScene::tick(u16 keys) {
|
void WireScene::tick(u16 keys) {
|
||||||
|
int curmsecs = engine->getTimer()->getMsecs();
|
||||||
|
int elapsed = curmsecs - msecs;
|
||||||
|
msecs = curmsecs;
|
||||||
|
|
||||||
|
TextStream::instance().setText(std::to_string(1000 / elapsed) + std::string(" FPS"), 1, 1);
|
||||||
|
|
||||||
cube->rotate(2, 2);
|
cube->rotate(2, 2);
|
||||||
|
|
||||||
if(keys & KEY_A) {
|
if(keys & KEY_A) {
|
||||||
|
|
|
@ -31,10 +31,10 @@ public:
|
||||||
std::string to_string();
|
std::string to_string();
|
||||||
|
|
||||||
int getTotalMsecs();
|
int getTotalMsecs();
|
||||||
int getMsecs() { return msecs; }
|
inline int getMsecs() { return msecs; }
|
||||||
int getSecs() { return secs; }
|
inline int getSecs() { return secs; }
|
||||||
int getMinutes() { return minutes; }
|
inline int getMinutes() { return minutes; }
|
||||||
int getHours() { return hours; }
|
inline int getHours() { return hours; }
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, Timer& timer);
|
friend std::ostream& operator<<(std::ostream& os, Timer& timer);
|
||||||
};
|
};
|
||||||
|
|
|
@ -130,12 +130,11 @@ void GBAEngine::update() {
|
||||||
// WARNING - keep amount of instructions as minimal as possible in here!
|
// WARNING - keep amount of instructions as minimal as possible in here!
|
||||||
|
|
||||||
u16 keys = readKeys();
|
u16 keys = readKeys();
|
||||||
// main scene update loop call. This *might* take a while.
|
|
||||||
currentScene->tick(keys);
|
|
||||||
|
|
||||||
// TODO use software interrupt Vsyncing instead of 2 wasteful whiles
|
// TODO use software interrupt Vsyncing instead of 2 wasteful whiles
|
||||||
vsync();
|
vsync();
|
||||||
renderClear();
|
renderClear();
|
||||||
|
currentScene->tick(keys);
|
||||||
render();
|
render();
|
||||||
flipPage();
|
flipPage();
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 175 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue