diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 259148f..0000000 --- a/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 6bea905..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "examples/thirdparty/imgui"] - path = examples/thirdparty/imgui - url = https://github.com/ocornut/imgui.git -[submodule "examples/thirdparty/sdl2-cmake-modules"] - path = examples/thirdparty/sdl2-cmake-modules - url = https://github.com/aminosbh/sdl2-cmake-modules.git diff --git a/README.md b/README.md index 6a82092..fd77a9b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # imapp -Standalone application starter kit for [Dear ImGui](https://github.com/ocornut/imgui) +Standalone application framework for [Dear ImGui](https://github.com/ocornut/imgui) ## Features @@ -84,7 +84,7 @@ IMAPP_MAIN("Minimal Example") // Setup/Process events/Rendering/Shutdown ## Building -Note: Consult `examples/` directory for CMake build example. +Note: Consult [imapp-template](https://github.com/remyroez/imapp-template) for build example using CMake. ### Add required files @@ -142,7 +142,6 @@ Note: Consult `examples/` directory for CMake build example. ## TODO -- Split examples directory into separate repo - Setup build/test on GitHub Actions - Test on Windows/macOS - Support iOS/Android @@ -151,8 +150,7 @@ Note: Consult `examples/` directory for CMake build example. ## Links - [Dear ImGui](https://github.com/ocornut/imgui) -- [SDL2 CMake modules](https://github.com/aminosbh/sdl2-cmake-modules) -- [stb](https://github.com/nothings/stb) +- [stb](https://github.com/nothings/stb) (Texture loading API using stb_image.h) - [martty/imgui](https://github.com/martty/imgui) (User texture binding for Vulkan Renderer) ## License diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index d708b35..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -cmake_policy(SET CMP0076 NEW) - -# CMake Module path -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/sdl2-cmake-modules) - -# Project and Executable -project(imapp_example C CXX) -add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE) - -# Copy example resources -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MyImage01.jpg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -# Dear ImGui -include(cmake/imgui.cmake) -target_link_libraries(${PROJECT_NAME} ${IMGUI_LIBRARIES}) - -# Emscripten options -if(EMSCRIPTEN) - set(CMAKE_EXECUTABLE_SUFFIX ".html") - set(IMAPP_EXAMPLE_EMSCRIPTEN_SHELL ${IMGUI_EXAMPLE_DIR}/example_emscripten/shell_minimal.html) - set(IMAPP_EXAMPLE_PRELOAD_FILE "MyImage01.jpg") - set(IMAPP_EXAMPLE_LINK_FLAGS "-s USE_SDL=2 -s WASM=1 -s FETCH=1") - string(APPEND IMAPP_EXAMPLE_LINK_FLAGS " -s ALLOW_MEMORY_GROWTH=1") - string(APPEND IMAPP_EXAMPLE_LINK_FLAGS " -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0") - string(APPEND IMAPP_EXAMPLE_LINK_FLAGS " -s ASSERTIONS=1") - string(APPEND IMAPP_EXAMPLE_LINK_FLAGS " --no-heap-copy --preload-file ${IMAPP_EXAMPLE_PRELOAD_FILE}") - string(APPEND IMAPP_EXAMPLE_LINK_FLAGS " --preload-file ${IMGUI_INCLUDE_DIR}/misc/fonts@/fonts") - string(APPEND IMAPP_EXAMPLE_LINK_FLAGS " --shell-file ${IMAPP_EXAMPLE_EMSCRIPTEN_SHELL}") - set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${IMAPP_EXAMPLE_LINK_FLAGS}) -endif() - -# Standalone application starter kit -include(cmake/imapp.cmake) -target_link_libraries(${PROJECT_NAME} ${IMAPP_LIBRARIES}) - -# Example options -option(IMAPP_EXAMPLE_MINIMAL "Minimal example" OFF) - -# Example sources -if(IMAPP_EXAMPLE_MINIMAL) - target_sources(${PROJECT_NAME} PRIVATE main_minimal.cpp) -elseif(EMSCRIPTEN) - target_sources(${PROJECT_NAME} PRIVATE main_emscripten.cpp) -else() - target_sources(${PROJECT_NAME} PRIVATE main.cpp) -endif() - diff --git a/examples/MyImage01.jpg b/examples/MyImage01.jpg deleted file mode 100644 index ac02db2..0000000 Binary files a/examples/MyImage01.jpg and /dev/null differ diff --git a/examples/cmake/gl3w.cmake b/examples/cmake/gl3w.cmake deleted file mode 100644 index 31cab1d..0000000 --- a/examples/cmake/gl3w.cmake +++ /dev/null @@ -1,17 +0,0 @@ - -set(GL3W_PATH ${CMAKE_SOURCE_DIR}/thirdparty/imgui/examples/libs/gl3w) -set(GL3W_SOURCE_DIR ${GL3W_PATH}/GL) -set(GL3W_INCLUDE_DIR ${GL3W_PATH}) - -add_library(gl3w STATIC) - -target_sources(gl3w PRIVATE - ${GL3W_SOURCE_DIR}/gl3w.c -) -target_include_directories(gl3w PUBLIC ${GL3W_INCLUDE_DIR}) -target_link_libraries(gl3w ${CMAKE_DL_LIBS}) - -find_package(OpenGL REQUIRED) -target_link_libraries(gl3w OpenGL::GLX) - -set(GL3W_LIBRARIES gl3w) diff --git a/examples/cmake/imapp.cmake b/examples/cmake/imapp.cmake deleted file mode 100644 index c3ddebc..0000000 --- a/examples/cmake/imapp.cmake +++ /dev/null @@ -1,137 +0,0 @@ - -set(IMAPP_SOURCE_DIR ${CMAKE_SOURCE_DIR}/..) -set(IMAPP_INCLUDE_DIR ${IMAPP_SOURCE_DIR}) - -# Standalone application starter kit -add_library(imapp STATIC) -target_include_directories(imapp PUBLIC ${IMAPP_INCLUDE_DIR}) - -# System options -set(IMAPP_SYSTEM_EMSCRIPTEN OFF) -if(EMSCRIPTEN) - set(IMAPP_SYSTEM_EMSCRIPTEN ON) - target_compile_definitions(imapp PUBLIC IMAPP_SYSTEM_EMSCRIPTEN) -endif() - -# Platform options -set(IMAPP_PLATFORM "SDL2" CACHE STRING "Platform Binding") -string(TOUPPER ${IMAPP_PLATFORM} IMAPP_PLATFORM) - -set(IMAPP_PLATFORM_SDL2 OFF) -set(IMAPP_PLATFORM_GLFW OFF) - -if(IMAPP_SYSTEM_EMSCRIPTEN) - set(IMAPP_PLATFORM "SDL2") -endif() - -if(IMAPP_PLATFORM STREQUAL "SDL2") - set(IMAPP_PLATFORM_SDL2 ON) - set(IMGUI_IMPL_PLATFORM_SDL2 ON) -elseif(IMAPP_PLATFORM STREQUAL "GLFW") - set(IMAPP_PLATFORM_GLFW ON) - set(IMGUI_IMPL_PLATFORM_GLFW ON) -endif() - -# Platform Bindings -include(cmake/imgui_impl_platform.cmake) -target_link_libraries(imapp ${IMGUI_IMPL_PLATFORM_LIBRARIES}) - -# Renderer options -set(IMAPP_RENDERER "OpenGL3" CACHE STRING "Renderer Binding") -string(TOUPPER ${IMAPP_RENDERER} IMAPP_RENDERER) - -set(IMAPP_RENDERER_OPENGL OFF) -set(IMAPP_RENDERER_OPENGL2 OFF) -set(IMAPP_RENDERER_OPENGL3 OFF) -set(IMAPP_RENDERER_VULKAN OFF) - -if(IMAPP_SYSTEM_EMSCRIPTEN) - set(IMAPP_RENDERER "OPENGL3") -endif() - -if(IMAPP_RENDERER STREQUAL "OPENGL2") - set(IMAPP_RENDERER_OPENGL ON) - set(IMAPP_RENDERER_OPENGL2 ON) - set(IMGUI_IMPL_RENDERER_OPENGL2 ON) -elseif(IMAPP_RENDERER STREQUAL "OPENGL3") - set(IMAPP_RENDERER_OPENGL ON) - set(IMAPP_RENDERER_OPENGL3 ON) - set(IMGUI_IMPL_RENDERER_OPENGL3 ON) -elseif(IMAPP_RENDERER STREQUAL "VULKAN") - set(IMAPP_RENDERER_VULKAN ON) - set(IMGUI_IMPL_RENDERER_VULKAN ON) - - # Custom Vulkan Renderer Binding - set(IMGUI_IMPL_RENDERER_VULKAN_CUSTOM_SOURCE ${IMAPP_SOURCE_DIR}/imapp_impl_vulkan.cpp) -endif() - -# OpenGL Loader options -set(IMAPP_OPENGL_LOADER "GLEW" CACHE STRING "OpenGL Loader") -string(TOUPPER ${IMAPP_OPENGL_LOADER} IMAPP_OPENGL_LOADER) - -set(IMAPP_OPENGL_LOADER_GLEW OFF) -set(IMAPP_OPENGL_LOADER_GL3W OFF) -set(IMAPP_OPENGL_LOADER_GLAD OFF) -set(IMAPP_OPENGL_LOADER_GLBINDING2 OFF) -set(IMAPP_OPENGL_LOADER_GLBINDING3 OFF) - -if(NOT IMAPP_RENDERER_OPENGL3) - # unnecessary -elseif(IMAPP_SYSTEM_EMSCRIPTEN) - # unnecessary -elseif(IMAPP_OPENGL_LOADER STREQUAL "GLEW") - set(IMAPP_OPENGL_LOADER_GLEW ON) - set(IMGUI_IMPL_OPENGL_LOADER_GLEW ON) -elseif(IMAPP_OPENGL_LOADER STREQUAL "GL3W") - set(IMAPP_OPENGL_LOADER_GL3W ON) - set(IMGUI_IMPL_OPENGL_LOADER_GL3W ON) -elseif(IMAPP_OPENGL_LOADER STREQUAL "GLAD") - set(IMAPP_OPENGL_LOADER_GLAD ON) - set(IMGUI_IMPL_OPENGL_LOADER_GLAD ON) -elseif(IMAPP_OPENGL_LOADER STREQUAL "GLBINDING2") - set(IMAPP_OPENGL_LOADER_GLBINDING2 ON) - set(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2 ON) -elseif(IMAPP_OPENGL_LOADER STREQUAL "GLBINDING3") - set(IMAPP_OPENGL_LOADER_GLBINDING3 ON) - set(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3 ON) -endif() - -# Renderer Bindings -include(cmake/imgui_impl_renderer.cmake) -target_link_libraries(imapp ${IMGUI_IMPL_RENDERER_LIBRARIES}) - -# Sources -target_sources(imapp PRIVATE - ${IMAPP_SOURCE_DIR}/imapp.cpp -) - -# Platform -if(IMAPP_PLATFORM_SDL2) # SDL2 - target_compile_definitions(imapp PUBLIC IMAPP_PLATFORM_SDL2) - target_sources(imapp PRIVATE ${IMAPP_SOURCE_DIR}/imapp_platform_sdl.cpp) - -elseif(IMAPP_PLATFORM_GLFW) # GLFW - target_compile_definitions(imapp PUBLIC IMAPP_PLATFORM_GLFW) - target_sources(imapp PRIVATE ${IMAPP_SOURCE_DIR}/imapp_platform_glfw.cpp) -endif() - -# Renderer -if(IMAPP_RENDERER_OPENGL) # OpenGL - target_compile_definitions(imapp PUBLIC IMAPP_RENDERER_OPENGL) - target_sources(imapp PRIVATE ${IMAPP_SOURCE_DIR}/imapp_opengl_loader.cpp) - - if(IMAPP_RENDERER_OPENGL3) # OpenGL 3 - target_compile_definitions(imapp PUBLIC IMAPP_RENDERER_OPENGL3) - target_sources(imapp PRIVATE ${IMAPP_SOURCE_DIR}/imapp_renderer_opengl3.cpp) - - elseif(IMAPP_RENDERER_OPENGL2) # OpenGL 2 - target_compile_definitions(imapp PUBLIC IMAPP_RENDERER_OPENGL2) - target_sources(imapp PRIVATE ${IMAPP_SOURCE_DIR}/imapp_renderer_opengl2.cpp) - endif() - -elseif(IMAPP_RENDERER_VULKAN) # Vulkan - target_compile_definitions(imapp PUBLIC IMAPP_RENDERER_VULKAN) - target_sources(imapp PRIVATE ${IMAPP_SOURCE_DIR}/imapp_renderer_vulkan.cpp) -endif() - -set(IMAPP_LIBRARIES imapp) diff --git a/examples/cmake/imgui.cmake b/examples/cmake/imgui.cmake deleted file mode 100644 index 8b64c04..0000000 --- a/examples/cmake/imgui.cmake +++ /dev/null @@ -1,16 +0,0 @@ - -set(IMGUI_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/imgui) -set(IMGUI_EXAMPLE_DIR ${IMGUI_INCLUDE_DIR}/examples) - -add_library(imgui STATIC) - -target_sources(imgui PRIVATE - ${IMGUI_INCLUDE_DIR}/imgui.cpp - ${IMGUI_INCLUDE_DIR}/imgui_demo.cpp - ${IMGUI_INCLUDE_DIR}/imgui_draw.cpp - ${IMGUI_INCLUDE_DIR}/imgui_widgets.cpp -) - -target_include_directories(imgui PUBLIC ${IMGUI_INCLUDE_DIR} ${IMGUI_EXAMPLE_DIR}) - -set(IMGUI_LIBRARIES imgui) diff --git a/examples/cmake/imgui_impl_platform.cmake b/examples/cmake/imgui_impl_platform.cmake deleted file mode 100644 index 3380987..0000000 --- a/examples/cmake/imgui_impl_platform.cmake +++ /dev/null @@ -1,31 +0,0 @@ - -set(IMGUI_IMPL_PLATFORM_INCLUDE_DIR ${IMGUI_EXAMPLE_DIR}) -set(IMGUI_IMPL_PLATFORM_SOURCE_DIR ${IMGUI_IMPL_PLATFORM_INCLUDE_DIR}) - -# Platform Bindings -add_library(imgui_impl_platform STATIC) -target_link_libraries(imgui_impl_platform ${IMGUI_LIBRARIES}) -target_include_directories(imgui_impl_platform PUBLIC ${IMGUI_IMPL_PLATFORM_INCLUDE_DIR}) - -# Platform options -option(IMGUI_IMPL_PLATFORM_SDL2 "Platform for SDL2" OFF) -option(IMGUI_IMPL_PLATFORM_GLFW "Platform for GLFW" OFF) - -if(IMGUI_IMPL_PLATFORM_SDL2) # SDL2 - if(EMSCRIPTEN) # Emscripten - # - target_compile_options(imgui_impl_platform PUBLIC -s USE_SDL=2) - else() - find_package(SDL2 REQUIRED) - endif() - target_link_libraries(imgui_impl_platform ${SDL2_LIBRARIES}) - target_include_directories(imgui_impl_platform PUBLIC ${SDL2_INCLUDE_DIRS}) - target_sources(imgui_impl_platform PRIVATE ${IMGUI_IMPL_PLATFORM_SOURCE_DIR}/imgui_impl_sdl.cpp) - -elseif(IMGUI_IMPL_PLATFORM_GLFW) # GLFW - find_package(glfw3 REQUIRED) - target_link_libraries(imgui_impl_platform glfw) - target_sources(imgui_impl_platform PRIVATE ${IMGUI_IMPL_PLATFORM_SOURCE_DIR}/imgui_impl_glfw.cpp) -endif() - -set(IMGUI_IMPL_PLATFORM_LIBRARIES imgui_impl_platform) diff --git a/examples/cmake/imgui_impl_renderer.cmake b/examples/cmake/imgui_impl_renderer.cmake deleted file mode 100644 index 25bf712..0000000 --- a/examples/cmake/imgui_impl_renderer.cmake +++ /dev/null @@ -1,97 +0,0 @@ - -set(IMGUI_IMPL_RENDERER_INCLUDE_DIR ${IMGUI_EXAMPLE_DIR}) -set(IMGUI_IMPL_RENDERER_SOURCE_DIR ${IMGUI_IMPL_RENDERER_INCLUDE_DIR}) - -# Renderer Bindings -add_library(imgui_impl_renderer STATIC) -target_link_libraries(imgui_impl_renderer ${IMGUI_LIBRARIES}) -target_include_directories(imgui_impl_renderer PUBLIC ${IMGUI_IMPL_RENDERER_INCLUDE_DIR}) - -# Renderer options -option(IMGUI_IMPL_RENDERER_OPENGL2 "Renderer for OpenGL2" OFF) -option(IMGUI_IMPL_RENDERER_OPENGL3 "Renderer for OpenGL3" OFF) -option(IMGUI_IMPL_RENDERER_VULKAN "Renderer for Vulkan" OFF) - -# OpenGL Loader options -option(IMGUI_IMPL_OPENGL_LOADER_GLEW "OpenGL Loader GLEW" OFF) -option(IMGUI_IMPL_OPENGL_LOADER_GL3W "OpenGL Loader GL3W" OFF) -option(IMGUI_IMPL_OPENGL_LOADER_GLAD "OpenGL Loader GLAD" OFF) -option(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2 "OpenGL Loader glbinding v2" OFF) -option(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3 "OpenGL Loader glbinding v3" OFF) - -# Renderer -set(IMGUI_IMPL_RENDERER_SOURCE "") - -if(IMGUI_IMPL_RENDERER_OPENGL2 OR IMGUI_IMPL_RENDERER_OPENGL3) # OpenGL - if(EMSCRIPTEN) # Emscripten - # - else() - find_package(OpenGL REQUIRED) - endif() - target_link_libraries(imgui_impl_renderer ${OPENGL_LIBRARIES}) - target_include_directories(imgui_impl_renderer PUBLIC ${OPENGL_INCLUDE_DIRS}) - - if(IMGUI_IMPL_RENDERER_OPENGL2) - set(IMGUI_IMPL_RENDERER_SOURCE ${IMGUI_IMPL_RENDERER_SOURCE_DIR}/imgui_impl_opengl2.cpp) - elseif(IMGUI_IMPL_RENDERER_OPENGL3) - set(IMGUI_IMPL_RENDERER_SOURCE ${IMGUI_IMPL_RENDERER_SOURCE_DIR}/imgui_impl_opengl3.cpp) - endif() - -elseif(IMGUI_IMPL_RENDERER_VULKAN) # Vulkan - find_package(Vulkan REQUIRED) - target_link_libraries(imgui_impl_renderer ${Vulkan_LIBRARIES}) - target_include_directories(imgui_impl_renderer PUBLIC ${Vulkan_INCLUDE_DIRS}) - set(IMGUI_IMPL_RENDERER_SOURCE ${IMGUI_IMPL_RENDERER_SOURCE_DIR}/imgui_impl_vulkan.cpp) - - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - target_compile_definitions(imgui_impl_renderer PUBLIC IMGUI_VULKAN_DEBUG_REPORT) - endif() -endif() - -# OpenGL Loader -if(EMSCRIPTEN) # Emscripten - # - -elseif(IMGUI_IMPL_OPENGL_LOADER_GLEW) # GLEW - find_package(GLEW REQUIRED) - target_compile_definitions(imgui_impl_renderer PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLEW) - target_include_directories(imgui_impl_renderer PUBLIC ${GLEW_INCLUDE_DIRS}) - target_link_libraries(imgui_impl_renderer ${GLEW_LIBRARIES}) - -elseif(IMGUI_IMPL_OPENGL_LOADER_GL3W) # GL3W - include(cmake/gl3w.cmake) - target_compile_definitions(imgui_impl_renderer PUBLIC IMGUI_IMPL_OPENGL_LOADER_GL3W) - target_link_libraries(imgui_impl_renderer ${GL3W_LIBRARIES}) - -elseif(IMGUI_IMPL_OPENGL_LOADER_GLAD) # GLAD - #TODO: Setup GLAD - #target_compile_definitions(imgui_impl_renderer PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLAD) - #target_include_directories(imgui_impl_renderer PUBLIC ${GLAD_INCLUDE_DIRS}) - #target_link_libraries(imgui_impl_renderer ${GLAD_LIBRARIES}) - -elseif(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) # glbinding v2 - find_package(glbinding REQUIRED) - target_compile_definitions(imgui_impl_renderer PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) - target_link_libraries(imgui_impl_renderer glbinding::glbinding) - -elseif(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) # glbinding v3 - find_package(glbinding REQUIRED) - target_compile_definitions(imgui_impl_renderer PUBLIC IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) - target_link_libraries(imgui_impl_renderer glbinding::glbinding) -endif() - -# Renderer definitions -if(NOT IMGUI_IMPL_RENDERER_CUSTOM_DEFINE OR IMGUI_IMPL_RENDERER_CUSTOM_DEFINE STREQUAL "") - # nop -else() - target_compile_definitions(imgui_impl_renderer PUBLIC ${IMGUI_IMPL_RENDERER_CUSTOM_DEFINE}) -endif() - -# Renderer sources -if(NOT IMGUI_IMPL_RENDERER_VULKAN_CUSTOM_SOURCE OR IMGUI_IMPL_RENDERER_VULKAN_CUSTOM_SOURCE STREQUAL "") - target_sources(imgui_impl_renderer PRIVATE ${IMGUI_IMPL_RENDERER_SOURCE}) -else() - target_sources(imgui_impl_renderer PRIVATE ${IMGUI_IMPL_RENDERER_VULKAN_CUSTOM_SOURCE}) -endif() - -set(IMGUI_IMPL_RENDERER_LIBRARIES imgui_impl_renderer) diff --git a/examples/main.cpp b/examples/main.cpp deleted file mode 100644 index c3e4b6a..0000000 --- a/examples/main.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// imapp: standalone example application -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. - -#include "imgui.h" -#include "imapp.h" - -// Main code -int main(int, char**) -{ - // Setup Platform/Renderer/Dear ImGui - if (!ImApp::BeginApplication("imapp example")) - { - return -1; - } - - // Enable Keyboard/Gamepad Controls - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'imgui/docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../examples/thirdparty/imgui/misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../examples/thirdparty/imgui/misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../examples/thirdparty/imgui/misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../examples/thirdparty/imgui/misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Load Texture - // - We will here use ImApp::LoadTextureFromFile to load images from disk. - int my_image_width = 0; - int my_image_height = 0; - ImTextureID my_image_texture; - bool loaded_texture = false; - loaded_texture = ImApp::LoadTextureFromFile("MyImage01.jpg", &my_image_texture, &my_image_width, &my_image_height); - - // Main loop - while (ImApp::BeginFrame()) - { - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - if (ImGui::ColorEdit3("clear color", (float*)&clear_color)) // Edit 3 floats representing a color - { - ImApp::SetClearColor(clear_color); - } - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Ex. Show a loaded texture. - if (loaded_texture) - { - ImGui::SetNextWindowPos(ImVec2(60, 300), ImGuiCond_FirstUseEver); - ImGui::Begin("Texture Text"); - ImGui::Text("pointer = %p", my_image_texture); - ImGui::Text("size = %d x %d", my_image_width, my_image_height); - ImGui::Image(my_image_texture, ImVec2(my_image_width, my_image_height)); - ImGui::End(); - } - - ImApp::EndFrame(); - } - - ImApp::EndApplication(); - - return 0; -} diff --git a/examples/main_emscripten.cpp b/examples/main_emscripten.cpp deleted file mode 100644 index 10f9660..0000000 --- a/examples/main_emscripten.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// imapp: standalone example application -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. -// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/) - -#include "imgui.h" -#include "imapp.h" - -namespace -{ - -// Our state (make them static = more or less global) as a convenience to keep the example terse. -bool show_demo_window = true; -bool show_another_window = false; -ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - -int my_image_width = 0; -int my_image_height = 0; -ImTextureID my_image_texture; -bool loaded_texture = false; - -} // namespace - -// For clarity, our main loop code is declared at the end. -void main_loop(void*); - -// Main code -int main(int, char**) -{ - // Setup Platform/Renderer/Dear ImGui - if (!ImApp::BeginApplication("imapp Emscripten example")) - { - return -1; - } - - // Enable Keyboard/Gamepad Controls - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - // - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details. - //io.Fonts->AddFontDefault(); -#ifndef IMGUI_DISABLE_FILE_FUNCTIONS - io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); -#endif - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Load Texture - // - We will here use ImApp::LoadTextureFromFile to load images from disk. -#ifndef IMGUI_DISABLE_FILE_FUNCTIONS - loaded_texture = ImApp::LoadTextureFromFile("MyImage01.jpg", &my_image_texture, &my_image_width, &my_image_height); -#endif - - // This function call won't return, and will engage in an infinite loop, processing events from the browser, and dispatching them. - ImApp::StartMainLoop(main_loop); -} - -void main_loop(void* arg) -{ - IM_UNUSED(arg); // We can pass this argument as the second parameter of emscripten_set_main_loop_arg(), but we don't use that. - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - if (ImGui::ColorEdit3("clear color", (float*)&clear_color)) // Edit 3 floats representing a color - { - ImApp::SetClearColor(clear_color); - } - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Ex. Show a loaded texture. - if (loaded_texture) - { - ImGui::SetNextWindowPos(ImVec2(60, 300), ImGuiCond_FirstUseEver); - ImGui::Begin("Texture Text"); - ImGui::Text("pointer = %p", my_image_texture); - ImGui::Text("size = %d x %d", my_image_width, my_image_height); - ImGui::Image(my_image_texture, ImVec2(my_image_width, my_image_height)); - ImGui::End(); - } -} diff --git a/examples/main_minimal.cpp b/examples/main_minimal.cpp deleted file mode 100644 index 1bda120..0000000 --- a/examples/main_minimal.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// imapp: standalone example application -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. - -#include "imgui.h" -#include "imapp.h" - -namespace -{ - -// Our state (make them static = more or less global) as a convenience to keep the example terse. -bool show_demo_window = true; -bool show_another_window = false; -ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - -int my_image_width = 0; -int my_image_height = 0; -ImTextureID my_image_texture; -bool loaded_texture = false; - -bool once = false; - -} // namespace - -IMAPP_MAIN("imapp minimal example") -{ - // Setup once - if (!once) - { - once = true; - - // Load Texture - // - We will here use ImApp::LoadTextureFromFile to load images from disk. -#ifndef IMGUI_DISABLE_FILE_FUNCTIONS - loaded_texture = ImApp::LoadTextureFromFile("MyImage01.jpg", &my_image_texture, &my_image_width, &my_image_height); -#endif - } - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - if (ImGui::ColorEdit3("clear color", (float*)&clear_color)) // Edit 3 floats representing a color - { - ImApp::SetClearColor(clear_color); - } - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Ex. Show a loaded texture. - if (loaded_texture) - { - ImGui::SetNextWindowPos(ImVec2(60, 300), ImGuiCond_FirstUseEver); - ImGui::Begin("Texture Text"); - ImGui::Text("pointer = %p", my_image_texture); - ImGui::Text("size = %d x %d", my_image_width, my_image_height); - ImGui::Image(my_image_texture, ImVec2(my_image_width, my_image_height)); - ImGui::End(); - } -} diff --git a/examples/thirdparty/imgui b/examples/thirdparty/imgui deleted file mode 160000 index 9418dcb..0000000 --- a/examples/thirdparty/imgui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9418dcb69355558f70de260483424412c5ca2fce diff --git a/examples/thirdparty/sdl2-cmake-modules b/examples/thirdparty/sdl2-cmake-modules deleted file mode 160000 index ad006a3..0000000 --- a/examples/thirdparty/sdl2-cmake-modules +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ad006a3daae65a612ed87415037e32188b81071e