#ifndef JNR_CORE_H
#define JNR_CORE_H

#include <SDL2/SDL.h>
#include <stdbool.h>
#include <stdint.h>
#include "config.h"

typedef struct Engine {
    bool          running;
    SDL_Window   *window;
    SDL_Renderer *renderer;
    uint32_t      tick;            /* current physics tick              */
    float         interpolation;   /* 0.0-1.0 for render interpolation */
    float         fps;             /* smoothed frames-per-second        */
} Engine;

/* Global engine instance */
extern Engine g_engine;

bool engine_init(void);
void engine_run(void);
void engine_shutdown(void);

/* Called by the game layer - set these before engine_run() */
typedef void (*GameInitFn)(void);
typedef void (*GameUpdateFn)(float dt);
typedef void (*GameRenderFn)(float interpolation);
typedef void (*GameShutdownFn)(void);

typedef struct GameCallbacks {
    GameInitFn     init;
    GameUpdateFn   update;
    GameRenderFn   render;
    GameShutdownFn shutdown;
} GameCallbacks;

void engine_set_callbacks(GameCallbacks cb);

#endif /* JNR_CORE_H */
