// DXGI_FORMAT
19 |
20 | struct ID3D12Device;
21 | struct ID3D12DescriptorHeap;
22 | struct ID3D12GraphicsCommandList;
23 | struct D3D12_CPU_DESCRIPTOR_HANDLE;
24 | struct D3D12_GPU_DESCRIPTOR_HANDLE;
25 |
26 | // cmd_list is the command list that the implementation will use to render imgui draw lists.
27 | // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
28 | // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
29 | // font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture.
30 | IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
31 | D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
32 | IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
33 | IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
34 | IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
35 |
36 | // Use if you want to reset your rendering device without losing Dear ImGui state.
37 | IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
38 | IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects();
39 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_glfw_opengl2/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Cross Platform Makefile
3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
4 | #
5 | # You will need GLFW (http://www.glfw.org):
6 | # Linux:
7 | # apt-get install libglfw-dev
8 | # Mac OS X:
9 | # brew install glfw
10 | # MSYS2:
11 | # pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
12 | #
13 |
14 | #CXX = g++
15 | #CXX = clang++
16 |
17 | EXE = example_glfw_opengl2
18 | IMGUI_DIR = ../..
19 | SOURCES = main.cpp
20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp
22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
23 | UNAME_S := $(shell uname -s)
24 |
25 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
26 | CXXFLAGS += -g -Wall -Wformat
27 | LIBS =
28 |
29 | ##---------------------------------------------------------------------
30 | ## BUILD FLAGS PER PLATFORM
31 | ##---------------------------------------------------------------------
32 |
33 | ifeq ($(UNAME_S), Linux) #LINUX
34 | ECHO_MESSAGE = "Linux"
35 | LIBS += -lGL `pkg-config --static --libs glfw3`
36 |
37 | CXXFLAGS += `pkg-config --cflags glfw3`
38 | CFLAGS = $(CXXFLAGS)
39 | endif
40 |
41 | ifeq ($(UNAME_S), Darwin) #APPLE
42 | ECHO_MESSAGE = "Mac OS X"
43 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
44 | LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib
45 | #LIBS += -lglfw3
46 | LIBS += -lglfw
47 |
48 | CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
49 | CFLAGS = $(CXXFLAGS)
50 | endif
51 |
52 | ifeq ($(OS), Windows_NT)
53 | ECHO_MESSAGE = "MinGW"
54 | LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
55 |
56 | CXXFLAGS += `pkg-config --cflags glfw3`
57 | CFLAGS = $(CXXFLAGS)
58 | endif
59 |
60 | ##---------------------------------------------------------------------
61 | ## BUILD RULES
62 | ##---------------------------------------------------------------------
63 |
64 | %.o:%.cpp
65 | $(CXX) $(CXXFLAGS) -c -o $@ $<
66 |
67 | %.o:$(IMGUI_DIR)/%.cpp
68 | $(CXX) $(CXXFLAGS) -c -o $@ $<
69 |
70 | %.o:$(IMGUI_DIR)/backends/%.cpp
71 | $(CXX) $(CXXFLAGS) -c -o $@ $<
72 |
73 | all: $(EXE)
74 | @echo Build complete for $(ECHO_MESSAGE)
75 |
76 | $(EXE): $(OBJS)
77 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
78 |
79 | clean:
80 | rm -f $(EXE) $(OBJS)
81 |
82 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/libs/emscripten/shell_minimal.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Dear ImGui Emscripten example
7 |
30 |
31 |
32 |
33 |
63 | {{{ SCRIPT }}}
64 |
65 |
66 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d}
6 |
7 |
8 | {f18ab499-84e1-499f-8eff-9754361e0e52}
9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
10 |
11 |
12 |
13 |
14 | sources
15 |
16 |
17 | imgui
18 |
19 |
20 | imgui
21 |
22 |
23 | imgui
24 |
25 |
26 | imgui
27 |
28 |
29 | imgui
30 |
31 |
32 | sources
33 |
34 |
35 | sources
36 |
37 |
38 |
39 |
40 | imgui
41 |
42 |
43 | imgui
44 |
45 |
46 | imgui
47 |
48 |
49 | sources
50 |
51 |
52 | sources
53 |
54 |
55 | sources
56 |
57 |
58 |
59 |
60 |
61 | imgui
62 |
63 |
64 | imgui
65 |
66 |
67 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_sdl2_opengl3/example_sdl2_opengl3.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d}
6 |
7 |
8 | {f18ab499-84e1-499f-8eff-9754361e0e52}
9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
10 |
11 |
12 |
13 |
14 | imgui
15 |
16 |
17 | imgui
18 |
19 |
20 | imgui
21 |
22 |
23 | sources
24 |
25 |
26 | sources
27 |
28 |
29 | sources
30 |
31 |
32 | imgui
33 |
34 |
35 | imgui
36 |
37 |
38 |
39 |
40 | imgui
41 |
42 |
43 | imgui
44 |
45 |
46 | imgui
47 |
48 |
49 | sources
50 |
51 |
52 | sources
53 |
54 |
55 | sources
56 |
57 |
58 |
59 |
60 |
61 | imgui
62 |
63 |
64 | imgui
65 |
66 |
67 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_sdl3_opengl3/example_sdl3_opengl3.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {20b90ce4-7fcb-4731-b9a0-075f875de82d}
6 |
7 |
8 | {f18ab499-84e1-499f-8eff-9754361e0e52}
9 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
10 |
11 |
12 |
13 |
14 | imgui
15 |
16 |
17 | imgui
18 |
19 |
20 | imgui
21 |
22 |
23 | sources
24 |
25 |
26 | sources
27 |
28 |
29 | sources
30 |
31 |
32 | imgui
33 |
34 |
35 | imgui
36 |
37 |
38 |
39 |
40 | imgui
41 |
42 |
43 | imgui
44 |
45 |
46 | imgui
47 |
48 |
49 | sources
50 |
51 |
52 | sources
53 |
54 |
55 | sources
56 |
57 |
58 |
59 |
60 |
61 | imgui
62 |
63 |
64 | imgui
65 |
66 |
67 |
--------------------------------------------------------------------------------
/draw/src/main/java/com/example/draw/wrappers/Ln.java:
--------------------------------------------------------------------------------
1 | package com.example.draw.wrappers;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Log both to Android logger (so that logs are visible in "adb logcat") and standard output/error (so that they are visible in the terminal
7 | * directly).
8 | */
9 | public final class Ln {
10 |
11 | private static final String TAG = "scrcpy";
12 | private static final String PREFIX = "[server] ";
13 |
14 | enum Level {
15 | VERBOSE, DEBUG, INFO, WARN, ERROR
16 | }
17 |
18 | private static Level threshold = Level.INFO;
19 |
20 | private Ln() {
21 | // not instantiable
22 | }
23 |
24 | /**
25 | * Initialize the log level.
26 | *
27 | * Must be called before starting any new thread.
28 | *
29 | * @param level the log level
30 | */
31 | public static void initLogLevel(Level level) {
32 | threshold = level;
33 | }
34 |
35 | public static boolean isEnabled(Level level) {
36 | return level.ordinal() >= threshold.ordinal();
37 | }
38 |
39 | public static void v(String message) {
40 | if (isEnabled(Level.VERBOSE)) {
41 | Log.v(TAG, message);
42 | System.out.print(PREFIX + "VERBOSE: " + message + '\n');
43 | }
44 | }
45 |
46 | public static void d(String message) {
47 | if (isEnabled(Level.DEBUG)) {
48 | Log.d(TAG, message);
49 | System.out.print(PREFIX + "DEBUG: " + message + '\n');
50 | }
51 | }
52 |
53 | public static void i(String message) {
54 | if (isEnabled(Level.INFO)) {
55 | Log.i(TAG, message);
56 | System.out.print(PREFIX + "INFO: " + message + '\n');
57 | }
58 | }
59 |
60 | public static void w(String message, Throwable throwable) {
61 | if (isEnabled(Level.WARN)) {
62 | Log.w(TAG, message, throwable);
63 | System.err.print(PREFIX + "WARN: " + message + '\n');
64 | if (throwable != null) {
65 | throwable.printStackTrace();
66 | }
67 | }
68 | }
69 |
70 | public static void w(String message) {
71 | w(message, null);
72 | }
73 |
74 | public static void e(String message, Throwable throwable) {
75 | if (isEnabled(Level.ERROR)) {
76 | Log.e(TAG, message, throwable);
77 | System.err.print(PREFIX + "ERROR: " + message + "\n");
78 | if (throwable != null) {
79 | throwable.printStackTrace();
80 | }
81 | }
82 | }
83 |
84 | public static void e(String message) {
85 | e(message, null);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/libs/emscripten/emscripten_mainloop_stub.h:
--------------------------------------------------------------------------------
1 | // What does this file solves?
2 | // - Since Dear ImGui 1.00 we took pride that most of our examples applications had their entire
3 | // main-loop inside the main() function. That's because:
4 | // - It makes the examples easier to read, keeping the code sequential.
5 | // - It permit the use of local variables, making it easier to try things and perform quick
6 | // changes when someone needs to quickly test something (vs having to structure the example
7 | // in order to pass data around). This is very important because people use those examples
8 | // to craft easy-to-past repro when they want to discuss features or report issues.
9 | // - It conveys at a glance that this is a no-BS framework, it won't take your main loop away from you.
10 | // - It is generally nice and elegant.
11 | // - However, comes Emscripten... it is a wonderful and magical tech but it requires a "main loop" function.
12 | // - Only some of our examples would run on Emscripten. Typically the ones rendering with GL or WGPU ones.
13 | // - I tried to refactor those examples but felt it was problematic that other examples didn't follow the
14 | // same layout. Why would the SDL+GL example be structured one way and the SGL+DX11 be structured differently?
15 | // Especially as we are trying hard to convey that using a Dear ImGui backend in an *existing application*
16 | // should requires only a few dozens lines of code, and this should be consistent and symmetrical for all backends.
17 | // - So the next logical step was to refactor all examples to follow that layout of using a "main loop" function.
18 | // This worked, but it made us lose all the nice things we had...
19 |
20 | // Since only about 3 examples really need to run with Emscripten, here's our solution:
21 | // - Use some weird macros and capturing lambda to turn a loop in main() into a function.
22 | // - Hide all that crap in this file so it doesn't make our examples unusually ugly.
23 | // As a stance and principle of Dear ImGui development we don't use C++ headers and we don't
24 | // want to suggest to the newcomer that we would ever use C++ headers as this would affect
25 | // the initial judgment of many of our target audience.
26 | // - Technique is based on this idea: https://github.com/ocornut/imgui/pull/2492/
27 | #ifdef __EMSCRIPTEN__
28 | #include
29 | #include
30 | static std::function MainLoopForEmscriptenP;
31 | static void MainLoopForEmscripten() { MainLoopForEmscriptenP(); }
32 | #define EMSCRIPTEN_MAINLOOP_BEGIN MainLoopForEmscriptenP = [&]()
33 | #define EMSCRIPTEN_MAINLOOP_END ; emscripten_set_main_loop(MainLoopForEmscripten, 0, true)
34 | #else
35 | #define EMSCRIPTEN_MAINLOOP_BEGIN
36 | #define EMSCRIPTEN_MAINLOOP_END
37 | #endif
38 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_sdl3_opengl3/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Cross Platform Makefile
3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
4 | #
5 | # You will need SDL3 (http://www.libsdl.org) which is still unreleased/unpackaged.
6 |
7 | #CXX = g++
8 | #CXX = clang++
9 |
10 | EXE = example_sdl3_opengl3
11 | IMGUI_DIR = ../..
12 | SOURCES = main.cpp
13 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
14 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl3.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
15 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
16 | UNAME_S := $(shell uname -s)
17 | LINUX_GL_LIBS = -lGL
18 |
19 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
20 | CXXFLAGS += -g -Wall -Wformat
21 | LIBS =
22 |
23 | ##---------------------------------------------------------------------
24 | ## OPENGL ES
25 | ##---------------------------------------------------------------------
26 |
27 | ## This assumes a GL ES library available in the system, e.g. libGLESv2.so
28 | # CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2
29 | # LINUX_GL_LIBS = -lGLESv2
30 | ## If you're on a Raspberry Pi and want to use the legacy drivers,
31 | ## use the following instead:
32 | # LINUX_GL_LIBS = -L/opt/vc/lib -lbrcmGLESv2
33 |
34 | ##---------------------------------------------------------------------
35 | ## BUILD FLAGS PER PLATFORM
36 | ##---------------------------------------------------------------------
37 |
38 | ifeq ($(UNAME_S), Linux) #LINUX
39 | ECHO_MESSAGE = "Linux"
40 | LIBS += $(LINUX_GL_LIBS) -ldl `sdl3-config --libs`
41 |
42 | CXXFLAGS += `sdl3-config --cflags`
43 | CFLAGS = $(CXXFLAGS)
44 | endif
45 |
46 | ifeq ($(UNAME_S), Darwin) #APPLE
47 | ECHO_MESSAGE = "Mac OS X"
48 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl3-config --libs`
49 | LIBS += -L/usr/local/lib -L/opt/local/lib
50 |
51 | CXXFLAGS += `sdl3-config --cflags`
52 | CXXFLAGS += -I/usr/local/include -I/opt/local/include
53 | CFLAGS = $(CXXFLAGS)
54 | endif
55 |
56 | ifeq ($(OS), Windows_NT)
57 | ECHO_MESSAGE = "MinGW"
58 | LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl3`
59 |
60 | CXXFLAGS += `pkg-config --cflags sdl3`
61 | CFLAGS = $(CXXFLAGS)
62 | endif
63 |
64 | ##---------------------------------------------------------------------
65 | ## BUILD RULES
66 | ##---------------------------------------------------------------------
67 |
68 | %.o:%.cpp
69 | $(CXX) $(CXXFLAGS) -c -o $@ $<
70 |
71 | %.o:$(IMGUI_DIR)/%.cpp
72 | $(CXX) $(CXXFLAGS) -c -o $@ $<
73 |
74 | %.o:$(IMGUI_DIR)/backends/%.cpp
75 | $(CXX) $(CXXFLAGS) -c -o $@ $<
76 |
77 | all: $(EXE)
78 | @echo Build complete for $(ECHO_MESSAGE)
79 |
80 | $(EXE): $(OBJS)
81 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
82 |
83 | clean:
84 | rm -f $(EXE) $(OBJS)
85 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_glfw_opengl3/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Cross Platform Makefile
3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
4 | #
5 | # You will need GLFW (http://www.glfw.org):
6 | # Linux:
7 | # apt-get install libglfw-dev
8 | # Mac OS X:
9 | # brew install glfw
10 | # MSYS2:
11 | # pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
12 | #
13 |
14 | #CXX = g++
15 | #CXX = clang++
16 |
17 | EXE = example_glfw_opengl3
18 | IMGUI_DIR = ../..
19 | SOURCES = main.cpp
20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
23 | UNAME_S := $(shell uname -s)
24 | LINUX_GL_LIBS = -lGL
25 |
26 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
27 | CXXFLAGS += -g -Wall -Wformat
28 | LIBS =
29 |
30 | ##---------------------------------------------------------------------
31 | ## OPENGL ES
32 | ##---------------------------------------------------------------------
33 |
34 | ## This assumes a GL ES library available in the system, e.g. libGLESv2.so
35 | # CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2
36 | # LINUX_GL_LIBS = -lGLESv2
37 |
38 | ##---------------------------------------------------------------------
39 | ## BUILD FLAGS PER PLATFORM
40 | ##---------------------------------------------------------------------
41 |
42 | ifeq ($(UNAME_S), Linux) #LINUX
43 | ECHO_MESSAGE = "Linux"
44 | LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3`
45 |
46 | CXXFLAGS += `pkg-config --cflags glfw3`
47 | CFLAGS = $(CXXFLAGS)
48 | endif
49 |
50 | ifeq ($(UNAME_S), Darwin) #APPLE
51 | ECHO_MESSAGE = "Mac OS X"
52 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
53 | LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib
54 | #LIBS += -lglfw3
55 | LIBS += -lglfw
56 |
57 | CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
58 | CFLAGS = $(CXXFLAGS)
59 | endif
60 |
61 | ifeq ($(OS), Windows_NT)
62 | ECHO_MESSAGE = "MinGW"
63 | LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
64 |
65 | CXXFLAGS += `pkg-config --cflags glfw3`
66 | CFLAGS = $(CXXFLAGS)
67 | endif
68 |
69 | ##---------------------------------------------------------------------
70 | ## BUILD RULES
71 | ##---------------------------------------------------------------------
72 |
73 | %.o:%.cpp
74 | $(CXX) $(CXXFLAGS) -c -o $@ $<
75 |
76 | %.o:$(IMGUI_DIR)/%.cpp
77 | $(CXX) $(CXXFLAGS) -c -o $@ $<
78 |
79 | %.o:$(IMGUI_DIR)/backends/%.cpp
80 | $(CXX) $(CXXFLAGS) -c -o $@ $<
81 |
82 | all: $(EXE)
83 | @echo Build complete for $(ECHO_MESSAGE)
84 |
85 | $(EXE): $(OBJS)
86 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
87 |
88 | clean:
89 | rm -f $(EXE) $(OBJS)
90 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_sdl2_opengl3/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Cross Platform Makefile
3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
4 | #
5 | # You will need SDL2 (http://www.libsdl.org):
6 | # Linux:
7 | # apt-get install libsdl2-dev
8 | # Mac OS X:
9 | # brew install sdl2
10 | # MSYS2:
11 | # pacman -S mingw-w64-i686-SDL2
12 | #
13 |
14 | #CXX = g++
15 | #CXX = clang++
16 |
17 | EXE = example_sdl2_opengl3
18 | IMGUI_DIR = ../..
19 | SOURCES = main.cpp
20 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
21 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
22 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
23 | UNAME_S := $(shell uname -s)
24 | LINUX_GL_LIBS = -lGL
25 |
26 | CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
27 | CXXFLAGS += -g -Wall -Wformat
28 | LIBS =
29 |
30 | ##---------------------------------------------------------------------
31 | ## OPENGL ES
32 | ##---------------------------------------------------------------------
33 |
34 | ## This assumes a GL ES library available in the system, e.g. libGLESv2.so
35 | # CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2
36 | # LINUX_GL_LIBS = -lGLESv2
37 | ## If you're on a Raspberry Pi and want to use the legacy drivers,
38 | ## use the following instead:
39 | # LINUX_GL_LIBS = -L/opt/vc/lib -lbrcmGLESv2
40 |
41 | ##---------------------------------------------------------------------
42 | ## BUILD FLAGS PER PLATFORM
43 | ##---------------------------------------------------------------------
44 |
45 | ifeq ($(UNAME_S), Linux) #LINUX
46 | ECHO_MESSAGE = "Linux"
47 | LIBS += $(LINUX_GL_LIBS) -ldl `sdl2-config --libs`
48 |
49 | CXXFLAGS += `sdl2-config --cflags`
50 | CFLAGS = $(CXXFLAGS)
51 | endif
52 |
53 | ifeq ($(UNAME_S), Darwin) #APPLE
54 | ECHO_MESSAGE = "Mac OS X"
55 | LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs`
56 | LIBS += -L/usr/local/lib -L/opt/local/lib
57 |
58 | CXXFLAGS += `sdl2-config --cflags`
59 | CXXFLAGS += -I/usr/local/include -I/opt/local/include
60 | CFLAGS = $(CXXFLAGS)
61 | endif
62 |
63 | ifeq ($(OS), Windows_NT)
64 | ECHO_MESSAGE = "MinGW"
65 | LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
66 |
67 | CXXFLAGS += `pkg-config --cflags sdl2`
68 | CFLAGS = $(CXXFLAGS)
69 | endif
70 |
71 | ##---------------------------------------------------------------------
72 | ## BUILD RULES
73 | ##---------------------------------------------------------------------
74 |
75 | %.o:%.cpp
76 | $(CXX) $(CXXFLAGS) -c -o $@ $<
77 |
78 | %.o:$(IMGUI_DIR)/%.cpp
79 | $(CXX) $(CXXFLAGS) -c -o $@ $<
80 |
81 | %.o:$(IMGUI_DIR)/backends/%.cpp
82 | $(CXX) $(CXXFLAGS) -c -o $@ $<
83 |
84 | all: $(EXE)
85 | @echo Build complete for $(ECHO_MESSAGE)
86 |
87 | $(EXE): $(OBJS)
88 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
89 |
90 | clean:
91 | rm -f $(EXE) $(OBJS)
92 |
--------------------------------------------------------------------------------
/draw/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import com.android.tools.r8.R8
2 | import java.io.PrintStream
3 | import java.nio.file.Files
4 | import java.nio.file.Paths
5 | import java.util.stream.Collectors
6 |
7 | @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
8 | plugins {
9 | alias(libs.plugins.androidLibrary)
10 | }
11 |
12 | android {
13 | namespace = "com.example.draw"
14 | compileSdk = 33
15 |
16 | defaultConfig {
17 | minSdk = 28
18 | externalNativeBuild {
19 | cmake {
20 | cppFlags("-std=c++17")
21 | abiFilters("arm64-v8a")
22 | }
23 | }
24 | consumerProguardFiles("consumer-rules.pro")
25 | }
26 |
27 | buildTypes {
28 | release {
29 | isMinifyEnabled = false
30 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
31 | }
32 | }
33 | compileOptions {
34 | sourceCompatibility = JavaVersion.VERSION_1_8
35 | targetCompatibility = JavaVersion.VERSION_1_8
36 | }
37 | buildFeatures {
38 | aidl = true
39 | }
40 | externalNativeBuild {
41 | cmake {
42 | path("src/main/cpp/CMakeLists.txt")
43 | version = "3.22.1"
44 | }
45 | }
46 | ndkVersion = "25.2.9519653"
47 | }
48 | android.libraryVariants.all {
49 | val jarTask = tasks.register("create${name.capitalize()}MainJar") {
50 |
51 | doLast {
52 | val classDir = Paths.get(buildDir.path, "intermediates",
53 | "javac", this@all.name, "classes")
54 |
55 | val classFiles = Files.walk(classDir)
56 | .filter { Files.isRegularFile(it) && it.toString().endsWith(".class") }
57 | .collect(Collectors.toList())
58 |
59 | val androidJar = Paths.get(android.sdkDirectory.path, "platforms",
60 | android.compileSdkVersion, "android.jar")
61 |
62 | val output = Paths.get(
63 | android.sourceSets.getByName("main").assets.srcDirs.first().path, "main.jar")
64 |
65 | if (Files.notExists(output.parent))
66 | Files.createDirectories(output.parent)
67 |
68 | val pgConf = File(buildDir, "mainJar.pro")
69 |
70 | PrintStream(pgConf.outputStream()).use {
71 | it.println("-keep class com.example.draw.Main")
72 | it.println("{ public static void main(java.lang.String[]); }")
73 | }
74 |
75 | val args = mutableListOf(
76 | "--debug", "--output", output,
77 | "--pg-conf", pgConf,
78 | "--classpath", androidJar
79 | ).apply { addAll(classFiles) }
80 | .map { it.toString() }
81 | .toTypedArray()
82 |
83 | R8.main(args)
84 | }
85 | }
86 | javaCompileProvider {
87 | finalizedBy(jarTask)
88 | }
89 | }
90 | dependencies {
91 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/backends/imgui_impl_glut.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Platform Backend for GLUT/FreeGLUT
2 | // This needs to be used along with a Renderer (e.g. OpenGL2)
3 |
4 | // !!! GLUT/FreeGLUT IS OBSOLETE PREHISTORIC SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
5 | // !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!!
6 | // !!! Nowadays, prefer using GLFW or SDL instead!
7 |
8 | // Implemented features:
9 | // [X] Platform: Partial keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLUT values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
10 | // Issues:
11 | // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I
12 | // [ ] Platform: Missing horizontal mouse wheel support.
13 | // [ ] Platform: Missing mouse cursor shape/visibility support.
14 | // [ ] Platform: Missing clipboard support (not supported by Glut).
15 | // [ ] Platform: Missing gamepad support.
16 |
17 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
18 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
19 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
20 | // Read online: https://github.com/ocornut/imgui/tree/master/docs
21 |
22 | #pragma once
23 | #include "imgui.h" // IMGUI_IMPL_API
24 |
25 | IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
26 | IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
27 | IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown();
28 | IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame();
29 |
30 | // You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically,
31 | // or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency..
32 | //---------------------------------------- GLUT name --------------------------------------------- Decent Name ---------
33 | IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc
34 | IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc
35 | IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc
36 | IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc
37 | IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc
38 | IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
39 | IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
40 | IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
41 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/backends/imgui_impl_opengl3.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
2 | // - Desktop GL: 2.x 3.x 4.x
3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4 | // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
5 |
6 | // Implemented features:
7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8 | // [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
9 |
10 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
11 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
12 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
13 | // Read online: https://github.com/ocornut/imgui/tree/master/docs
14 |
15 | // About GLSL version:
16 | // The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
17 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
18 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
19 |
20 | #pragma once
21 | #include "imgui.h" // IMGUI_IMPL_API
22 |
23 | // Backend API
24 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
25 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
26 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
27 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
28 |
29 | // (Optional) Called by Init/NewFrame/Shutdown
30 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
31 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
32 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
33 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
34 |
35 | // Specific OpenGL ES versions
36 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
37 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
38 |
39 | // You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
40 | #if !defined(IMGUI_IMPL_OPENGL_ES2) \
41 | && !defined(IMGUI_IMPL_OPENGL_ES3)
42 |
43 | // Try to detect GLES on matching platforms
44 | #if defined(__APPLE__)
45 | #include
46 | #endif
47 | #if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
48 | #define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
49 | #elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
50 | #define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
51 | #else
52 | // Otherwise imgui_impl_opengl3_loader.h will be used.
53 | #endif
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_null/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Cross Platform Makefile
3 | # Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
4 | #
5 | # Important: This is a "null backend" application, with no visible output or interaction!
6 | # This is used for testing purpose and continuous integration, and has little use for end-user.
7 | #
8 |
9 | # Options
10 | WITH_EXTRA_WARNINGS ?= 0
11 | WITH_FREETYPE ?= 0
12 |
13 | EXE = example_null
14 | IMGUI_DIR = ../..
15 | SOURCES = main.cpp
16 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
17 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
18 | UNAME_S := $(shell uname -s)
19 |
20 | CXXFLAGS += -std=c++11 -I$(IMGUI_DIR)
21 | CXXFLAGS += -g -Wall -Wformat
22 | LIBS =
23 |
24 | # We use the WITH_EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings
25 | ifeq ($(WITH_EXTRA_WARNINGS), 1)
26 | CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros
27 | endif
28 |
29 | # We use the WITH_FREETYPE flag on our CI setup to test compiling misc/freetype/imgui_freetype.cpp
30 | # (only supported on Linux, and note that the imgui_freetype code currently won't be executed)
31 | ifeq ($(WITH_FREETYPE), 1)
32 | SOURCES += $(IMGUI_DIR)/misc/freetype/imgui_freetype.cpp
33 | CXXFLAGS += $(shell pkg-config --cflags freetype2)
34 | LIBS += $(shell pkg-config --libs freetype2)
35 | endif
36 |
37 | ##---------------------------------------------------------------------
38 | ## BUILD FLAGS PER PLATFORM
39 | ##---------------------------------------------------------------------
40 |
41 | ifeq ($(UNAME_S), Linux) #LINUX
42 | ECHO_MESSAGE = "Linux"
43 | ifeq ($(WITH_EXTRA_WARNINGS), 1)
44 | CXXFLAGS += -Wextra -Wpedantic
45 | ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1)
46 | CXXFLAGS += -Wshadow -Wsign-conversion
47 | endif
48 | endif
49 | CFLAGS = $(CXXFLAGS)
50 | endif
51 |
52 | ifeq ($(UNAME_S), Darwin) #APPLE
53 | ECHO_MESSAGE = "Mac OS X"
54 | ifeq ($(WITH_EXTRA_WARNINGS), 1)
55 | CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-poison-system-directories
56 | endif
57 | CFLAGS = $(CXXFLAGS)
58 | endif
59 |
60 | ifeq ($(OS), Windows_NT)
61 | ECHO_MESSAGE = "MinGW"
62 | ifeq ($(WITH_EXTRA_WARNINGS), 1)
63 | CXXFLAGS += -Wextra -Wpedantic
64 | endif
65 | LIBS += -limm32
66 | CFLAGS = $(CXXFLAGS)
67 | endif
68 |
69 | ##---------------------------------------------------------------------
70 | ## BUILD RULES
71 | ##---------------------------------------------------------------------
72 |
73 | %.o:%.cpp
74 | $(CXX) $(CXXFLAGS) -c -o $@ $<
75 |
76 | %.o:$(IMGUI_DIR)/%.cpp
77 | $(CXX) $(CXXFLAGS) -c -o $@ $<
78 |
79 | %.o:$(IMGUI_DIR)/backends/%.cpp
80 | $(CXX) $(CXXFLAGS) -c -o $@ $<
81 |
82 | %.o:$(IMGUI_DIR)/misc/freetype/%.cpp
83 | $(CXX) $(CXXFLAGS) -c -o $@ $<
84 |
85 | all: $(EXE)
86 | @echo Build complete for $(ECHO_MESSAGE)
87 |
88 | $(EXE): $(OBJS)
89 | $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
90 |
91 | clean:
92 | rm -f $(EXE) $(OBJS)
93 |
--------------------------------------------------------------------------------
/draw/src/main/java/com/example/draw/wrappers/InputManager.java:
--------------------------------------------------------------------------------
1 | package com.example.draw.wrappers;
2 |
3 | import android.view.InputEvent;
4 | import android.view.MotionEvent;
5 |
6 | import java.lang.reflect.InvocationTargetException;
7 | import java.lang.reflect.Method;
8 |
9 | public final class InputManager {
10 |
11 | public static final int INJECT_INPUT_EVENT_MODE_ASYNC = 0;
12 | public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT = 1;
13 | public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2;
14 |
15 | private final android.hardware.input.InputManager manager;
16 | private Method injectInputEventMethod;
17 |
18 | private static Method setDisplayIdMethod;
19 | private static Method setActionButtonMethod;
20 |
21 | public InputManager(android.hardware.input.InputManager manager) {
22 | this.manager = manager;
23 | }
24 |
25 | private Method getInjectInputEventMethod() throws NoSuchMethodException {
26 | if (injectInputEventMethod == null) {
27 | injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class);
28 | }
29 | return injectInputEventMethod;
30 | }
31 |
32 | public boolean injectInputEvent(InputEvent inputEvent, int mode) {
33 | try {
34 | Method method = getInjectInputEventMethod();
35 | return (boolean) method.invoke(manager, inputEvent, mode);
36 | } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
37 | Ln.e("Could not invoke method", e);
38 | return false;
39 | }
40 | }
41 |
42 | private static Method getSetDisplayIdMethod() throws NoSuchMethodException {
43 | if (setDisplayIdMethod == null) {
44 | setDisplayIdMethod = InputEvent.class.getMethod("setDisplayId", int.class);
45 | }
46 | return setDisplayIdMethod;
47 | }
48 |
49 | public static boolean setDisplayId(InputEvent inputEvent, int displayId) {
50 | try {
51 | Method method = getSetDisplayIdMethod();
52 | method.invoke(inputEvent, displayId);
53 | return true;
54 | } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
55 | Ln.e("Cannot associate a display id to the input event", e);
56 | return false;
57 | }
58 | }
59 |
60 | private static Method getSetActionButtonMethod() throws NoSuchMethodException {
61 | if (setActionButtonMethod == null) {
62 | setActionButtonMethod = MotionEvent.class.getMethod("setActionButton", int.class);
63 | }
64 | return setActionButtonMethod;
65 | }
66 |
67 | public static boolean setActionButton(MotionEvent motionEvent, int actionButton) {
68 | try {
69 | Method method = getSetActionButtonMethod();
70 | method.invoke(motionEvent, actionButton);
71 | return true;
72 | } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
73 | Ln.e("Cannot set action button on MotionEvent", e);
74 | return false;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/backends/imgui_impl_metal.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Renderer Backend for Metal
2 | // This needs to be used along with a Platform Backend (e.g. OSX)
3 |
4 | // Implemented features:
5 | // [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID!
6 | // [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
7 |
8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs
12 |
13 | #include "imgui.h" // IMGUI_IMPL_API
14 |
15 | //-----------------------------------------------------------------------------
16 | // ObjC API
17 | //-----------------------------------------------------------------------------
18 |
19 | #ifdef __OBJC__
20 |
21 | @class MTLRenderPassDescriptor;
22 | @protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder;
23 |
24 | IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id device);
25 | IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
26 | IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
27 | IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
28 | id commandBuffer,
29 | id commandEncoder);
30 |
31 | // Called by Init/NewFrame/Shutdown
32 | IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id device);
33 | IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
34 | IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id device);
35 | IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
36 |
37 | #endif
38 |
39 | //-----------------------------------------------------------------------------
40 | // C++ API
41 | //-----------------------------------------------------------------------------
42 |
43 | // Enable Metal C++ binding support with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file
44 | // More info about using Metal from C++: https://developer.apple.com/metal/cpp/
45 |
46 | #ifdef IMGUI_IMPL_METAL_CPP
47 | #include
48 | #ifndef __OBJC__
49 |
50 | IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
51 | IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
52 | IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
53 | IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
54 | MTL::CommandBuffer* commandBuffer,
55 | MTL::RenderCommandEncoder* commandEncoder);
56 |
57 | // Called by Init/NewFrame/Shutdown
58 | IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(MTL::Device* device);
59 | IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture();
60 | IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device);
61 | IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects();
62 |
63 | #endif
64 | #endif
65 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/backends/imgui_impl_win32.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Platform Backend for Windows (standard windows API for 32-bits AND 64-bits applications)
2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
3 |
4 | // Implemented features:
5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
6 | // [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen.
7 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy VK_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
9 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
10 |
11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
13 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
14 | // Read online: https://github.com/ocornut/imgui/tree/master/docs
15 |
16 | #pragma once
17 | #include "imgui.h" // IMGUI_IMPL_API
18 |
19 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
20 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
21 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
22 |
23 | // Win32 message handler your application need to call.
24 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper.
25 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
26 | // - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE.
27 |
28 | #if 0
29 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
30 | #endif
31 |
32 | // DPI-related helpers (optional)
33 | // - Use to enable DPI awareness without having to create an application manifest.
34 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
35 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
36 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
37 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
38 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
39 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
40 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
41 |
42 | // Transparency related helpers (optional) [experimental]
43 | // - Use to enable alpha compositing transparency with the desktop.
44 | // - Use together with e.g. clearing your framebuffer with zero-alpha.
45 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
46 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_emscripten_wgpu/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile to use with emscripten
3 | # See https://emscripten.org/docs/getting_started/downloads.html
4 | # for installation instructions.
5 | #
6 | # This Makefile assumes you have loaded emscripten's environment.
7 | # (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead)
8 | #
9 | # Running `make` will produce three files:
10 | # - web/index.html (current stored in the repository)
11 | # - web/index.js
12 | # - web/index.wasm
13 | #
14 | # All three are needed to run the demo.
15 |
16 | CC = emcc
17 | CXX = em++
18 | WEB_DIR = web
19 | EXE = $(WEB_DIR)/index.js
20 | IMGUI_DIR = ../..
21 | SOURCES = main.cpp
22 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
23 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_wgpu.cpp
24 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
25 | UNAME_S := $(shell uname -s)
26 | CPPFLAGS =
27 | LDFLAGS =
28 | EMS =
29 |
30 | ##---------------------------------------------------------------------
31 | ## EMSCRIPTEN OPTIONS
32 | ##---------------------------------------------------------------------
33 |
34 | # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only)
35 | EMS += -s DISABLE_EXCEPTION_CATCHING=1
36 | LDFLAGS += -s USE_GLFW=3 -s USE_WEBGPU=1
37 | LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1
38 |
39 | # Emscripten allows preloading a file or folder to be accessible at runtime.
40 | # The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
41 | # See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
42 | # (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
43 | USE_FILE_SYSTEM ?= 0
44 | ifeq ($(USE_FILE_SYSTEM), 0)
45 | LDFLAGS += -s NO_FILESYSTEM=1
46 | CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
47 | endif
48 | ifeq ($(USE_FILE_SYSTEM), 1)
49 | LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
50 | endif
51 |
52 | ##---------------------------------------------------------------------
53 | ## FINAL BUILD FLAGS
54 | ##---------------------------------------------------------------------
55 |
56 | CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
57 | #CPPFLAGS += -g
58 | CPPFLAGS += -Wall -Wformat -Os $(EMS)
59 | #LDFLAGS += --shell-file shell_minimal.html
60 | LDFLAGS += $(EMS)
61 |
62 | ##---------------------------------------------------------------------
63 | ## BUILD RULES
64 | ##---------------------------------------------------------------------
65 |
66 | %.o:%.cpp
67 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
68 |
69 | %.o:$(IMGUI_DIR)/%.cpp
70 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
71 |
72 | %.o:$(IMGUI_DIR)/backends/%.cpp
73 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
74 |
75 | all: $(EXE)
76 | @echo Build complete for $(EXE)
77 |
78 | $(WEB_DIR):
79 | mkdir $@
80 |
81 | serve: all
82 | python3 -m http.server -d $(WEB_DIR)
83 |
84 | $(EXE): $(OBJS) $(WEB_DIR)
85 | $(CXX) -o $@ $(OBJS) $(LDFLAGS)
86 |
87 | clean:
88 | rm -f $(EXE) $(OBJS) $(WEB_DIR)/*.js $(WEB_DIR)/*.wasm $(WEB_DIR)/*.wasm.pre
89 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/misc/cpp/imgui_stdlib.cpp:
--------------------------------------------------------------------------------
1 | // dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
2 | // This is also an example of how you may wrap your own similar types.
3 |
4 | // Changelog:
5 | // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
6 |
7 | // See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
8 | // https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
9 |
10 | #include "imgui.h"
11 | #include "imgui_stdlib.h"
12 |
13 | struct InputTextCallback_UserData
14 | {
15 | std::string* Str;
16 | ImGuiInputTextCallback ChainCallback;
17 | void* ChainCallbackUserData;
18 | };
19 |
20 | static int InputTextCallback(ImGuiInputTextCallbackData* data)
21 | {
22 | InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData;
23 | if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
24 | {
25 | // Resize string callback
26 | // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want.
27 | std::string* str = user_data->Str;
28 | IM_ASSERT(data->Buf == str->c_str());
29 | str->resize(data->BufTextLen);
30 | data->Buf = (char*)str->c_str();
31 | }
32 | else if (user_data->ChainCallback)
33 | {
34 | // Forward to user callback, if any
35 | data->UserData = user_data->ChainCallbackUserData;
36 | return user_data->ChainCallback(data);
37 | }
38 | return 0;
39 | }
40 |
41 | bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
42 | {
43 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
44 | flags |= ImGuiInputTextFlags_CallbackResize;
45 |
46 | InputTextCallback_UserData cb_user_data;
47 | cb_user_data.Str = str;
48 | cb_user_data.ChainCallback = callback;
49 | cb_user_data.ChainCallbackUserData = user_data;
50 | return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
51 | }
52 |
53 | bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
54 | {
55 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
56 | flags |= ImGuiInputTextFlags_CallbackResize;
57 |
58 | InputTextCallback_UserData cb_user_data;
59 | cb_user_data.Str = str;
60 | cb_user_data.ChainCallback = callback;
61 | cb_user_data.ChainCallbackUserData = user_data;
62 | return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data);
63 | }
64 |
65 | bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
66 | {
67 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
68 | flags |= ImGuiInputTextFlags_CallbackResize;
69 |
70 | InputTextCallback_UserData cb_user_data;
71 | cb_user_data.Str = str;
72 | cb_user_data.ChainCallback = callback;
73 | cb_user_data.ChainCallbackUserData = user_data;
74 | return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
75 | }
76 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_glfw_opengl3/Makefile.emscripten:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile to use with GLFW+emscripten
3 | # See https://emscripten.org/docs/getting_started/downloads.html
4 | # for installation instructions.
5 | #
6 | # This Makefile assumes you have loaded emscripten's environment.
7 | # (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead)
8 | #
9 | # Running `make -f Makefile.emscripten` will produce three files:
10 | # - web/index.html
11 | # - web/index.js
12 | # - web/index.wasm
13 | #
14 | # All three are needed to run the demo.
15 |
16 | CC = emcc
17 | CXX = em++
18 | WEB_DIR = web
19 | EXE = $(WEB_DIR)/index.html
20 | IMGUI_DIR = ../..
21 | SOURCES = main.cpp
22 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
23 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
24 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
25 | UNAME_S := $(shell uname -s)
26 | CPPFLAGS =
27 | LDFLAGS =
28 | EMS =
29 |
30 | ##---------------------------------------------------------------------
31 | ## EMSCRIPTEN OPTIONS
32 | ##---------------------------------------------------------------------
33 |
34 | # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only)
35 | EMS += -s DISABLE_EXCEPTION_CATCHING=1
36 | LDFLAGS += -s USE_GLFW=3 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1
37 |
38 | # Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
39 | #EMS += -s BINARYEN_TRAP_MODE=clamp
40 | #EMS += -s SAFE_HEAP=1 ## Adds overhead
41 |
42 | # Emscripten allows preloading a file or folder to be accessible at runtime.
43 | # The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
44 | # See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
45 | # (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
46 | USE_FILE_SYSTEM ?= 0
47 | ifeq ($(USE_FILE_SYSTEM), 0)
48 | LDFLAGS += -s NO_FILESYSTEM=1
49 | CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
50 | endif
51 | ifeq ($(USE_FILE_SYSTEM), 1)
52 | LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
53 | endif
54 |
55 | ##---------------------------------------------------------------------
56 | ## FINAL BUILD FLAGS
57 | ##---------------------------------------------------------------------
58 |
59 | CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
60 | #CPPFLAGS += -g
61 | CPPFLAGS += -Wall -Wformat -Os $(EMS)
62 | # LDFLAGS += --shell-file ../libs/emscripten/shell_minimal.html
63 | LDFLAGS += $(EMS)
64 |
65 | ##---------------------------------------------------------------------
66 | ## BUILD RULES
67 | ##---------------------------------------------------------------------
68 |
69 | %.o:%.cpp
70 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
71 |
72 | %.o:$(IMGUI_DIR)/%.cpp
73 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
74 |
75 | %.o:$(IMGUI_DIR)/backends/%.cpp
76 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
77 |
78 | all: $(EXE)
79 | @echo Build complete for $(EXE)
80 |
81 | $(WEB_DIR):
82 | mkdir $@
83 |
84 | serve: all
85 | python3 -m http.server -d $(WEB_DIR)
86 |
87 | $(EXE): $(OBJS) $(WEB_DIR)
88 | $(CXX) -o $@ $(OBJS) $(LDFLAGS)
89 |
90 | clean:
91 | rm -rf $(OBJS) $(WEB_DIR)
92 |
--------------------------------------------------------------------------------
/draw/src/main/cpp/imgui/examples/example_sdl2_opengl3/Makefile.emscripten:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile to use with SDL+emscripten
3 | # See https://emscripten.org/docs/getting_started/downloads.html
4 | # for installation instructions.
5 | #
6 | # This Makefile assumes you have loaded emscripten's environment.
7 | # (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead)
8 | #
9 | # Running `make -f Makefile.emscripten` will produce three files:
10 | # - web/index.html
11 | # - web/index.js
12 | # - web/index.wasm
13 | #
14 | # All three are needed to run the demo.
15 |
16 | CC = emcc
17 | CXX = em++
18 | WEB_DIR = web
19 | EXE = $(WEB_DIR)/index.html
20 | IMGUI_DIR = ../..
21 | SOURCES = main.cpp
22 | SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
23 | SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp
24 | OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
25 | UNAME_S := $(shell uname -s)
26 | CPPFLAGS =
27 | LDFLAGS =
28 | EMS =
29 |
30 | ##---------------------------------------------------------------------
31 | ## EMSCRIPTEN OPTIONS
32 | ##---------------------------------------------------------------------
33 |
34 | # ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only)
35 | EMS += -s USE_SDL=2
36 | EMS += -s DISABLE_EXCEPTION_CATCHING=1
37 | LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1
38 |
39 | # Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877)
40 | #EMS += -s BINARYEN_TRAP_MODE=clamp
41 | #EMS += -s SAFE_HEAP=1 ## Adds overhead
42 |
43 | # Emscripten allows preloading a file or folder to be accessible at runtime.
44 | # The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
45 | # See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
46 | # (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
47 | USE_FILE_SYSTEM ?= 0
48 | ifeq ($(USE_FILE_SYSTEM), 0)
49 | LDFLAGS += -s NO_FILESYSTEM=1
50 | CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
51 | endif
52 | ifeq ($(USE_FILE_SYSTEM), 1)
53 | LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts
54 | endif
55 |
56 | ##---------------------------------------------------------------------
57 | ## FINAL BUILD FLAGS
58 | ##---------------------------------------------------------------------
59 |
60 | CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
61 | #CPPFLAGS += -g
62 | CPPFLAGS += -Wall -Wformat -Os $(EMS)
63 | LDFLAGS += --shell-file ../libs/emscripten/shell_minimal.html
64 | LDFLAGS += $(EMS)
65 |
66 | ##---------------------------------------------------------------------
67 | ## BUILD RULES
68 | ##---------------------------------------------------------------------
69 |
70 | %.o:%.cpp
71 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
72 |
73 | %.o:$(IMGUI_DIR)/%.cpp
74 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
75 |
76 | %.o:$(IMGUI_DIR)/backends/%.cpp
77 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
78 |
79 | all: $(EXE)
80 | @echo Build complete for $(EXE)
81 |
82 | $(WEB_DIR):
83 | mkdir $@
84 |
85 | serve: all
86 | python3 -m http.server -d $(WEB_DIR)
87 |
88 | $(EXE): $(OBJS) $(WEB_DIR)
89 | $(CXX) -o $@ $(OBJS) $(LDFLAGS)
90 |
91 | clean:
92 | rm -rf $(OBJS) $(WEB_DIR)
93 |
--------------------------------------------------------------------------------