Initial setup done, debug mode, build script, simple entry point, simple game manager setup. Ideal starting point for my games.
49 lines
1.2 KiB
Odin
49 lines
1.2 KiB
Odin
package game
|
|
|
|
import "core:log"
|
|
import "core:mem"
|
|
|
|
// compiler sets debug mode
|
|
DEBUG :: #config(DEBUG_MODE, false)
|
|
|
|
main :: proc() {
|
|
when DEBUG {
|
|
context.logger = log.create_console_logger()
|
|
defer log.destroy_console_logger(context.logger)
|
|
log.debug("--- DEBUG MODE ENABLED ---")
|
|
|
|
track: mem.Tracking_Allocator
|
|
mem.tracking_allocator_init(&track, context.allocator)
|
|
defer mem.tracking_allocator_destroy(&track)
|
|
context.allocator = mem.tracking_allocator(&track)
|
|
}
|
|
// ------------------------------------------------------
|
|
|
|
game := Game{}
|
|
|
|
game_init(&game)
|
|
|
|
for game_should_run() {
|
|
game_update(&game)
|
|
game_render(&game)
|
|
}
|
|
|
|
game_quit(&game)
|
|
|
|
// ------------------------------------------------------
|
|
// Check for any leaks!
|
|
when DEBUG {
|
|
if len(track.allocation_map) > 0 {
|
|
log.errorf("\nMEMORY LEAKS: %v allocation(s)", len(track.allocation_map))
|
|
for _, entry in track.allocation_map {
|
|
log.errorf(" %v bytes @ %v", entry.size, entry.location)
|
|
}
|
|
}
|
|
if len(track.bad_free_array) > 0 {
|
|
log.errorf("\nBAD FREES: %v", len(track.bad_free_array))
|
|
for entry in track.bad_free_array {
|
|
log.errorf(" %v @ %v", entry.memory, entry.location)
|
|
}
|
|
}
|
|
}
|
|
} |