GoldFish Engine
Quite simple and lightweight game engine
Loading...
Searching...
No Matches
gf_physics.c
1
#define GF_EXPOSE_PHYSICS
2
3
#include <
gf_pre.h
>
4
5
/* External library */
6
#include <ode/ode.h>
7
8
/* Interface */
9
#include <
gf_physics.h
>
10
11
/* Engine */
12
#include <
gf_log.h
>
13
14
/* Standard */
15
#include <stdlib.h>
16
17
void
gf_physics_begin(
void
) { dInitODE(); }
18
19
void
gf_physics_end(
void
) { dCloseODE(); }
20
21
gf_physics_t
* gf_physics_create(
gf_engine_t
* engine) {
22
gf_physics_t
* physics = malloc(
sizeof
(*physics));
23
physics->
engine
= engine;
24
physics->
id
= dWorldCreate();
25
dWorldSetGravity(physics->
id
, 0, 0, -9.81);
26
return
physics;
27
}
28
29
void
gf_physics_destroy(
gf_physics_t
* physics) {
30
dWorldDestroy(physics->
id
);
31
gf_log_function
(physics->
engine
,
"Destroyed physics interface"
,
""
);
32
free(physics);
33
}
gf_log.h
Logger.
gf_log_function
#define gf_log_function(engine, fmt,...)
Output log with line number and function name.
Definition
gf_log.h:26
gf_physics.h
Physics interface.
gf_pre.h
Required headers before anything.
gf_engine_t
Engine instance.
Definition
core.h:46
gf_physics_t
Physics interface.
Definition
physics.h:38
gf_physics_t::engine
gf_engine_t * engine
Engine instance.
Definition
physics.h:38
gf_physics_t::id
dWorldID id
ODE's world ID.
Definition
physics.h:38
gf_physics.c
Generated by
1.9.8