| 25 | void bindImageTextureFunctions(); |
| 26 | |
| 27 | void init(struct android_app *app) |
| 28 | { |
| 29 | if (g_Initialized) |
| 30 | return; |
| 31 | |
| 32 | g_App = app; |
| 33 | ANativeWindow_acquire(g_App->window); |
| 34 | |
| 35 | // Initialize EGL |
| 36 | // This is mostly boilerplate code for EGL... |
| 37 | { |
| 38 | g_EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
| 39 | if (g_EglDisplay == EGL_NO_DISPLAY) |
| 40 | __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglGetDisplay(EGL_DEFAULT_DISPLAY) returned EGL_NO_DISPLAY"); |
| 41 | |
| 42 | if (eglInitialize(g_EglDisplay, 0, 0) != EGL_TRUE) |
| 43 | __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglInitialize() returned with an error"); |
| 44 | |
| 45 | const EGLint egl_attributes[] = {EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE}; |
| 46 | EGLint num_configs = 0; |
| 47 | if (eglChooseConfig(g_EglDisplay, egl_attributes, nullptr, 0, &num_configs) != EGL_TRUE) |
| 48 | __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglChooseConfig() returned with an error"); |
| 49 | if (num_configs == 0) |
| 50 | __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglChooseConfig() returned 0 matching config"); |
| 51 | |
| 52 | // Get the first matching config |
| 53 | EGLConfig egl_config; |
| 54 | eglChooseConfig(g_EglDisplay, egl_attributes, &egl_config, 1, &num_configs); |
| 55 | EGLint egl_format; |
| 56 | eglGetConfigAttrib(g_EglDisplay, egl_config, EGL_NATIVE_VISUAL_ID, &egl_format); |
| 57 | ANativeWindow_setBuffersGeometry(g_App->window, 0, 0, egl_format); |
| 58 | |
| 59 | const EGLint egl_context_attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; |
| 60 | g_EglContext = eglCreateContext(g_EglDisplay, egl_config, EGL_NO_CONTEXT, egl_context_attributes); |
| 61 | |
| 62 | if (g_EglContext == EGL_NO_CONTEXT) |
| 63 | __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglCreateContext() returned EGL_NO_CONTEXT"); |
| 64 | |
| 65 | g_EglSurface = eglCreateWindowSurface(g_EglDisplay, egl_config, g_App->window, NULL); |
| 66 | eglMakeCurrent(g_EglDisplay, g_EglSurface, g_EglSurface, g_EglContext); |
| 67 | } |
| 68 | |
| 69 | if (!was_init) |
| 70 | { |
| 71 | // Setup Dear ImGui context |
| 72 | IMGUI_CHECKVERSION(); |
| 73 | ImGui::CreateContext(); |
| 74 | ImGuiIO &io = ImGui::GetIO(); |
| 75 | |
| 76 | // Disable loading/saving of .ini file from disk. |
| 77 | // FIXME: Consider using LoadIniSettingsFromMemory() / SaveIniSettingsToMemory() to save in appropriate location for Android. |
| 78 | io.IniFilename = NULL; |
| 79 | } |
| 80 | |
| 81 | // Setup Platform/Renderer backends |
| 82 | ImGui_ImplAndroid_Init(g_App->window); |
| 83 | ImGui_ImplOpenGL3_Init("#version 300 es"); |
| 84 |
no test coverage detected