GoldFish Engine
Quite simple and lightweight game engine
Loading...
Searching...
No Matches
gf_client.c
1#define GF_EXPOSE_CLIENT
2#define GF_EXPOSE_DRAW
3
4#include <gf_pre.h>
5
6/* External library */
7
8/* Interface */
9#include <gf_client.h>
10
11/* Engine */
12#include <gf_draw.h>
13#include <gf_log.h>
14#include <gf_input.h>
15
16/* Standard */
17#include <stdlib.h>
18#include <string.h>
19
20void gf_client_begin(void) { gf_draw_begin(); }
21
22void gf_client_end(void) { gf_draw_end(); }
23
24gf_client_t* gf_client_create(gf_engine_t* engine, const char* title) {
25 gf_client_t* client = malloc(sizeof(*client));
26 memset(client, 0, sizeof(*client));
27 client->engine = engine;
28 client->draw = gf_draw_create(engine, title);
29 if(client->draw == NULL) {
30 gf_log_function(engine, "Failed to create drawing interface", "");
31 gf_client_destroy(client);
32 return NULL;
33 }
34 client->input = gf_input_create(engine);
35 gf_draw_set_input(client->draw, client->input);
36 return client;
37}
38
39void gf_client_destroy(gf_client_t* client) {
40 if(client->draw != NULL) gf_draw_destroy(client->draw);
41 if(client->input != NULL) gf_input_destroy(client->input);
42 gf_log_function(client->engine, "Destroyed client interface", "");
43 free(client);
44}
45
46int gf_client_step(gf_client_t* client) {
47 int s = gf_draw_step(client->draw);
48 return s;
49}
Client interface.
Drawing interface.
Logger.
#define gf_log_function(engine, fmt,...)
Output log with line number and function name.
Definition gf_log.h:26
Required headers before anything.
Client interface.
Definition client.h:43
gf_draw_t * draw
Drawing interface.
Definition client.h:43
gf_input_t * input
Input interface.
Definition client.h:43
gf_engine_t * engine
Engine instance.
Definition client.h:43
Engine instance.
Definition core.h:46