2019-07-20 16:03:28 +02:00
|
|
|
#include "FxEngine.h"
|
2019-07-21 16:32:43 +02:00
|
|
|
|
2019-07-20 16:47:37 +02:00
|
|
|
#include <libprof.h>
|
2019-07-21 20:14:54 +02:00
|
|
|
#include "coord.h"
|
|
|
|
#include <stdbool.h>
|
2019-07-22 16:28:59 +02:00
|
|
|
#include <gint/keyboard.h>
|
|
|
|
#include <gint/clock.h>
|
2019-07-21 20:14:54 +02:00
|
|
|
#include <gint/display.h>
|
|
|
|
|
|
|
|
FE_position FE_user={0,0,0};
|
|
|
|
double FE_dh,FE_dv,FE_roulis;
|
2019-07-20 16:03:28 +02:00
|
|
|
|
2019-07-22 16:28:59 +02:00
|
|
|
static uint32_t frame_interval=0, frame_interval_min=1000001, frame_interval_max=1; // in milliseconds
|
2019-07-20 16:47:37 +02:00
|
|
|
static bool loaded_before=false;
|
2019-07-20 16:03:28 +02:00
|
|
|
|
2019-07-22 19:17:16 +02:00
|
|
|
static double dh_vel=0.05;
|
|
|
|
static double dv_vel=0.05;
|
|
|
|
|
2019-07-21 20:14:54 +02:00
|
|
|
static void FE_move() // call at each frame
|
|
|
|
{
|
2019-07-22 16:28:59 +02:00
|
|
|
key_event_t event;
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
event=pollevent();
|
|
|
|
if (event.type&KEYEV_DOWN)
|
|
|
|
{
|
2019-07-22 19:17:16 +02:00
|
|
|
if (event.key==KEY_LEFT)
|
|
|
|
FE_dh-=dh_vel;
|
|
|
|
if (event.key==KEY_RIGHT)
|
|
|
|
FE_dh+=dh_vel;
|
|
|
|
if (event.key==KEY_UP)
|
|
|
|
FE_dv+=dv_vel;
|
|
|
|
if (event.key==KEY_DOWN)
|
|
|
|
FE_dv-=dv_vel;
|
2019-07-22 16:28:59 +02:00
|
|
|
}
|
|
|
|
if (event.type==KEYEV_NONE)
|
|
|
|
break;
|
|
|
|
}
|
2019-07-21 20:14:54 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FE_new_frame(void)
|
2019-07-20 16:03:28 +02:00
|
|
|
{
|
2019-07-20 16:47:37 +02:00
|
|
|
if (loaded_before)
|
2019-07-21 20:14:54 +02:00
|
|
|
{
|
2019-07-20 16:47:37 +02:00
|
|
|
prof_leave(0);
|
2019-07-22 16:28:59 +02:00
|
|
|
frame_interval=prof_time(0);
|
|
|
|
if (frame_interval<frame_interval_min)
|
|
|
|
frame_interval_min=frame_interval;
|
|
|
|
if (frame_interval>frame_interval_max)
|
|
|
|
frame_interval_max=frame_interval;
|
2019-07-21 20:14:54 +02:00
|
|
|
}
|
2019-07-20 16:47:37 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
prof_init(1,0);
|
|
|
|
loaded_before=true;
|
|
|
|
}
|
2019-07-20 16:53:07 +02:00
|
|
|
prof_clear(0);
|
2019-07-20 16:47:37 +02:00
|
|
|
prof_enter(0);
|
2019-07-20 16:29:46 +02:00
|
|
|
|
2019-07-20 16:03:28 +02:00
|
|
|
FE_move(); // Not implemented yet !
|
2019-07-21 20:14:54 +02:00
|
|
|
FE_set_matrice();
|
2019-07-23 15:52:20 +02:00
|
|
|
FE_zbuffer_clear();
|
2019-07-20 16:03:28 +02:00
|
|
|
|
2019-07-22 13:55:24 +02:00
|
|
|
dupdate();
|
2019-07-22 16:28:59 +02:00
|
|
|
dclear(C_WHITE);
|
2019-07-20 16:03:28 +02:00
|
|
|
}
|
|
|
|
|
2019-07-22 16:28:59 +02:00
|
|
|
|
|
|
|
static char fps_history[15];
|
2019-07-22 19:17:16 +02:00
|
|
|
char* FE_get_fps_history()
|
2019-07-22 16:28:59 +02:00
|
|
|
{
|
|
|
|
sprintf(fps_history,"%d/%d/%d",FE_get_fps_min(),FE_get_fps_current(),FE_get_fps_max());
|
|
|
|
return fps_history;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const uint32_t unite=1000000;
|
|
|
|
unsigned int FE_get_fps_current(void)
|
|
|
|
{return unite/frame_interval;}
|
|
|
|
|
|
|
|
unsigned int FE_get_fps_min(void)
|
|
|
|
{return unite/frame_interval_max;}
|
|
|
|
|
|
|
|
unsigned int FE_get_fps_max(void)
|
|
|
|
{return unite/frame_interval_min;}
|
2019-07-20 16:47:37 +02:00
|
|
|
|
2019-07-21 20:14:54 +02:00
|
|
|
|