summaryrefslogtreecommitdiff
path: root/src/core/include/engine/engine.h
blob: 6e208d30f3d7da74ec5b95604acf1627323cf7b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef ENGINE_H
#define ENGINE_H

#include <stdbool.h>

// TODO: Cleanup the includes, ideally this header file should only include all
// "public-facing" headers.

#include <engine/core/types.h>
#include <engine/core/logging.h>
#include <engine/core/memory.h>
#include <engine/core/state.h>
#include <engine/ctrl/input.h>
#include <engine/resources.h>
#include <engine/utils/stack.h>
#include <engine/utils/vector.h>

typedef struct {
  u32 texture_id;
  i32 x, y, w, h;
} RenderUnit;

#include <engine/rendering/window.h>

#define NUM_GLOBAL_BINDINGS 1
typedef struct {
  void* data; /* Contains textures and such */
  u64 data_len;

  Window window;
  bool quit;

  u64 frame;
  f32 fps_target;

  /* TODO: Move mouse data to input ctx */
  v2_i32 mouse_pos;

  v2_i32 mousedown;
  v2_i32 mouseup;

  bool mouse_lclick;
  bool mouse_rclick;

  i32 camera_x;
  i32 camera_y;

  /* Text input/editing is currently not used/implemented */
  char* edit_text;
  usize edit_pos;

  memory* mem;

  i_ctx** bindings;
  usize bindings_sz;
  usize bindings_len;

  struct RenderObject *testobject;

  binding_t bindings_global[NUM_GLOBAL_BINDINGS];
} Platform;

/* Essential functions */
Platform* engine_init(const char* windowtitle, v2_i32 windowsize,
                      const f32 render_scale, const u32 flags,
                      const usize initial_memory, const Asset_FontSpec* fonts[],
                      const Asset_TextureSpec* textures[]);

i32 engine_run(Platform* p, StateType initial_state);

void engine_stop(Platform* p);

/* Utility functions */
void engine_fps_max(u64 cap);

void render_set_zoom(f32 new_zoom);
void render_adjust_zoom(f32 diff);
void render_add_unit(RenderUnit* u);

f64 get_time(void);
//v2_i32 get_windowsize(void);
v2_i32* get_mousepos(void);

/* Input handling */
void engine_input_ctx_push(i_ctx* ctx);
void engine_input_ctx_pop(void);
void engine_input_ctx_reset(void);

//#include <engine/rendering/rendering.h>

//#ifdef ENGINE_INTERNALS
//
//#include <glad/gl.h>
//#define GLFW_INCLUDE_NONE
//#include <GLFW/glfw3.h>
//
//
//#endif
#endif