kiba-engine
entry.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include <kiba/core/event.h>
12 #include <kiba/core/input.h>
13 #include <kiba/core/log.h>
14 #include <kiba/defines.h>
15 #include <kiba/format/format.h>
16 #include <kiba/gpu/backend.h>
17 #include <kiba/platform/timer.h>
18 
24 extern b8 create_application(void);
25 
33 extern b8 update_application(f64 delta);
34 
40 extern void destroy_application(void);
41 
51 int main(int argc, char **argv) {
52  UNUSED(argc);
53  UNUSED(argv);
54 
55  log_set_active_level(LOG_LEVEL_MAX);
56 
57  if (!format_initialize()) {
58  return false;
59  }
60 
61  log_set_active_level(LOG_LEVEL_DEBUG);
62 
63  if (!input_initialize()) {
64  return false;
65  }
66  if (!event_initialize()) {
67  return false;
68  }
69  if (!gpu_backend_initialize()) {
70  return false;
71  }
72 
73  if (create_application()) {
74  timestamp last = time_now();
75  f64 frame_time;
76  do {
77  timestamp cur = time_now();
78  f64 frame_time = time_diff_ms(last, cur);
79  u64 fps = (u64) (1000.0 / frame_time);
80  KB_DEBUG("fps: {u64}", fps);
81  last = cur;
82  input_update(frame_time);
83  } while (update_application(frame_time));
85  }
86  gpu_backend_shutdown();
89  log_set_active_level(LOG_LEVEL_MAX);
90  format_shutdown();
91 
92  return 0;
93 }
Global typedefs and macros.
#define UNUSED(x)
Mark parameter as unused.
Definition: defines.h:21
void destroy_application(void)
Shutdown of the application.
int main(int argc, char **argv)
Entrypoint of the application.
Definition: entry.h:51
b8 create_application(void)
Initialization of the application.
b8 update_application(f64 delta)
Updating the application.
b8 event_initialize(void)
Initialize the event system.
Definition: event.c:40
void event_shutdown(void)
Shutdown event system.
Definition: event.c:45
Event system.
void input_shutdown(void)
Shutdown input system.
Definition: input.c:49
void input_update(f64 delta_time)
Updates the input system.
Definition: input.c:51
b8 input_initialize(void)
Initialize the input system.
Definition: input.c:43
Input abstraction layer.
void log_set_active_level(log_level level)
Set the minimum log level to log.
Definition: log.c:29
Logging system.
#define KB_DEBUG(...)
Log entry with debug log level.
Definition: log.h:163
Definition: timer.h:5