Removed config file added mem leak check.
Removed config file did not need a whole file, moved those to the main func as globals. Added some odin specific memory leak tracking.
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// Configuration
|
||||
//
|
||||
// Stores compile-time configuration values used to initialize the game.
|
||||
// Static values that configure the game, Runtime settings + game state belong elsewhere.
|
||||
// -----------------------------------------------------------------------------
|
||||
package game
|
||||
|
||||
DEBUG_MODE :: true
|
||||
|
||||
WINDOW_WIDTH :: 480
|
||||
WINDOW_HEIGHT :: 270
|
||||
WINDOW_TITLE :: "Graveyard"
|
||||
@@ -1,6 +1,32 @@
|
||||
package game
|
||||
|
||||
import "core:log"
|
||||
import "core:mem"
|
||||
|
||||
// Configuration Variables
|
||||
// -----------------------------------------------------------------------------
|
||||
DEBUG_MODE :: true
|
||||
|
||||
WINDOW_WIDTH :: 1920
|
||||
WINDOW_HEIGHT :: 1080
|
||||
GAME_WIDTH :: 480
|
||||
GAME_HEIGHT :: 270
|
||||
|
||||
WINDOW_TITLE :: "Graveyard"
|
||||
PLAYER_SPEED :: 180
|
||||
TILE_SIZE :: 32
|
||||
|
||||
main :: proc() {
|
||||
context.logger = log.create_console_logger()
|
||||
defer log.destroy_console_logger(context.logger)
|
||||
|
||||
when DEBUG_MODE {
|
||||
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_init()
|
||||
|
||||
for game_should_run(&game) {
|
||||
@@ -9,4 +35,21 @@ main :: proc() {
|
||||
}
|
||||
|
||||
game_close(&game)
|
||||
|
||||
when DEBUG_MODE {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user