Kohi Game Engine
entry.h
Go to the documentation of this file.
1 
17 #pragma once
18 
19 #include "application_types.h"
20 #include "core/engine.h"
21 #include "core/logger.h"
22 
29 
31 
36 int main(void) {
37  // Request the application instance from the application.
38  application app_inst = {0};
39  if (!create_application(&app_inst)) {
40  KFATAL("Could not create application!");
41  return -1;
42  }
43 
44  // Ensure the function pointers exist.
45  if (!app_inst.render_frame || !app_inst.prepare_frame || !app_inst.update || !app_inst.initialize || !app_inst.on_resize) {
46  KFATAL("The application's function pointers must be assigned!");
47  return -2;
48  }
49 
50  // Initialization.
51  if (!engine_create(&app_inst)) {
52  KFATAL("Engine failed to create!.");
53  return 1;
54  }
55 
56  if (!initialize_application(&app_inst)) {
57  KFATAL("Could not initialize application!");
58  return -1;
59  }
60 
61  // Begin the engine loop.
62  if (!engine_run(&app_inst)) {
63  KINFO("Application did not shutdown gracefully.");
64  return 2;
65  }
66 
67  return 0;
68 }
This file contains types to be consumed by the application library.
_Bool b8
8-bit boolean type
Definition: defines.h:58
This file contains structures and logic pertaining to the overall engine itself. The engine is respon...
KAPI b8 engine_create(struct application *game_inst)
Creates the engine, standing up the platform layer and all underlying subsystems.
KAPI b8 engine_run(struct application *game_inst)
Starts the main engine loop.
b8 initialize_application(application *app)
b8 create_application(application *out_app)
Externally-defined function to create a application, provided by the consumer of this library.
int main(void)
The main entry point of the application.
Definition: entry.h:36
This file contains structures and logic pertaining to the logging system.
#define KFATAL(message,...)
Logs a fatal-level message. Should be used to stop the application when hit.
Definition: logger.h:77
#define KINFO(message,...)
Logs an info-level message. Should be used for non-erronuous informational purposes.
Definition: logger.h:113
Represents the basic application state in a application. Called for creation by the application.
Definition: application_types.h:42
b8(* prepare_frame)(struct application *app_inst, struct frame_data *p_frame_data)
Function pointer to application's prepare_frame function.
Definition: application_types.h:75
void(* on_resize)(struct application *app_inst, u32 width, u32 height)
Function pointer to handle resizes, if applicable.
Definition: application_types.h:91
b8(* initialize)(struct application *app_inst)
Function pointer to application's initialize function.
Definition: application_types.h:59
b8(* render_frame)(struct application *app_inst, struct frame_data *p_frame_data)
Function pointer to application's render_frame function.
Definition: application_types.h:83
b8(* update)(struct application *app_inst, struct frame_data *p_frame_data)
Function pointer to application's update function.
Definition: application_types.h:67