mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-05 04:28:47 +02:00
Examples: Emscripten: Demonstrating embedding fonts in Makefile and code. (#2953) [@Oipo]
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
#
|
||||
# Makefile to use with emscripten
|
||||
# See https://emscripten.org/docs/getting_started/downloads.html
|
||||
# for installation instructions. This Makefile assumes you have
|
||||
# loaded emscripten's environment.
|
||||
# for installation instructions.
|
||||
#
|
||||
# This Makefile assumes you have loaded emscripten's environment.
|
||||
# (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead)
|
||||
#
|
||||
# Running `make` will produce three files:
|
||||
# - example_emscripten.html
|
||||
@ -13,7 +15,6 @@
|
||||
|
||||
CC = emcc
|
||||
CXX = em++
|
||||
|
||||
EXE = example_emscripten.html
|
||||
SOURCES = main.cpp
|
||||
SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp
|
||||
@ -21,21 +22,41 @@ SOURCES += ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../../imgui
|
||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
EMS = -s USE_SDL=2 -s WASM=1
|
||||
##---------------------------------------------------------------------
|
||||
## EMSCRIPTEN OPTIONS
|
||||
##---------------------------------------------------------------------
|
||||
|
||||
EMS += -s USE_SDL=2 -s WASM=1
|
||||
EMS += -s ALLOW_MEMORY_GROWTH=1
|
||||
EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0
|
||||
EMS += -s ASSERTIONS=1
|
||||
EMS += -s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS
|
||||
# Uncomment next line to fix possible rendering bugs with emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
|
||||
|
||||
# Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
|
||||
#EMS += -s BINARYEN_TRAP_MODE=clamp
|
||||
#EMS += -s SAFE_HEAP=1 ## Adds overhead
|
||||
|
||||
CPPFLAGS = -I../ -I../../
|
||||
# Emscripten allows preloading a file or folder to be accessible at runtime.
|
||||
# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
|
||||
# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
|
||||
# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
|
||||
USE_FILE_SYSTEM ?= 0
|
||||
ifeq ($(USE_FILE_SYSTEM), 0)
|
||||
EMS += -s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS
|
||||
endif
|
||||
ifeq ($(USE_FILE_SYSTEM), 1)
|
||||
LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
|
||||
endif
|
||||
|
||||
##---------------------------------------------------------------------
|
||||
## FINAL BUILD FLAGS
|
||||
##---------------------------------------------------------------------
|
||||
|
||||
CPPFLAGS += -I../ -I../../
|
||||
#CPPFLAGS += -g
|
||||
CPPFLAGS += -Wall -Wformat -Os
|
||||
CPPFLAGS += $(EMS)
|
||||
LIBS = $(EMS)
|
||||
LDFLAGS = --shell-file shell_minimal.html
|
||||
LIBS += $(EMS)
|
||||
LDFLAGS += --shell-file shell_minimal.html
|
||||
|
||||
##---------------------------------------------------------------------
|
||||
## BUILD RULES
|
||||
|
Reference in New Issue
Block a user