Skip to content

Commit 7aa2e5e

Browse files
committed
Update setup.sh to use array of sources, swap main CPP file for existing one in examples/example_sdl3_opengl3/main.cpp
1 parent a39c299 commit 7aa2e5e

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

examples/example_android_sdl3_opengl3/setup.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,38 @@ if [ ! -d "${SDL_DIR}" ]; then
1212
git submodule update --init --recursive
1313
fi
1414

15+
SOURCES=( \
16+
"../../imgui.h " \
17+
"../../imgui.cpp " \
18+
"../../imconfig.h " \
19+
"../../imstb_rectpack.h " \
20+
"../../imstb_textedit.h " \
21+
"../../imstb_truetype.h " \
22+
"../../imgui_internal.h " \
23+
"../../imgui_widgets.cpp " \
24+
"../../imgui_tables.cpp " \
25+
"../../imgui_draw.cpp " \
26+
"../../imgui_demo.cpp " \
27+
"../../backends/imgui_impl_opengl3.cpp " \
28+
"../../backends/imgui_impl_opengl3.h " \
29+
"../../backends/imgui_impl_sdl3.cpp " \
30+
"../../backends/imgui_impl_sdl3.h " \
31+
"../../examples/example_sdl3_opengl3/main.cpp")
32+
33+
SOURCE_AS_STR=""
34+
for val in "${SOURCES[@]}";
35+
do
36+
SOURCE_AS_STR+=$val
37+
done
38+
39+
echo -n $SOURCE_AS_STR
40+
1541
ANDROID_JNI_PATH="${SDL_DIR}/build/${JAVA_PKG_NAME}/app/jni/src"
1642
ANDROID_STRINGS_PATH="${SDL_DIR}/build/${JAVA_PKG_NAME}/app/src/main/res/values"
1743

1844

1945
if [ ! -d "${ANDROID_JNI_PATH}" ]; then
20-
bash ${SDL_BUILD_SCRIPTS_DIR}/androidbuild.sh $JAVA_PKG_NAME < ../../imgui.cpp ../../imgui.h ../../imconfig.h ../../imstb_rectpack.h ../../imstb_textedit.h ../../imstb_truetype.h ../../imgui_internal.h imconfig.h ../../imgui_widgets.cpp ../../imgui_tables.cpp ../../imgui_draw.cpp ../../imgui_demo.cpp ../../backends/imgui_impl_opengl3.cpp ../../backends/imgui_impl_opengl3.h ../../backends/imgui_impl_sdl3.cpp ../../backends/imgui_impl_sdl3.h DearImGuiDemo.cpp
46+
bash ${SDL_BUILD_SCRIPTS_DIR}/androidbuild.sh $JAVA_PKG_NAME < "${SOURCE_AS_STR}"
2147
sed -i -e "s|-lGLESv2|-lGLESv2 -lGLESv3|" $ANDROID_JNI_PATH/Android.mk
2248
sed -i -e "s|Game|$APP_NAME|g" $ANDROID_STRINGS_PATH/strings.xml
2349
fi

examples/example_sdl3_opengl3/main.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
#include "imgui.h"
1111
#include "imgui_impl_sdl3.h"
1212
#include "imgui_impl_opengl3.h"
13+
1314
#include <stdio.h>
14-
#include <SDL3/SDL.h>
15+
16+
#include <SDL3/SDL_main.h>
17+
#include <SDL3/SDL_test_common.h>
18+
1519
#if defined(IMGUI_IMPL_OPENGL_ES2)
1620
#include <SDL3/SDL_opengles2.h>
21+
#elif defined(IMGUI_IMPL_OPENGL_ES3)
22+
#include <GLES3/gl3.h>
23+
#include <SDL3/SDL_opengles2.h>
1724
#else
1825
#include <SDL3/SDL_opengl.h>
1926
#endif
@@ -41,6 +48,13 @@ int main(int, char**)
4148
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
4249
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
4350
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
51+
#elif defined(IMGUI_IMPL_OPENGL_ES3)
52+
// GL ES 3.0 + GLSL 100
53+
const char* glsl_version = "#version 100";
54+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
55+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
56+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
57+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
4458
#elif defined(__APPLE__)
4559
// GL 3.2 Core + GLSL 150
4660
const char* glsl_version = "#version 150";

0 commit comments

Comments
 (0)