Skip to content

Commit

Permalink
Allow memory to grow (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop authored Dec 21, 2024
1 parent 604ba37 commit 76b633b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions OpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ if (EMSCRIPTEN)
target_link_options(${PROJECT_NAME} PRIVATE
-sASYNCIFY
--preload-file "${CMAKE_CURRENT_SOURCE_DIR}/res"
-sALLOW_MEMORY_GROWTH=1
--shell-file ${CMAKE_CURRENT_SOURCE_DIR}/../web/template.html
)
# TODO: It would be cool to add -fno-exceptions -fno-rtti
Expand Down
10 changes: 10 additions & 0 deletions OpenGL/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ ImFont* load_font(std::filesystem::path res_path, ImGuiIO* io, const std::string

bool Application::initialized = false;

#ifdef __EMSCRIPTEN__
EM_JS(void, print_memory_consumption, (), {
console.log('Current heap size:', HEAP8.length);
console.log('Memory used:', HEAPU8.buffer.byteLength);
});
#endif

// Initialize everything and return true if it went all right
Application::Application()
: res_path(getResPath())
Expand Down Expand Up @@ -468,6 +475,9 @@ Application::Application()
assert(false);
} else {
std::cout << "Application initialized" << std::endl;
#ifdef __EMSCRIPTEN__
print_memory_consumption();
#endif
}

initialized = true;
Expand Down
2 changes: 1 addition & 1 deletion OpenGL/src/AudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AudioEngine {
Sound Impact;
Sound Scuff;
Sound Song;

// bunny dialogue
Sound Rabbit1;
Sound Rabbit2;
Expand Down

0 comments on commit 76b633b

Please sign in to comment.