Moving some scene files around

This commit is contained in:
2023-07-03 23:05:59 -07:00
parent 71c9f5309b
commit 6de9e3a67f
5 changed files with 29 additions and 5 deletions

View File

@ -78,7 +78,7 @@ size_t AssetLoader::loadRaw(uint8_t **buffer) {
this->rewind();
// Read the string then close the file handle.
*buffer = static_cast<uint8_t *>(malloc(sizeof(uint8_t) * length));
*buffer = static_cast<uint8_t *>(memoryAllocate(sizeof(uint8_t) * length));
read = this->read(*buffer, length);
this->close();

View File

@ -127,5 +127,6 @@ void TextureAsset::updateAsync() {
TextureAsset::~TextureAsset() {
if(this->buffer != nullptr) {
memoryFree(this->buffer);
this->buffer = nullptr;
}
}

View File

@ -4,12 +4,10 @@
// https://opensource.org/licenses/MIT
#include "game/DawnGame.hpp"
#include "vnscenes/SceneTest.hpp"
#include "scenes/HelloWorldScene.hpp"
#include "vnscenes/ScenePrologue0.hpp"
using namespace Dawn;
Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) {
// return new HelloWorldScene(game);
return new SceneTest(game);
return new ScenePrologue0(game);
}

View File

@ -5,11 +5,19 @@
#include "DawnHostTux32.hpp"
#if DAWN_DEBUG_BUILD
uint64_t dawnAllocatedItemCount;
#endif
using namespace Dawn;
int32_t main(int32_t argc, char **args) {
int32_t result;
#if DAWN_DEBUG_BUILD
dawnAllocatedItemCount = 0;
#endif
// Create the host
auto host = new DawnHost();
auto game = new DawnGame(host);
@ -40,6 +48,10 @@ int32_t main(int32_t argc, char **args) {
delete game;
delete host;
#if DAWN_DEBUG_BUILD
assertTrue(dawnAllocatedItemCount == 0);
#endif
// Success
return 0;
}

View File

@ -8,6 +8,10 @@
#pragma once
#include "assert/assert.hpp"
#if DAWN_DEBUG_BUILD
extern uint64_t dawnAllocatedItemCount;
#endif
/**
* Allocate some space in memory to use for your needs. Memory allocation may
* change how it functions later on to keep things nice and efficient. For now
@ -18,6 +22,9 @@
*/
static inline void * memoryAllocate(const size_t size) {
assertTrue(size > 0);
#if DAWN_DEBUG_BUILD
dawnAllocatedItemCount++;
#endif
auto x = (void *)malloc(size);
assertNotNull(x);
return x;
@ -31,6 +38,9 @@ static inline void * memoryAllocate(const size_t size) {
*/
static inline void * memoryFillWithZero(const size_t size) {
assertTrue(size > 0);
#if DAWN_DEBUG_BUILD
dawnAllocatedItemCount++;
#endif
auto x =(void *)calloc(1, size);
assertNotNull(x);
return x;
@ -43,6 +53,9 @@ static inline void * memoryFillWithZero(const size_t size) {
*/
static inline void memoryFree(void *pointer) {
assertNotNull(pointer);
#if DAWN_DEBUG_BUILD
dawnAllocatedItemCount--;
#endif
free(pointer);
}