Show the FPS readout in the top right
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,5 +1,5 @@
|
|||||||
SDLFLAGS_CC:=$(shell pkg-config sdl3 --cflags) $(shell pkg-config sdl3-image --cflags) $(shell pkg-config sdl3game --cflags) $(shell pkg-config akerror --cflags)
|
SDLFLAGS_CC:=$(shell pkg-config sdl3 --cflags) $(shell pkg-config sdl3-ttf --cflags) $(shell pkg-config sdl3-image --cflags) $(shell pkg-config sdl3game --cflags) $(shell pkg-config akerror --cflags)
|
||||||
SDLFLAGS_LD:=$(shell pkg-config sdl3 --libs) $(shell pkg-config sdl3-mixer --libs) $(shell pkg-config sdl3-image --libs) $(shell pkg-config sdl3game --libs) $(shell pkg-config akerror --libs) -lasound
|
SDLFLAGS_LD:=$(shell pkg-config sdl3 --libs) $(shell pkg-config sdl3-ttf --libs) $(shell pkg-config sdl3-mixer --libs) $(shell pkg-config sdl3-image --libs) $(shell pkg-config sdl3game --libs) $(shell pkg-config akerror --libs) -lasound
|
||||||
CC:=$(shell which gcc)
|
CC:=$(shell which gcc)
|
||||||
LD:=$(shell which ld)
|
LD:=$(shell which ld)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <sdl3game/sprite.h>
|
#include <sdl3game/sprite.h>
|
||||||
#include <sdl3game/actor.h>
|
#include <sdl3game/actor.h>
|
||||||
#include <sdl3game/registry.h>
|
#include <sdl3game/registry.h>
|
||||||
|
#include <sdl3game/text.h>
|
||||||
|
|
||||||
int numsprites = 8;
|
int numsprites = 8;
|
||||||
char *spritepaths[] = {
|
char *spritepaths[] = {
|
||||||
@@ -146,6 +147,8 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||||||
controlmap->controls[5].event_on = SDL_EVENT_KEY_DOWN;
|
controlmap->controls[5].event_on = SDL_EVENT_KEY_DOWN;
|
||||||
controlmap->controls[5].handler_on = &music_toggle;
|
controlmap->controls[5].handler_on = &music_toggle;
|
||||||
|
|
||||||
|
CATCH(errctx, text_loadFont("C64Pro", "assets/C64_Pro-STYLE.ttf", 18));
|
||||||
|
|
||||||
} CLEANUP {
|
} CLEANUP {
|
||||||
} PROCESS(errctx) {
|
} PROCESS(errctx) {
|
||||||
} HANDLE_DEFAULT(errctx) {
|
} HANDLE_DEFAULT(errctx) {
|
||||||
@@ -180,9 +183,12 @@ SDL_AppResult SDL_AppIterate(void *appstate)
|
|||||||
//b2Vec2 position;
|
//b2Vec2 position;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
iterator opflags;
|
iterator opflags;
|
||||||
|
char fpsText[32];
|
||||||
|
|
||||||
PREPARE_ERROR(errctx);
|
PREPARE_ERROR(errctx);
|
||||||
|
|
||||||
|
GAME_updateFPS();
|
||||||
|
|
||||||
BITMASK_CLEAR(opflags.flags);
|
BITMASK_CLEAR(opflags.flags);
|
||||||
BITMASK_ADD(opflags.flags, ITERATOR_OP_UPDATE);
|
BITMASK_ADD(opflags.flags, ITERATOR_OP_UPDATE);
|
||||||
BITMASK_ADD(opflags.flags, ITERATOR_OP_RENDER);
|
BITMASK_ADD(opflags.flags, ITERATOR_OP_RENDER);
|
||||||
@@ -200,7 +206,28 @@ SDL_AppResult SDL_AppIterate(void *appstate)
|
|||||||
return SDL_APP_FAILURE;
|
return SDL_APP_FAILURE;
|
||||||
} FINISH_NORETURN(errctx);
|
} FINISH_NORETURN(errctx);
|
||||||
}
|
}
|
||||||
|
ATTEMPT {
|
||||||
|
memset((char *)&fpsText, 0x00, 32);
|
||||||
|
snprintf((char *)&fpsText, 31, "FPS : %d", game.fps);
|
||||||
|
CATCH(errctx, text_renderTextAt(
|
||||||
|
SDL_GetPointerProperty(
|
||||||
|
REGISTRY_FONT,
|
||||||
|
"C64Pro",
|
||||||
|
NULL),
|
||||||
|
(char *)&fpsText,
|
||||||
|
(SDL_Color){255, 255, 255, 255},
|
||||||
|
0,
|
||||||
|
450,
|
||||||
|
10)
|
||||||
|
);
|
||||||
|
} CLEANUP {
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
} PROCESS(errctx) {
|
||||||
|
} HANDLE_DEFAULT(errctx) {
|
||||||
|
LOG_ERROR(errctx);
|
||||||
|
return SDL_APP_FAILURE;
|
||||||
|
} FINISH_NORETURN(errctx);
|
||||||
|
|
||||||
return SDL_APP_CONTINUE;
|
return SDL_APP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user