From fac0c801da9993ac601c972fa8c0dfd9f88c38be Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 11 Jun 2018 10:19:17 +0200 Subject: [PATCH 01/16] Examples: Added imgui_impl_osx.mm bindings (#1870, #281) --- CHANGELOG.txt | 1 + examples/.gitignore | 9 +- examples/README.txt | 7 +- examples/example_apple/.gitignore | 3 - .../project.pbxproj | 325 ++++++++++++++++++ examples/example_osx_opengl2/main.mm | 280 +++++++++++++++ examples/imgui_impl_osx.h | 11 + examples/imgui_impl_osx.mm | 236 +++++++++++++ 8 files changed, 866 insertions(+), 6 deletions(-) delete mode 100644 examples/example_apple/.gitignore create mode 100644 examples/example_osx_opengl2/example_osx_opengl2.xcodeproj/project.pbxproj create mode 100644 examples/example_osx_opengl2/main.mm create mode 100644 examples/imgui_impl_osx.h create mode 100644 examples/imgui_impl_osx.mm diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 83a4b88e..4c870478 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -76,6 +76,7 @@ Other Changes: - SliderFloat(): When using keyboard/gamepad and a zero precision format string (e.g. "%.0f"), always step in integer units. (#1866) - ImFontConfig: Added GlyphMinAdvanceX/GlyphMaxAdvanceX settings useful to make a font appears monospaced, particularly useful for icon fonts. (#1869) - ImFontAtlas: Added GetGlyphRangesChineseSimplifiedCommon() helper that returns a list of ~2500 most common Simplified Chinese characters. (#1859) [@JX-Master, @ocornut] + - Examples: OSX: Added imgui_impl_osx.mm binding to be used along with e.g. imgui_impl_opengl2.cpp. (#281, #1870) [@pagghiu, @itamago, @ocornut] - Examples: GLFW: Made it possible to Shutdown/Init the backend again (by reseting the time storage properly). (#1827) [@ice1000] - Misc: Updated stb_textedit from 1.09 + patches to 1.12 + minor patches. - Internals: PushItemFlag() flags are inherited by BeginChild(). diff --git a/examples/.gitignore b/examples/.gitignore index db2859e1..e3f0f12b 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -9,13 +9,18 @@ build/* *.vcxproj.user *.o *.obj -*.exe *.pdb *.ilk *.VC.db *.VC.VC.opendb -## Unix executables +## XCode cruft +.DS_Store +project.xcworkspace +xcuserdata/* + +## Executables +*.exe example_glfw_opengl2/example_glfw_opengl2 example_glfw_opengl3/example_glfw_opengl3 example_sdl_opengl2/example_sdl_opengl2 diff --git a/examples/README.txt b/examples/README.txt index 407cceb9..2dce98da 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -109,6 +109,7 @@ Most the example bindings are split in 2 parts: List of officially maintained Platforms Bindings: imgui_impl_glfw.cpp + imgui_impl_osx.mm imgui_impl_sdl.cpp imgui_impl_win32.cpp @@ -212,10 +213,14 @@ example_sdl_vulkan/ This is quite long and tedious, because: Vulkan. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp +example_osx_opengl2/ + OSX Cocoa + OpenGL2. + = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp + example_apple/ OSX & iOS example + OpenGL2. THIS EXAMPLE HAS NOT BEEN MAINTAINED PROPERLY AND NEEDS A MAINTAINER. - Consider using the example_glfw_opengl3/ instead. + Consider using the example_glfw_opengl3/ or example_osx_opengl2/ example instead. On iOS, Using Synergy to access keyboard/mouse data from server computer. Synergy keyboard integration is rather hacky. diff --git a/examples/example_apple/.gitignore b/examples/example_apple/.gitignore deleted file mode 100644 index 8feda89d..00000000 --- a/examples/example_apple/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -imguiex.xcodeproj/project.xcworkspace/ -imguiex.xcodeproj/xcuserdata/ \ No newline at end of file diff --git a/examples/example_osx_opengl2/example_osx_opengl2.xcodeproj/project.pbxproj b/examples/example_osx_opengl2/example_osx_opengl2.xcodeproj/project.pbxproj new file mode 100644 index 00000000..a325e96d --- /dev/null +++ b/examples/example_osx_opengl2/example_osx_opengl2.xcodeproj/project.pbxproj @@ -0,0 +1,325 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 4080A99820B02D340036BA46 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4080A98A20B02CD90036BA46 /* main.mm */; }; + 4080A9A220B034280036BA46 /* imgui_impl_opengl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */; }; + 4080A9AD20B0343C0036BA46 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */; }; + 4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9A720B0343C0036BA46 /* imgui.cpp */; }; + 4080A9AF20B0343C0036BA46 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */; }; + 4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */; }; + 4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4080A9B220B034E40036BA46 /* Cocoa.framework */; }; + 4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4080A9B420B034EA0036BA46 /* OpenGL.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 4080A96920B029B00036BA46 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 4080A96B20B029B00036BA46 /* example_osx_opengl2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example_osx_opengl2; sourceTree = BUILT_PRODUCTS_DIR; }; + 4080A98A20B02CD90036BA46 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = SOURCE_ROOT; }; + 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../imgui_impl_opengl2.cpp; sourceTree = ""; }; + 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../imgui_impl_osx.mm; sourceTree = ""; }; + 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../imgui_impl_opengl2.h; sourceTree = ""; }; + 4080A9A120B034280036BA46 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../imgui_impl_osx.h; sourceTree = ""; }; + 4080A9A420B0343C0036BA46 /* stb_truetype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stb_truetype.h; path = ../../stb_truetype.h; sourceTree = ""; }; + 4080A9A520B0343C0036BA46 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = ""; }; + 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; }; + 4080A9A720B0343C0036BA46 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; + 4080A9A820B0343C0036BA46 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; + 4080A9A920B0343C0036BA46 /* stb_rect_pack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stb_rect_pack.h; path = ../../stb_rect_pack.h; sourceTree = ""; }; + 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; + 4080A9AB20B0343C0036BA46 /* stb_textedit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stb_textedit.h; path = ../../stb_textedit.h; sourceTree = ""; }; + 4080A9AC20B0343C0036BA46 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; }; + 4080A9B220B034E40036BA46 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 4080A9B420B034EA0036BA46 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4080A96820B029B00036BA46 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */, + 4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4080A96220B029B00036BA46 = { + isa = PBXGroup; + children = ( + 4080A9AC20B0343C0036BA46 /* imconfig.h */, + 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */, + 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */, + 4080A9A520B0343C0036BA46 /* imgui_internal.h */, + 4080A9A720B0343C0036BA46 /* imgui.cpp */, + 4080A9A820B0343C0036BA46 /* imgui.h */, + 4080A9A920B0343C0036BA46 /* stb_rect_pack.h */, + 4080A9AB20B0343C0036BA46 /* stb_textedit.h */, + 4080A9A420B0343C0036BA46 /* stb_truetype.h */, + 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */, + 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */, + 4080A9A120B034280036BA46 /* imgui_impl_osx.h */, + 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */, + 4080A98A20B02CD90036BA46 /* main.mm */, + 4080A96C20B029B00036BA46 /* Products */, + 4080A9B120B034E40036BA46 /* Frameworks */, + ); + sourceTree = ""; + }; + 4080A96C20B029B00036BA46 /* Products */ = { + isa = PBXGroup; + children = ( + 4080A96B20B029B00036BA46 /* example_osx_opengl2 */, + ); + name = Products; + sourceTree = ""; + }; + 4080A9B120B034E40036BA46 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4080A9B420B034EA0036BA46 /* OpenGL.framework */, + 4080A9B220B034E40036BA46 /* Cocoa.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4080A96A20B029B00036BA46 /* example_osx_opengl2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl2" */; + buildPhases = ( + 4080A96720B029B00036BA46 /* Sources */, + 4080A96820B029B00036BA46 /* Frameworks */, + 4080A96920B029B00036BA46 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = example_osx_opengl2; + productName = example_osx_opengl2; + productReference = 4080A96B20B029B00036BA46 /* example_osx_opengl2 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4080A96320B029B00036BA46 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0930; + ORGANIZATIONNAME = ImGui; + TargetAttributes = { + 4080A96A20B029B00036BA46 = { + CreatedOnToolsVersion = 9.3.1; + }; + }; + }; + buildConfigurationList = 4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_osx_opengl2" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4080A96220B029B00036BA46; + productRefGroup = 4080A96C20B029B00036BA46 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4080A96A20B029B00036BA46 /* example_osx_opengl2 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 4080A96720B029B00036BA46 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4080A99820B02D340036BA46 /* main.mm in Sources */, + 4080A9AD20B0343C0036BA46 /* imgui_demo.cpp in Sources */, + 4080A9AF20B0343C0036BA46 /* imgui_draw.cpp in Sources */, + 4080A9A220B034280036BA46 /* imgui_impl_opengl2.cpp in Sources */, + 4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */, + 4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4080A97020B029B00036BA46 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 4080A97120B029B00036BA46 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 4080A97320B029B00036BA46 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SYSTEM_HEADER_SEARCH_PATHS = ../libs/gl3w; + USER_HEADER_SEARCH_PATHS = ../..; + }; + name = Debug; + }; + 4080A97420B029B00036BA46 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SYSTEM_HEADER_SEARCH_PATHS = ../libs/gl3w; + USER_HEADER_SEARCH_PATHS = ../..; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_osx_opengl2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4080A97020B029B00036BA46 /* Debug */, + 4080A97120B029B00036BA46 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4080A97320B029B00036BA46 /* Debug */, + 4080A97420B029B00036BA46 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4080A96320B029B00036BA46 /* Project object */; +} diff --git a/examples/example_osx_opengl2/main.mm b/examples/example_osx_opengl2/main.mm new file mode 100644 index 00000000..c4b4a968 --- /dev/null +++ b/examples/example_osx_opengl2/main.mm @@ -0,0 +1,280 @@ +// ImGui - standalone example application for OSX + OpenGL2, using legacy fixed pipeline +// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. + +#include "imgui.h" +#include "../imgui_impl_osx.h" +#include "../imgui_impl_opengl2.h" +#include +#import +#import +#import + +//----------------------------------------------------------------------------------- +// ImGuiExampleView +//----------------------------------------------------------------------------------- + +@interface ImGuiExampleView : NSOpenGLView +{ + NSTimer* animationTimer; +} +@end + +@implementation ImGuiExampleView + +-(void)animationTimerFired:(NSTimer*)timer +{ + [self setNeedsDisplay:YES]; +} + +-(void)prepareOpenGL +{ + [super prepareOpenGL]; + +#ifndef DEBUG + GLint swapInterval = 1; + [[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; + if (swapInterval == 0) + NSLog(@"Error: Cannot set swap interval."); +#endif +} + +-(void)updateAndDrawDemoView +{ + ImGui_ImplOpenGL2_NewFrame(); + ImGui_ImplOSX_NewFrame(self); + + // Global data for the demo + static bool show_demo_window = true; + static bool show_another_window = false; + static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); + + // 1. Show a simple window. + // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug". + { + static float f = 0.0f; + static int counter = 0; + ImGui::Text("Hello, world!"); // Display some text (you can use a format string too) + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f + ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color + + ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state + ImGui::Checkbox("Another Window", &show_another_window); + + if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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); + } + + // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows. + if (show_another_window) + { + ImGui::Begin("Another Window", &show_another_window); + ImGui::Text("Hello from another window!"); + if (ImGui::Button("Close Me")) + show_another_window = false; + ImGui::End(); + } + + // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui! + if (show_demo_window) + { + ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly! + ImGui::ShowDemoWindow(&show_demo_window); + } + + // Rendering + ImGui::Render(); + [[self openGLContext] makeCurrentContext]; + + ImGuiIO& io = ImGui::GetIO(); + GLsizei width = (GLsizei)(io.DisplaySize.x * io.DisplayFramebufferScale.x); + GLsizei height = (GLsizei)(io.DisplaySize.y * io.DisplayFramebufferScale.y); + glViewport(0, 0, width, height); + + glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); + glClear(GL_COLOR_BUFFER_BIT); + ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); + + // Present + [[self openGLContext] flushBuffer]; + + if (!animationTimer) + animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES]; +} + +-(void)reshape +{ + [[self openGLContext] update]; + [self updateAndDrawDemoView]; +} + +-(void)drawRect:(NSRect)bounds +{ + [self updateAndDrawDemoView]; +} + +-(BOOL)acceptsFirstResponder +{ + return (YES); +} + +-(BOOL)becomeFirstResponder +{ + return (YES); +} + +-(BOOL)resignFirstResponder +{ + return (YES); +} + +// Flip coordinate system upside down on Y +-(BOOL)isFlipped +{ + return (YES); +} + +-(void)dealloc +{ + animationTimer = nil; +} + +// Forward Mouse/Keyboard events to dear imgui OSX back-end. It returns true when imgui is expecting to use the event. +-(void)keyUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } +-(void)keyDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } +-(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } +-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } +-(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } +-(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } + +@end + +//----------------------------------------------------------------------------------- +// ImGuiExampleAppDelegate +//----------------------------------------------------------------------------------- + +@interface ImGuiExampleAppDelegate : NSObject +@property (nonatomic, readonly) NSWindow* window; +@end + +@implementation ImGuiExampleAppDelegate +@synthesize window = _window; + +-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication +{ + return YES; +} + +-(NSWindow*)window +{ + if (_window != nil) + return (_window); + + NSRect viewRect = NSMakeRect(100.0, 100.0, 100.0 + 1280.0, 100 + 720.0); + + _window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES]; + [_window setTitle:@"ImGui OSX+OpenGL2 Example"]; + [_window setOpaque:YES]; + [_window makeKeyAndOrderFront:NSApp]; + + return (_window); +} + +-(void)setupMenu +{ + NSMenu* mainMenuBar = [[NSMenu alloc] init]; + NSMenu* appMenu; + NSMenuItem* menuItem; + + appMenu = [[NSMenu alloc] initWithTitle:@"ImGui OSX+OpenGL2 Example"]; + menuItem = [appMenu addItemWithTitle:@"Quit ImGui OSX+OpenGL2 Example" action:@selector(terminate:) keyEquivalent:@"q"]; + [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask]; + + menuItem = [[NSMenuItem alloc] init]; + [menuItem setSubmenu:appMenu]; + + [mainMenuBar addItem:menuItem]; + + appMenu = nil; + [NSApp setMainMenu:mainMenuBar]; +} + +-(void)dealloc +{ + _window = nil; +} + +-(void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ + // Make the application a foreground application (else it won't receive keyboard events) + ProcessSerialNumber psn = {0, kCurrentProcess}; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + + // Menu + [self setupMenu]; + + NSOpenGLPixelFormatAttribute attrs[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFADepthSize, 32, + 0 + }; + + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; + ImGuiExampleView* view = [[ImGuiExampleView alloc] initWithFrame:self.window.frame pixelFormat:format]; + format = nil; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) + [view setWantsBestResolutionOpenGLSurface:YES]; +#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + [self.window setContentView:view]; + + if ([view openGLContext] == nil) + NSLog(@"No OpenGL Context!"); + + // Setup Dear ImGui binding + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; + //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + + ImGui_ImplOSX_Init(); + ImGui_ImplOpenGL2_Init(); + + // Setup style + ImGui::GetStyle().WindowRounding = 0.0f; + ImGui::StyleColorsDark(); + //ImGui::StyleColorsClassic(); + + // 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 'misc/fonts/README.txt' 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("../../misc/fonts/Roboto-Medium.ttf", 16.0f); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); + //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); + //io.Fonts->AddFontFromFileTTF("../../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); +} + +@end + +int main(int argc, const char* argv[]) +{ + @autoreleasepool + { + NSApp = [NSApplication sharedApplication]; + ImGuiExampleAppDelegate* delegate = [[ImGuiExampleAppDelegate alloc] init]; + [[NSApplication sharedApplication] setDelegate:delegate]; + [NSApp run]; + } + return NSApplicationMain(argc, argv); +} diff --git a/examples/imgui_impl_osx.h b/examples/imgui_impl_osx.h new file mode 100644 index 00000000..0626371d --- /dev/null +++ b/examples/imgui_impl_osx.h @@ -0,0 +1,11 @@ +// ImGui Platform Binding for: OSX / Cocoa +// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan..) + +@class NSEvent; +@class NSOpenGLView; + +// FIXME-OSX: Try replacing with NSView +IMGUI_API bool ImGui_ImplOSX_Init(); +IMGUI_API void ImGui_ImplOSX_Shutdown(); +IMGUI_API void ImGui_ImplOSX_NewFrame(NSOpenGLView* view); +IMGUI_API bool ImGui_ImplOSX_HandleEvent(NSEvent* event); diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm new file mode 100644 index 00000000..19018e69 --- /dev/null +++ b/examples/imgui_impl_osx.mm @@ -0,0 +1,236 @@ +// ImGui Platform Binding for: OSX / Cocoa +// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan..) + +// FIXME-OSX: Keyboard mapping is weird. +// FIXME-OSX: Mouse cursor shape support (see https://github.com/glfw/glfw/issues/427) +// FIXME-OSX: Test renderer backend combination, e.g. OpenGL3 + +#include "imgui.h" +#include "imgui_impl_osx.h" +#import + +// CHANGELOG +// (minor and older changes stripped away, please see git history for details) +// 2018-XX-XX: Initial version. + +// Data +static clock_t g_Time = 0; + +// Functions +bool ImGui_ImplOSX_Init() +{ + ImGuiIO& io = ImGui::GetIO(); + + // Setup back-end capabilities flags + //io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) + //io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) + //io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional) + //io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy) + + // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. + io.KeyMap[ImGuiKey_Tab] = 9; + io.KeyMap[ImGuiKey_LeftArrow] = ImGuiKey_LeftArrow; + io.KeyMap[ImGuiKey_RightArrow] = ImGuiKey_RightArrow; + io.KeyMap[ImGuiKey_UpArrow] = ImGuiKey_UpArrow; + io.KeyMap[ImGuiKey_DownArrow] = ImGuiKey_DownArrow; + io.KeyMap[ImGuiKey_PageUp] = ImGuiKey_PageUp; + io.KeyMap[ImGuiKey_PageDown] = ImGuiKey_PageDown; + io.KeyMap[ImGuiKey_Home] = ImGuiKey_Home; + io.KeyMap[ImGuiKey_End] = ImGuiKey_End; + io.KeyMap[ImGuiKey_Insert] = ImGuiKey_Insert; + io.KeyMap[ImGuiKey_Delete] = ImGuiKey_Delete; + io.KeyMap[ImGuiKey_Backspace] = 127; + io.KeyMap[ImGuiKey_Space] = 32; + io.KeyMap[ImGuiKey_Enter] = 13; + io.KeyMap[ImGuiKey_Escape] = 27; + io.KeyMap[ImGuiKey_A] = 'a'; + io.KeyMap[ImGuiKey_C] = 'c'; + io.KeyMap[ImGuiKey_V] = 'v'; + io.KeyMap[ImGuiKey_X] = 'x'; + io.KeyMap[ImGuiKey_Y] = 'y'; + io.KeyMap[ImGuiKey_Z] = 'z'; + + // Time elapsed since last frame, in seconds + // (in this sample app we'll override this every frame because our time step is variable) + io.DeltaTime = 1.0f/60.0f; + + return true; +} + +void ImGui_ImplOSX_Shutdown() +{ +} + +void ImGui_ImplOSX_NewFrame(NSOpenGLView* view) +{ + ImGuiIO& io = ImGui::GetIO(); + + // Setup display size + const float dpi = [view.window backingScaleFactor]; + io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height); + io.DisplayFramebufferScale = ImVec2(dpi, dpi); + + // Setup time step + if (g_Time == 0) + g_Time = clock(); + clock_t current_time = clock(); + io.DeltaTime = (double)(current_time - g_Time) / CLOCKS_PER_SEC; + g_Time = current_time; + + NSWindow* main_window = [view window]; + NSPoint mouse_pos = [main_window mouseLocationOutsideOfEventStream]; + mouse_pos = [view convertPoint:mouse_pos fromView:nil]; + io.MousePos = ImVec2(mouse_pos.x, mouse_pos.y - 1); + + // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. + ImGui::NewFrame(); +} + +// FIXME-OSX: Store in io.KeysDown[] +static bool mapKeymap(int* keymap) +{ + if (*keymap == NSUpArrowFunctionKey) + *keymap = ImGuiKey_LeftArrow; + else if (*keymap == NSDownArrowFunctionKey) + *keymap = ImGuiKey_DownArrow; + else if (*keymap == NSLeftArrowFunctionKey) + *keymap = ImGuiKey_LeftArrow; + else if (*keymap == NSRightArrowFunctionKey) + *keymap = ImGuiKey_RightArrow; + else if (*keymap == NSHomeFunctionKey) + *keymap = ImGuiKey_Home; + else if (*keymap == NSEndFunctionKey) + *keymap = ImGuiKey_End; + else if (*keymap == NSDeleteFunctionKey) + *keymap = ImGuiKey_Delete; + else if (*keymap == 25) // SHIFT + TAB + *keymap = 9; // TAB + else + return true; + + return false; +} + +static void ResetKeys() +{ + // FIXME-OSX: Mapping + ImGuiIO& io = ImGui::GetIO(); + io.KeysDown[io.KeyMap[ImGuiKey_A]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_C]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_V]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_X]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_Y]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_Z]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_LeftArrow]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_RightArrow]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_Tab]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_UpArrow]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_DownArrow]] = false; + io.KeysDown[io.KeyMap[ImGuiKey_Tab]] = false; +} + +bool ImGui_ImplOSX_HandleEvent(NSEvent* event) +{ + ImGuiIO& io = ImGui::GetIO(); + + if (event.type == NSEventTypeLeftMouseDown) + { + int button = (int)[event buttonNumber]; + if (button >= 0 && button < IM_ARRAYSIZE(io.MouseDown)) + io.MouseDown[button] = true; + return io.WantCaptureMouse; + } + + if (event.type == NSEventTypeLeftMouseUp) + { + int button = (int)[event buttonNumber]; + if (button >= 0 && button < IM_ARRAYSIZE(io.MouseDown)) + io.MouseDown[button] = false; + return io.WantCaptureMouse; + } + + if (event.type == NSEventTypeScrollWheel) + { + double wheel_dx = 0.0; + double wheel_dy = 0.0; + + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) + { + wheel_dx = [event scrollingDeltaX]; + wheel_dy = [event scrollingDeltaY]; + if ([event hasPreciseScrollingDeltas]) + { + wheel_dx *= 0.1; + wheel_dy *= 0.1; + } + } + else + #endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ + { + wheel_dx = [event deltaX]; + wheel_dy = [event deltaY]; + } + + if (fabs(wheel_dx) > 0.0) + io.MouseWheelH += wheel_dx * 0.1f; + if (fabs(wheel_dy) > 0.0) + io.MouseWheel += wheel_dy * 0.1f; + return io.WantCaptureMouse; + } + + if (event.type == NSEventTypeKeyDown) + { + // FIXME-OSX: Try to store native NS keys in KeyDown[] + NSString* str = [event characters]; + int len = (int)[str length]; + for (int i = 0; i < len; i++) + { + int keymap = [str characterAtIndex:i]; + if (mapKeymap(&keymap) && !io.KeyCtrl) + io.AddInputCharacter(keymap); + if (keymap < 512) + { + // We must reset in case we're pressing a sequence of special keys while keeping the command pressed + if (io.KeyCtrl) + ResetKeys(); + io.KeysDown[keymap] = true; + } + } + return io.WantCaptureKeyboard; + } + + if (event.type == NSEventTypeKeyUp) + { + NSString* str = [event characters]; + int len = (int)[str length]; + for (int i = 0; i < len; i++) + { + int keymap = [str characterAtIndex:i]; + mapKeymap(&keymap); + if (keymap < 512) + io.KeysDown[keymap] = false; + } + return io.WantCaptureKeyboard; + } + + if (event.type == NSEventTypeFlagsChanged) + { + unsigned int flags; + flags = [event modifierFlags] & NSDeviceIndependentModifierFlagsMask; + ImGuiIO& io = ImGui::GetIO(); + bool wasKeyShift= io.KeyShift; + bool wasKeyCtrl = io.KeyCtrl; + io.KeyShift = flags & NSShiftKeyMask; + io.KeyCtrl = flags & NSCommandKeyMask; + bool keyShiftReleased = wasKeyShift && !io.KeyShift; + bool keyCtrlReleased = wasKeyCtrl && !io.KeyCtrl; + + // We must reset them as we will not receive any keyUp event if they where pressed during shift or command + if (keyShiftReleased || keyCtrlReleased) + ResetKeys(); + return io.WantCaptureKeyboard; + } + + return false; +} From e54b61aa0fd33931a9764b7529b99a0670f41986 Mon Sep 17 00:00:00 2001 From: Omar Cornut Date: Mon, 11 Jun 2018 21:07:14 +0200 Subject: [PATCH 02/16] Examples: OSX: Fixed obsolete enums. Fixed keyboard mapping. Added missing keyboard modifiers. (#1873) --- examples/example_osx_opengl2/main.mm | 2 +- examples/imgui_impl_osx.mm | 160 ++++++++++++--------------- 2 files changed, 70 insertions(+), 92 deletions(-) diff --git a/examples/example_osx_opengl2/main.mm b/examples/example_osx_opengl2/main.mm index c4b4a968..3d95fb86 100644 --- a/examples/example_osx_opengl2/main.mm +++ b/examples/example_osx_opengl2/main.mm @@ -191,7 +191,7 @@ appMenu = [[NSMenu alloc] initWithTitle:@"ImGui OSX+OpenGL2 Example"]; menuItem = [appMenu addItemWithTitle:@"Quit ImGui OSX+OpenGL2 Example" action:@selector(terminate:) keyEquivalent:@"q"]; - [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask]; + [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand]; menuItem = [[NSMenuItem alloc] init]; [menuItem setSubmenu:appMenu]; diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index 19018e69..c15a9fad 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -1,9 +1,10 @@ // ImGui Platform Binding for: OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan..) -// FIXME-OSX: Keyboard mapping is weird. -// FIXME-OSX: Mouse cursor shape support (see https://github.com/glfw/glfw/issues/427) -// FIXME-OSX: Test renderer backend combination, e.g. OpenGL3 +// Issues: +// [ ] Platform: CTRL+Tab can't be read. +// [ ] Platform: Mouse cursor shapes are not supported (see end of https://github.com/glfw/glfw/issues/427) +// [ ] Test with another renderer back-end than OpenGL2. e.g. OpenGL3. #include "imgui.h" #include "imgui_impl_osx.h" @@ -11,7 +12,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) -// 2018-XX-XX: Initial version. +// 2018-06-XX: Initial version. // Data static clock_t g_Time = 0; @@ -28,31 +29,28 @@ bool ImGui_ImplOSX_Init() //io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy) // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. - io.KeyMap[ImGuiKey_Tab] = 9; - io.KeyMap[ImGuiKey_LeftArrow] = ImGuiKey_LeftArrow; - io.KeyMap[ImGuiKey_RightArrow] = ImGuiKey_RightArrow; - io.KeyMap[ImGuiKey_UpArrow] = ImGuiKey_UpArrow; - io.KeyMap[ImGuiKey_DownArrow] = ImGuiKey_DownArrow; - io.KeyMap[ImGuiKey_PageUp] = ImGuiKey_PageUp; - io.KeyMap[ImGuiKey_PageDown] = ImGuiKey_PageDown; - io.KeyMap[ImGuiKey_Home] = ImGuiKey_Home; - io.KeyMap[ImGuiKey_End] = ImGuiKey_End; - io.KeyMap[ImGuiKey_Insert] = ImGuiKey_Insert; - io.KeyMap[ImGuiKey_Delete] = ImGuiKey_Delete; - io.KeyMap[ImGuiKey_Backspace] = 127; - io.KeyMap[ImGuiKey_Space] = 32; - io.KeyMap[ImGuiKey_Enter] = 13; - io.KeyMap[ImGuiKey_Escape] = 27; - io.KeyMap[ImGuiKey_A] = 'a'; - io.KeyMap[ImGuiKey_C] = 'c'; - io.KeyMap[ImGuiKey_V] = 'v'; - io.KeyMap[ImGuiKey_X] = 'x'; - io.KeyMap[ImGuiKey_Y] = 'y'; - io.KeyMap[ImGuiKey_Z] = 'z'; - - // Time elapsed since last frame, in seconds - // (in this sample app we'll override this every frame because our time step is variable) - io.DeltaTime = 1.0f/60.0f; + const int offset_for_function_keys = 256 - 0xF700; + io.KeyMap[ImGuiKey_Tab] = '\t'; + io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys; + io.KeyMap[ImGuiKey_Backspace] = 127; + io.KeyMap[ImGuiKey_Space] = 32; + io.KeyMap[ImGuiKey_Enter] = 13; + io.KeyMap[ImGuiKey_Escape] = 27; + io.KeyMap[ImGuiKey_A] = 'A'; + io.KeyMap[ImGuiKey_C] = 'C'; + io.KeyMap[ImGuiKey_V] = 'V'; + io.KeyMap[ImGuiKey_X] = 'X'; + io.KeyMap[ImGuiKey_Y] = 'Y'; + io.KeyMap[ImGuiKey_Z] = 'Z'; return true; } @@ -63,9 +61,8 @@ void ImGui_ImplOSX_Shutdown() void ImGui_ImplOSX_NewFrame(NSOpenGLView* view) { - ImGuiIO& io = ImGui::GetIO(); - // Setup display size + ImGuiIO& io = ImGui::GetIO(); const float dpi = [view.window backingScaleFactor]; io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height); io.DisplayFramebufferScale = ImVec2(dpi, dpi); @@ -86,47 +83,26 @@ void ImGui_ImplOSX_NewFrame(NSOpenGLView* view) ImGui::NewFrame(); } -// FIXME-OSX: Store in io.KeysDown[] -static bool mapKeymap(int* keymap) +static int mapCharacterToKey(int c) { - if (*keymap == NSUpArrowFunctionKey) - *keymap = ImGuiKey_LeftArrow; - else if (*keymap == NSDownArrowFunctionKey) - *keymap = ImGuiKey_DownArrow; - else if (*keymap == NSLeftArrowFunctionKey) - *keymap = ImGuiKey_LeftArrow; - else if (*keymap == NSRightArrowFunctionKey) - *keymap = ImGuiKey_RightArrow; - else if (*keymap == NSHomeFunctionKey) - *keymap = ImGuiKey_Home; - else if (*keymap == NSEndFunctionKey) - *keymap = ImGuiKey_End; - else if (*keymap == NSDeleteFunctionKey) - *keymap = ImGuiKey_Delete; - else if (*keymap == 25) // SHIFT + TAB - *keymap = 9; // TAB - else - return true; - - return false; + if (c >= 'a' && c <= 'z') + return c - 'a' + 'A'; + if (c == 25) // SHIFT+TAB -> TAB + return 9; + if (c >= 0 && c < 256) + return c; + if (c >= 0xF700 && c < 0xF700 + 256) + return c - 0xF700 + 256; + return -1; } -static void ResetKeys() +// Reset the non-characters keys +static void resetKeys() { - // FIXME-OSX: Mapping ImGuiIO& io = ImGui::GetIO(); - io.KeysDown[io.KeyMap[ImGuiKey_A]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_C]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_V]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_X]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_Y]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_Z]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_LeftArrow]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_RightArrow]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_Tab]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_UpArrow]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_DownArrow]] = false; - io.KeysDown[io.KeyMap[ImGuiKey_Tab]] = false; + for (int n = 0; n < IM_ARRAYSIZE(io.KeyMap); n++) + if (io.KeyMap[n] != -1 && io.KeyMap[n] >= 256) + io.KeysDown[io.KeyMap[n]] = false; } bool ImGui_ImplOSX_HandleEvent(NSEvent* event) @@ -186,16 +162,16 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event) int len = (int)[str length]; for (int i = 0; i < len; i++) { - int keymap = [str characterAtIndex:i]; - if (mapKeymap(&keymap) && !io.KeyCtrl) - io.AddInputCharacter(keymap); - if (keymap < 512) - { - // We must reset in case we're pressing a sequence of special keys while keeping the command pressed - if (io.KeyCtrl) - ResetKeys(); - io.KeysDown[keymap] = true; - } + int c = [str characterAtIndex:i]; + if (c < 0xF700 && !io.KeyCtrl) + io.AddInputCharacter(c); + + // We must reset in case we're pressing a sequence of special keys while keeping the command pressed + int key = mapCharacterToKey(c); + if (key != -1 && key < 256 && !io.KeyCtrl) + resetKeys(); + if (key != -1) + io.KeysDown[key] = true; } return io.WantCaptureKeyboard; } @@ -206,29 +182,31 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event) int len = (int)[str length]; for (int i = 0; i < len; i++) { - int keymap = [str characterAtIndex:i]; - mapKeymap(&keymap); - if (keymap < 512) - io.KeysDown[keymap] = false; + int c = [str characterAtIndex:i]; + int key = mapCharacterToKey(c); + if (key != -1) + io.KeysDown[key] = false; } return io.WantCaptureKeyboard; } if (event.type == NSEventTypeFlagsChanged) { - unsigned int flags; - flags = [event modifierFlags] & NSDeviceIndependentModifierFlagsMask; ImGuiIO& io = ImGui::GetIO(); - bool wasKeyShift= io.KeyShift; - bool wasKeyCtrl = io.KeyCtrl; - io.KeyShift = flags & NSShiftKeyMask; - io.KeyCtrl = flags & NSCommandKeyMask; - bool keyShiftReleased = wasKeyShift && !io.KeyShift; - bool keyCtrlReleased = wasKeyCtrl && !io.KeyCtrl; + unsigned int flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask; + + bool oldKeyCtrl = io.KeyCtrl; + bool oldKeyShift = io.KeyShift; + bool oldKeyAlt = io.KeyAlt; + bool oldKeySuper = io.KeySuper; + io.KeyCtrl = flags & NSEventModifierFlagControl; + io.KeyShift = flags & NSEventModifierFlagShift; + io.KeyAlt = flags & NSEventModifierFlagOption; + io.KeySuper = flags & NSEventModifierFlagCommand; // We must reset them as we will not receive any keyUp event if they where pressed during shift or command - if (keyShiftReleased || keyCtrlReleased) - ResetKeys(); + if ((oldKeyShift && !io.KeyShift) || (oldKeyCtrl && !io.KeyCtrl)) + resetKeys(); return io.WantCaptureKeyboard; } From a402edb66c8576922d79b6a040a7096d54a08589 Mon Sep 17 00:00:00 2001 From: Omar Cornut Date: Fri, 15 Jun 2018 22:49:03 +0200 Subject: [PATCH 03/16] Examples: OSX: Added clipboard support. Fixed ignore list for xcode cruft. Comments about broken keys. (#1873) --- examples/.gitignore | 2 +- examples/example_osx_opengl2/main.mm | 1 - examples/imgui_impl_osx.mm | 40 ++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/examples/.gitignore b/examples/.gitignore index e3f0f12b..e21b5147 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -17,7 +17,7 @@ build/* ## XCode cruft .DS_Store project.xcworkspace -xcuserdata/* +xcuserdata ## Executables *.exe diff --git a/examples/example_osx_opengl2/main.mm b/examples/example_osx_opengl2/main.mm index 3d95fb86..a5b89bf7 100644 --- a/examples/example_osx_opengl2/main.mm +++ b/examples/example_osx_opengl2/main.mm @@ -245,7 +245,6 @@ ImGui_ImplOpenGL2_Init(); // Setup style - ImGui::GetStyle().WindowRounding = 0.0f; ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index c15a9fad..eba2b108 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -2,7 +2,7 @@ // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan..) // Issues: -// [ ] Platform: CTRL+Tab can't be read. +// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. // [ ] Platform: Mouse cursor shapes are not supported (see end of https://github.com/glfw/glfw/issues/427) // [ ] Test with another renderer back-end than OpenGL2. e.g. OpenGL3. @@ -52,6 +52,32 @@ bool ImGui_ImplOSX_Init() io.KeyMap[ImGuiKey_Y] = 'Y'; io.KeyMap[ImGuiKey_Z] = 'Z'; + io.SetClipboardTextFn = [](void*, const char* str) -> void + { + NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; + [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; + [pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString]; + }; + + io.GetClipboardTextFn = [](void*) -> const char* + { + NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; + NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]]; + if (![available isEqualToString:NSPasteboardTypeString]) + return NULL; + + NSString* string = [pasteboard stringForType:NSPasteboardTypeString]; + if (string == nil) + return NULL; + + const char* string_c = (const char*)[string UTF8String]; + size_t string_len = strlen(string_c); + static ImVector s_clipboard; + s_clipboard.resize((int)string_len + 1); + strcpy(s_clipboard.Data, string_c); + return s_clipboard.Data; + }; + return true; } @@ -96,13 +122,11 @@ static int mapCharacterToKey(int c) return -1; } -// Reset the non-characters keys static void resetKeys() { ImGuiIO& io = ImGui::GetIO(); - for (int n = 0; n < IM_ARRAYSIZE(io.KeyMap); n++) - if (io.KeyMap[n] != -1 && io.KeyMap[n] >= 256) - io.KeysDown[io.KeyMap[n]] = false; + for (int n = 0; n < IM_ARRAYSIZE(io.KeysDown); n++) + io.KeysDown[n] = false; } bool ImGui_ImplOSX_HandleEvent(NSEvent* event) @@ -155,9 +179,9 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event) return io.WantCaptureMouse; } + // FIXME: All the key handling is wrong and broken. Refer to GLFW's cocoa_init.mm and cocoa_window.mm. if (event.type == NSEventTypeKeyDown) { - // FIXME-OSX: Try to store native NS keys in KeyDown[] NSString* str = [event characters]; int len = (int)[str length]; for (int i = 0; i < len; i++) @@ -204,8 +228,8 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event) io.KeyAlt = flags & NSEventModifierFlagOption; io.KeySuper = flags & NSEventModifierFlagCommand; - // We must reset them as we will not receive any keyUp event if they where pressed during shift or command - if ((oldKeyShift && !io.KeyShift) || (oldKeyCtrl && !io.KeyCtrl)) + // We must reset them as we will not receive any keyUp event if they where pressed with a modifier + if ((oldKeyShift && !io.KeyShift) || (oldKeyCtrl && !io.KeyCtrl) || (oldKeyAlt && !io.KeyAlt) || (oldKeySuper && !io.KeySuper)) resetKeys(); return io.WantCaptureKeyboard; } From a765c83bada1627bde76a97d1e8f40a01098b539 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 3 Jul 2018 15:57:34 +0200 Subject: [PATCH 04/16] Ignore list: added emscripten output --- examples/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/.gitignore b/examples/.gitignore index d5786ab8..9ce332bc 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -21,6 +21,10 @@ build/* project.xcworkspace xcuserdata +## Emscripten output +*.out.js +*.out.wasm + ## Unix executables example_glfw_opengl2/example_glfw_opengl2 example_glfw_opengl3/example_glfw_opengl3 From 665bd1e140de3647d02b6c306b8ddb2d369e3f73 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 4 Jul 2018 10:07:50 +0200 Subject: [PATCH 05/16] Links and thanks. Comments on using BeginCombo/EndCombo + moved the Combo() implementations closer to each others to maximize user seeing how it is implemented from any of the secondary function body. --- README.md | 6 ++--- imgui.cpp | 76 +++++++++++++++++++++++++++---------------------------- imgui.h | 2 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 5b5fb2b7..953d5ad6 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/ _NB: those third-party bindings may be more or less maintained, more or less close to the original API (as people who create language bindings sometimes haven't used the C++ API themselves.. for the good reason that they aren't C++ users). Dear ImGui was designed with C++ in mind and some of the subtleties may be lost in translation with other languages. If your language supports it, I would suggest replicating the function overloading and default parameters used in the original, else the API may be harder to use. In doubt, please check the original C++ version first!_ Languages: (third-party bindings) -- C: [cimgui](https://github.com/Extrawurst/cimgui) and [#1879](https://github.com/ocornut/imgui/issues/1879) +- C: [cimgui](https://github.com/Extrawurst/cimgui) or [sonoro1234's cimgui](https://github.com/sonoro1234/cimgui) (more recent update), also see [#1879](https://github.com/ocornut/imgui/issues/1879) - C#/.Net: [ImGui.NET](https://github.com/mellinoe/ImGui.NET) - ChaiScript: [imgui-chaiscript](https://github.com/JuJuBoSc/imgui-chaiscript) - D: [DerelictImgui](https://github.com/Extrawurst/DerelictImgui) @@ -316,10 +316,10 @@ Double-chocolate sponsors: - DotEmu Salty caramel supporters: -- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse, Lionel Landwerlin, Nikolay Ivanov, Ron Gilbert, Brandon Townsend, Nikhil Deshpande, Cort Stratton, drudru. +- Jetha Chan, Wild Sheep Studio, Pastagames, Mārtiņš Možeiko, Daniel Collin, Recognition Robotics, Chris Genova, ikrima, Glenn Fiedler, Geoffrey Evans, Dakko Dakko, Mercury Labs, Singularity Demo Group, Mischa Alff, Sebastien Ronsse, Lionel Landwerlin, Nikolay Ivanov, Ron Gilbert, Brandon Townsend, Nikhil Deshpande, Cort Stratton, drudru, Harfang 3D, Supercell. Caramel supporters: -- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić, Jonas Bernemann, Johan Andersson, Nathan Hartman, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Felipe Alfonso, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Edsel Malasig, Andrew Johnson, Sean Hunter, Jordan Mellow, Nefarius Software Solutions, Laura Wieme, Robert Nix, Mick Honey. +- Michel Courtine, César Leblic, Dale Kim, Alex Evans, Rui Figueira, Paul Patrashcu, Jerome Lanquetot, Ctrl Alt Ninja, Paul Fleming, Neil Henning, Stephan Dilly, Neil Blakey-Milner, Aleksei, NeiloGD, Justin Paver, FiniteSol, Vincent Pancaldi, James Billot, Robin Hübner, furrtek, Eric, Simon Barratt, Game Atelier, Julian Bosch, Simon Lundmark, Vincent Hamm, Farhan Wali, Jeff Roberts, Matt Reyer, Colin Riley, Victor Martins, Josh Simmons, Garrett Hoofman, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Kit framework, Josh Faust, Martin Donlon, Quinton, Felix, Andrew Belt, Codecat, Cort Stratton, Claudio Canepa, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Roger Clark, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Miloš Tošić, Jonas Bernemann, Johan Andersson, Nathan Hartman, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Felipe Alfonso, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Edsel Malasig, Andrew Johnson, Sean Hunter, Jordan Mellow, Nefarius Software Solutions, Laura Wieme, Robert Nix, Mick Honey, Astrofra, Jonas Lehmann, Steven Kah Hien Wong, Bartosz Bielecki. And other supporters; thanks! (Please contact me or PR if you would like to be added or removed from this list) diff --git a/imgui.cpp b/imgui.cpp index 60b60149..c1eada5f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11331,23 +11331,51 @@ void ImGui::EndCombo() EndPopup(); } +// Getter for the old Combo() API: const char*[] +static bool Items_ArrayGetter(void* data, int idx, const char** out_text) +{ + const char* const* items = (const char* const*)data; + if (out_text) + *out_text = items[idx]; + return true; +} + +// Getter for the old Combo() API: "item1\0item2\0item3\0" +static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) +{ + // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. + const char* items_separated_by_zeros = (const char*)data; + int items_count = 0; + const char* p = items_separated_by_zeros; + while (*p) + { + if (idx == items_count) + break; + p += strlen(p) + 1; + items_count++; + } + if (!*p) + return false; + if (out_text) + *out_text = p; + return true; +} + // Old API, prefer using BeginCombo() nowadays if you can. bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items) { ImGuiContext& g = *GImGui; - const char* preview_text = NULL; + // Call the getter to obtain the preview string which is a parameter to BeginCombo() + const char* preview_value = NULL; if (*current_item >= 0 && *current_item < items_count) - items_getter(data, *current_item, &preview_text); + items_getter(data, *current_item, &preview_value); - // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't, so we emulate it here. + // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here. if (popup_max_height_in_items != -1 && !g.NextWindowData.SizeConstraintCond) - { - float popup_max_height = CalcMaxPopupHeightFromItemCount(popup_max_height_in_items); - SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, popup_max_height)); - } + SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); - if (!BeginCombo(label, preview_text, 0)) + if (!BeginCombo(label, preview_value, ImGuiComboFlags_None)) return false; // Display items @@ -11374,34 +11402,6 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi return value_changed; } -static bool Items_ArrayGetter(void* data, int idx, const char** out_text) -{ - const char* const* items = (const char* const*)data; - if (out_text) - *out_text = items[idx]; - return true; -} - -static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) -{ - // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. - const char* items_separated_by_zeros = (const char*)data; - int items_count = 0; - const char* p = items_separated_by_zeros; - while (*p) - { - if (idx == items_count) - break; - p += strlen(p) + 1; - items_count++; - } - if (!*p) - return false; - if (out_text) - *out_text = p; - return true; -} - // Combo box helper allowing to pass an array of strings. bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items) { @@ -11409,7 +11409,7 @@ bool ImGui::Combo(const char* label, int* current_item, const char* const items[ return value_changed; } -// Combo box helper allowing to pass all items in a single string. +// Combo box helper allowing to pass all items in a single string literal holding multiple zero-terminated items "item1\0item2\0" bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items) { int items_count = 0; @@ -11424,7 +11424,7 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa } // Tip: pass an empty label (e.g. "##dummy") then you can use the space to draw other text or image. -// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID. +// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id. bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) { ImGuiWindow* window = GetCurrentWindow(); diff --git a/imgui.h b/imgui.h index 6463ec2e..1e4d26a7 100644 --- a/imgui.h +++ b/imgui.h @@ -338,7 +338,7 @@ namespace ImGui IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses // Widgets: Combo Box - // The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it. + // The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. // The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true! From deb7aa29cdeda8742e47b56dac94d794f2ea7fc0 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 4 Jul 2018 13:24:16 +0200 Subject: [PATCH 06/16] OSX: Various tweaks to imgui_impl_osx courtesy of @warrenm + fix NewFrame position which has been moved recently master. (#1873) --- examples/example_osx_opengl2/main.mm | 1 + examples/imgui_impl_osx.h | 8 ++++---- examples/imgui_impl_osx.mm | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/example_osx_opengl2/main.mm b/examples/example_osx_opengl2/main.mm index a5b89bf7..710ffe24 100644 --- a/examples/example_osx_opengl2/main.mm +++ b/examples/example_osx_opengl2/main.mm @@ -42,6 +42,7 @@ { ImGui_ImplOpenGL2_NewFrame(); ImGui_ImplOSX_NewFrame(self); + ImGui::NewFrame(); // Global data for the demo static bool show_demo_window = true; diff --git a/examples/imgui_impl_osx.h b/examples/imgui_impl_osx.h index 0626371d..bbe72fc9 100644 --- a/examples/imgui_impl_osx.h +++ b/examples/imgui_impl_osx.h @@ -1,11 +1,11 @@ // ImGui Platform Binding for: OSX / Cocoa -// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan..) +// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) @class NSEvent; -@class NSOpenGLView; +@class NSVew; // FIXME-OSX: Try replacing with NSView IMGUI_API bool ImGui_ImplOSX_Init(); IMGUI_API void ImGui_ImplOSX_Shutdown(); -IMGUI_API void ImGui_ImplOSX_NewFrame(NSOpenGLView* view); -IMGUI_API bool ImGui_ImplOSX_HandleEvent(NSEvent* event); +IMGUI_API void ImGui_ImplOSX_NewFrame(NSView *_Nonnull view); +IMGUI_API bool ImGui_ImplOSX_HandleEvent(NSEvent *_Nonnull event, NSView *_Nullable view); diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index eba2b108..d0b7efd2 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -1,5 +1,5 @@ // ImGui Platform Binding for: OSX / Cocoa -// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan..) +// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) // Issues: // [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. @@ -85,7 +85,7 @@ void ImGui_ImplOSX_Shutdown() { } -void ImGui_ImplOSX_NewFrame(NSOpenGLView* view) +void ImGui_ImplOSX_NewFrame(NSView* view) { // Setup display size ImGuiIO& io = ImGui::GetIO(); @@ -99,14 +99,6 @@ void ImGui_ImplOSX_NewFrame(NSOpenGLView* view) clock_t current_time = clock(); io.DeltaTime = (double)(current_time - g_Time) / CLOCKS_PER_SEC; g_Time = current_time; - - NSWindow* main_window = [view window]; - NSPoint mouse_pos = [main_window mouseLocationOutsideOfEventStream]; - mouse_pos = [view convertPoint:mouse_pos fromView:nil]; - io.MousePos = ImVec2(mouse_pos.x, mouse_pos.y - 1); - - // Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application. - ImGui::NewFrame(); } static int mapCharacterToKey(int c) @@ -129,11 +121,11 @@ static void resetKeys() io.KeysDown[n] = false; } -bool ImGui_ImplOSX_HandleEvent(NSEvent* event) +bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) { ImGuiIO& io = ImGui::GetIO(); - if (event.type == NSEventTypeLeftMouseDown) + if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown) { int button = (int)[event buttonNumber]; if (button >= 0 && button < IM_ARRAYSIZE(io.MouseDown)) @@ -141,7 +133,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event) return io.WantCaptureMouse; } - if (event.type == NSEventTypeLeftMouseUp) + if (event.type == NSEventTypeLeftMouseUp || event.type == NSEventTypeRightMouseUp || event.type == NSEventTypeOtherMouseUp) { int button = (int)[event buttonNumber]; if (button >= 0 && button < IM_ARRAYSIZE(io.MouseDown)) @@ -149,6 +141,14 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event) return io.WantCaptureMouse; } + if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged) + { + NSPoint mousePoint = event.locationInWindow; + mousePoint = [view convertPoint:mousePoint fromView:nil]; + mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y); + io.MousePos = ImVec2(mousePoint.x, mousePoint.y); + } + if (event.type == NSEventTypeScrollWheel) { double wheel_dx = 0.0; From 7b2662d245104d1d756e1d698ea6de3ce18472f9 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 4 Jul 2018 19:06:28 +0200 Subject: [PATCH 07/16] Examples: Comments, bits of documentation --- examples/imgui_impl_allegro5.cpp | 5 +-- examples/imgui_impl_allegro5.h | 5 +-- examples/imgui_impl_dx10.cpp | 3 +- examples/imgui_impl_dx10.h | 3 +- examples/imgui_impl_dx11.cpp | 3 +- examples/imgui_impl_dx11.h | 3 +- examples/imgui_impl_dx12.cpp | 3 +- examples/imgui_impl_dx12.h | 3 +- examples/imgui_impl_dx9.cpp | 3 +- examples/imgui_impl_dx9.h | 3 +- examples/imgui_impl_freeglut.cpp | 3 +- examples/imgui_impl_freeglut.h | 3 +- examples/imgui_impl_glfw.cpp | 3 +- examples/imgui_impl_glfw.h | 3 +- examples/imgui_impl_marmalade.cpp | 7 +--- examples/imgui_impl_marmalade.h | 3 +- examples/imgui_impl_opengl2.cpp | 4 ++ examples/imgui_impl_opengl2.h | 4 ++ examples/imgui_impl_opengl3.cpp | 4 ++ examples/imgui_impl_opengl3.h | 4 ++ examples/imgui_impl_sdl.cpp | 3 +- examples/imgui_impl_sdl.h | 3 +- examples/imgui_impl_vulkan.cpp | 3 +- examples/imgui_impl_vulkan.h | 3 +- imgui.cpp | 68 ++++++++++++++++++++++++------- 25 files changed, 93 insertions(+), 59 deletions(-) diff --git a/examples/imgui_impl_allegro5.cpp b/examples/imgui_impl_allegro5.cpp index 5126a3c2..b1e96325 100644 --- a/examples/imgui_impl_allegro5.cpp +++ b/examples/imgui_impl_allegro5.cpp @@ -10,9 +10,8 @@ // [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert the format of vertices. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui, Original code by @birthggd +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui, Original Allegro 5 code by @birthggd // CHANGELOG // (minor and older changes stripped away, please see git history for details) diff --git a/examples/imgui_impl_allegro5.h b/examples/imgui_impl_allegro5.h index 6455a3c6..053f87fa 100644 --- a/examples/imgui_impl_allegro5.h +++ b/examples/imgui_impl_allegro5.h @@ -9,9 +9,8 @@ // [ ] Platform: Missing clipboard support via al_set_clipboard_text/al_clipboard_has_text. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. -// https://github.com/ocornut/imgui, Original code by @birthggd +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui, Original Allegro 5 code by @birthggd #pragma once diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 3b6b85e3..c774277c 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -5,8 +5,7 @@ // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_dx10.h b/examples/imgui_impl_dx10.h index c0e27c60..424d7182 100644 --- a/examples/imgui_impl_dx10.h +++ b/examples/imgui_impl_dx10.h @@ -5,8 +5,7 @@ // [X] Renderer: User texture binding. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui struct ID3D10Device; diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index fedd0297..7f831f93 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -5,8 +5,7 @@ // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_dx11.h b/examples/imgui_impl_dx11.h index fef3f31c..38dae30d 100644 --- a/examples/imgui_impl_dx11.h +++ b/examples/imgui_impl_dx11.h @@ -5,8 +5,7 @@ // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui struct ID3D11Device; diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index f8ceab3c..af80c1de 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -7,8 +7,7 @@ // [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301 // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_dx12.h b/examples/imgui_impl_dx12.h index 2f70f960..823ac324 100644 --- a/examples/imgui_impl_dx12.h +++ b/examples/imgui_impl_dx12.h @@ -7,8 +7,7 @@ // [ ] 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*)). See github.com/ocornut/imgui/pull/301 // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui enum DXGI_FORMAT; diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index 77a764b0..9ee56db0 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -5,8 +5,7 @@ // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_dx9.h b/examples/imgui_impl_dx9.h index c7ac1c10..8c91364d 100644 --- a/examples/imgui_impl_dx9.h +++ b/examples/imgui_impl_dx9.h @@ -5,8 +5,7 @@ // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui struct IDirect3DDevice9; diff --git a/examples/imgui_impl_freeglut.cpp b/examples/imgui_impl_freeglut.cpp index 3c099eca..b265226b 100644 --- a/examples/imgui_impl_freeglut.cpp +++ b/examples/imgui_impl_freeglut.cpp @@ -5,8 +5,7 @@ // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_freeglut.h b/examples/imgui_impl_freeglut.h index e2b7ca6e..b6b88973 100644 --- a/examples/imgui_impl_freeglut.h +++ b/examples/imgui_impl_freeglut.h @@ -5,8 +5,7 @@ // [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui IMGUI_IMPL_API bool ImGui_ImplFreeGLUT_Init(); diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index c7ec4beb..48d83ea2 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -9,8 +9,7 @@ // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_glfw.h b/examples/imgui_impl_glfw.h index 229df383..8a68f447 100644 --- a/examples/imgui_impl_glfw.h +++ b/examples/imgui_impl_glfw.h @@ -9,8 +9,7 @@ // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // About GLSL version: diff --git a/examples/imgui_impl_marmalade.cpp b/examples/imgui_impl_marmalade.cpp index f7629e2a..6d78a1a9 100644 --- a/examples/imgui_impl_marmalade.cpp +++ b/examples/imgui_impl_marmalade.cpp @@ -1,16 +1,13 @@ // ImGui Renderer + Platform Binding for: Marmalade + IwGx +// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of ImGui) // Implemented features: // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui -// Copyright (C) 2015 by Giovanni Zito -// This file is part of ImGui - // CHANGELOG // (minor and older changes stripped away, please see git history for details) // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_Marmalade_RenderDrawData() in the .h file so you can call it yourself. diff --git a/examples/imgui_impl_marmalade.h b/examples/imgui_impl_marmalade.h index 01b84889..01769b94 100644 --- a/examples/imgui_impl_marmalade.h +++ b/examples/imgui_impl_marmalade.h @@ -4,8 +4,7 @@ // [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // Copyright (C) 2015 by Giovanni Zito diff --git a/examples/imgui_impl_opengl2.cpp b/examples/imgui_impl_opengl2.cpp index 54337dbf..ccac3fac 100644 --- a/examples/imgui_impl_opengl2.cpp +++ b/examples/imgui_impl_opengl2.cpp @@ -4,6 +4,10 @@ // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** // **Prefer using the code in imgui_impl_opengl3.cpp** // This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. diff --git a/examples/imgui_impl_opengl2.h b/examples/imgui_impl_opengl2.h index 52bcedf9..930d449c 100644 --- a/examples/imgui_impl_opengl2.h +++ b/examples/imgui_impl_opengl2.h @@ -4,6 +4,10 @@ // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + // **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** // **Prefer using the code in imgui_impl_opengl3.cpp** // This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. diff --git a/examples/imgui_impl_opengl3.cpp b/examples/imgui_impl_opengl3.cpp index fb266e93..73c61477 100644 --- a/examples/imgui_impl_opengl3.cpp +++ b/examples/imgui_impl_opengl3.cpp @@ -5,6 +5,10 @@ // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + // CHANGELOG // (minor and older changes stripped away, please see git history for details) // 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples. diff --git a/examples/imgui_impl_opengl3.h b/examples/imgui_impl_opengl3.h index 1dbb5da6..243f152c 100644 --- a/examples/imgui_impl_opengl3.h +++ b/examples/imgui_impl_opengl3.h @@ -5,6 +5,10 @@ // Implemented features: // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + // About GLSL version: // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 4fdb1c9c..39921691 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -10,8 +10,7 @@ // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_sdl.h b/examples/imgui_impl_sdl.h index 367697d7..d723bf42 100644 --- a/examples/imgui_impl_sdl.h +++ b/examples/imgui_impl_sdl.h @@ -10,8 +10,7 @@ // [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui struct SDL_Window; diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index bed7d382..7d6f7499 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -5,8 +5,7 @@ // [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914 // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 5 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXX_CreateFontsTexture(), ImGui_ImplXXXX_NewFrame(), ImGui_ImplXXXX_Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui // CHANGELOG diff --git a/examples/imgui_impl_vulkan.h b/examples/imgui_impl_vulkan.h index 5a9fd5d4..73e26884 100644 --- a/examples/imgui_impl_vulkan.h +++ b/examples/imgui_impl_vulkan.h @@ -5,8 +5,7 @@ // [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914 // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. -// If you use this binding you'll need to call 5 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXX_CreateFontsTexture(), ImGui_ImplXXXX_NewFrame(), ImGui_ImplXXXX_Render() and ImGui_ImplXXXX_Shutdown(). -// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. // https://github.com/ocornut/imgui #include diff --git a/imgui.cpp b/imgui.cpp index c1eada5f..7748838b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -120,34 +120,73 @@ - Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code. THIS IS HOW A SIMPLE APPLICATION MAY LOOK LIKE + EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder) - // Application init - // Create a context + // Application init: create a dear imgui context, setup some options, load fonts ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); + // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls // TODO: Fill optional settings of the io structure later. - // TODO: Load fonts if you don't want to use the default font. + // TODO: Load TTF/OTF fonts if you don't want to use the default font. + + // Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32 and imgui_impl_dx11) + ImGui_ImplWin32_Init(hwnd); + ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); + + // Application main loop + while (true) + { + // Feed inputs to dear imgui, start new frame + ImGui_ImplDX11_NewFrame(); + ImGui_ImplWin32_NewFrame(); + ImGui::NewFrame(); + + // Any application code here + ImGui::Text("Hello, world!"); + + // Render dear imgui into screen + ImGui::Render(); + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + g_pSwapChain->Present(1, 0); + } + + // Shutdown + ImGui_ImplDX11_Shutdown(); + ImGui_ImplWin32_Shutdown(); + ImGui::DestroyContext(); + + THIS IS HOW A SIMPLE APPLICATION MAY LOOK LIKE + EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE + + // Application init: create a dear imgui context, setup some options, load fonts + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls + // TODO: Fill optional settings of the io structure later. + // TODO: Load TTF/OTF fonts if you don't want to use the default font. // Build and load the texture atlas into a texture - unsigned char* pixels = NULL; + // (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer) int width, height; + unsigned char* pixels = NULL; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); + // At this point you've got the texture data and you need to upload that your your graphic system: + // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'. + // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ below for details about ImTextureID. MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32) - // Store your texture pointer/identifier (in whatever formatyour engine uses) in 'io.Fonts->TexID'. - // This will be passed back to your via the renderer. Read FAQ for details about ImTextureID. io.Fonts->TexID = (void*)texture; // Application main loop while (true) { - // Setup low-level inputs (e.g. on Win32, GetKeyboardState(), or write to those fields from your Windows message loop handlers, etc.) - ImGuiIO& io = ImGui::GetIO(); - io.DeltaTime = 1.0f/60.0f; - io.DisplaySize.x = 1920.0f; - io.DisplaySize.y = 1280.0f; - io.MousePos = my_mouse_pos; - io.MouseDown[0] = my_mouse_buttons[0]; + // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc. + // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform bindings) + io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds) + io.DisplaySize.x = 1920.0f; // set the current display width + io.DisplaySize.y = 1280.0f; // set the current display height here + io.MousePos = my_mouse_pos; // set the mouse position + io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states io.MouseDown[1] = my_mouse_buttons[1]; // Call NewFrame(), after this point you can use ImGui::* functions anytime @@ -163,7 +202,8 @@ // (You want to try calling EndFrame/Render as late as you can, to be able to use imgui in your own game rendering code) ImGui::EndFrame(); ImGui::Render(); - MyImGuiRenderFunction(ImGui::GetDrawData()); + ImDrawData* draw_data = ImGui::GetDrawData(); + MyImGuiRenderFunction(draw_data); SwapBuffers(); } From 0146f4b45627c1f9bb20d9bb8d4d34ff6a0204af Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 5 Jul 2018 09:17:16 +0200 Subject: [PATCH 08/16] Internals: BeginChildEx tweaks. --- imgui.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 7748838b..aed77b6f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -891,6 +891,8 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* ini namespace ImGui { +static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags); + static void NavUpdate(); static void NavUpdateWindowing(); static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id); @@ -5465,45 +5467,47 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } -static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; - ImGuiWindow* parent_window = ImGui::GetCurrentWindow(); - ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; + ImGuiWindow* parent_window = g.CurrentWindow; + + flags |= ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag - const ImVec2 content_avail = ImGui::GetContentRegionAvail(); + // Size + const ImVec2 content_avail = GetContentRegionAvail(); ImVec2 size = ImFloor(size_arg); const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); if (size.x <= 0.0f) size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues) if (size.y <= 0.0f) size.y = ImMax(content_avail.y + size.y, 4.0f); + SetNextWindowSize(size); - const float backup_border_size = g.Style.ChildBorderSize; - if (!border) - g.Style.ChildBorderSize = 0.0f; - flags |= extra_flags; - + // Name char title[256]; if (name) ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s", parent_window->Name, name); else ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id); - ImGui::SetNextWindowSize(size); - bool ret = ImGui::Begin(title, NULL, flags); - ImGuiWindow* child_window = ImGui::GetCurrentWindow(); + const float backup_border_size = g.Style.ChildBorderSize; + if (!border) + g.Style.ChildBorderSize = 0.0f; + bool ret = Begin(title, NULL, flags); + g.Style.ChildBorderSize = backup_border_size; + + ImGuiWindow* child_window = g.CurrentWindow; child_window->ChildId = id; child_window->AutoFitChildAxises = auto_fit_axises; - g.Style.ChildBorderSize = backup_border_size; // Process navigation-in immediately so NavInit can run on first frame - if (!(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll) && g.NavActivateId == id) + if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll)) { - ImGui::FocusWindow(child_window); - ImGui::NavInitWindow(child_window, false); - ImGui::SetActiveID(id+1, child_window); // Steal ActiveId with a dummy id so that key-press won't activate child item + FocusWindow(child_window); + NavInitWindow(child_window, false); + SetActiveID(id+1, child_window); // Steal ActiveId with a dummy id so that key-press won't activate child item g.ActiveIdSource = ImGuiInputSource_Nav; } From d64157e803442463ed5d5bef0adfd349b0da8ff9 Mon Sep 17 00:00:00 2001 From: Warren Moore Date: Thu, 5 Jul 2018 18:41:21 +0900 Subject: [PATCH 09/16] Introduced a new Metal renderer implementation and a new example illustrating usage of Metal on macOS and iOS (partially addresses #1873) --- examples/example_apple_metal/README.md | 6 + .../example_apple_metal/Shared/AppDelegate.h | 19 + .../example_apple_metal/Shared/AppDelegate.m | 12 + .../example_apple_metal/Shared/Renderer.h | 9 + .../example_apple_metal/Shared/Renderer.mm | 132 +++++ .../Shared/ViewController.h | 20 + .../Shared/ViewController.mm | 130 +++++ examples/example_apple_metal/Shared/main.m | 23 + .../project.pbxproj | 541 ++++++++++++++++++ .../iOS/Base.lproj/Main.storyboard | 28 + .../iOS/Default-568h@2x.png | Bin 0 -> 1673 bytes .../example_apple_metal/iOS/Info-iOS.plist | 51 ++ .../iOS/Launch Screen.storyboard | 29 + .../macOS/Base.lproj/Main.storyboard | 130 +++++ .../macOS/Info-macOS.plist | 32 ++ examples/imgui_impl_metal.h | 25 + examples/imgui_impl_metal.mm | 490 ++++++++++++++++ examples/imgui_impl_osx.h | 3 +- 18 files changed, 1678 insertions(+), 2 deletions(-) create mode 100644 examples/example_apple_metal/README.md create mode 100644 examples/example_apple_metal/Shared/AppDelegate.h create mode 100644 examples/example_apple_metal/Shared/AppDelegate.m create mode 100644 examples/example_apple_metal/Shared/Renderer.h create mode 100644 examples/example_apple_metal/Shared/Renderer.mm create mode 100644 examples/example_apple_metal/Shared/ViewController.h create mode 100644 examples/example_apple_metal/Shared/ViewController.mm create mode 100644 examples/example_apple_metal/Shared/main.m create mode 100644 examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj create mode 100644 examples/example_apple_metal/iOS/Base.lproj/Main.storyboard create mode 100644 examples/example_apple_metal/iOS/Default-568h@2x.png create mode 100644 examples/example_apple_metal/iOS/Info-iOS.plist create mode 100644 examples/example_apple_metal/iOS/Launch Screen.storyboard create mode 100644 examples/example_apple_metal/macOS/Base.lproj/Main.storyboard create mode 100644 examples/example_apple_metal/macOS/Info-macOS.plist create mode 100644 examples/imgui_impl_metal.h create mode 100644 examples/imgui_impl_metal.mm diff --git a/examples/example_apple_metal/README.md b/examples/example_apple_metal/README.md new file mode 100644 index 00000000..d43b4925 --- /dev/null +++ b/examples/example_apple_metal/README.md @@ -0,0 +1,6 @@ +# iOS / OSX Metal example + +## Introduction + +This example shows how to render ImGui with Metal. It is based on the cross-platform game template provided with Xcode as of Xcode 9. + diff --git a/examples/example_apple_metal/Shared/AppDelegate.h b/examples/example_apple_metal/Shared/AppDelegate.h new file mode 100644 index 00000000..c4632b1f --- /dev/null +++ b/examples/example_apple_metal/Shared/AppDelegate.h @@ -0,0 +1,19 @@ + +#import + +#if TARGET_OS_IPHONE + +#import + +@interface AppDelegate : UIResponder +@property (strong, nonatomic) UIWindow *window; +@end + +#else + +#import + +@interface AppDelegate : NSObject +@end + +#endif diff --git a/examples/example_apple_metal/Shared/AppDelegate.m b/examples/example_apple_metal/Shared/AppDelegate.m new file mode 100644 index 00000000..eabb44c1 --- /dev/null +++ b/examples/example_apple_metal/Shared/AppDelegate.m @@ -0,0 +1,12 @@ + +#import "AppDelegate.h" + +@implementation AppDelegate + +#if TARGET_OS_OSX +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { + return YES; +} +#endif + +@end diff --git a/examples/example_apple_metal/Shared/Renderer.h b/examples/example_apple_metal/Shared/Renderer.h new file mode 100644 index 00000000..f324915c --- /dev/null +++ b/examples/example_apple_metal/Shared/Renderer.h @@ -0,0 +1,9 @@ + +#import + +@interface Renderer : NSObject + +-(nonnull instancetype)initWithView:(nonnull MTKView *)view; + +@end + diff --git a/examples/example_apple_metal/Shared/Renderer.mm b/examples/example_apple_metal/Shared/Renderer.mm new file mode 100644 index 00000000..2f62ed17 --- /dev/null +++ b/examples/example_apple_metal/Shared/Renderer.mm @@ -0,0 +1,132 @@ + +#import "Renderer.h" +#import + +#include "imgui.h" +#include "imgui_impl_metal.h" + +#if TARGET_OS_OSX +#include "imgui_impl_osx.h" +#endif + +@interface Renderer () +@property (nonatomic, strong) id device; +@property (nonatomic, strong) id commandQueue; +@end + +@implementation Renderer + +-(nonnull instancetype)initWithView:(nonnull MTKView *)view; +{ + self = [super init]; + if(self) + { + _device = view.device; + _commandQueue = [_device newCommandQueue]; + + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + (void)ImGui::GetIO(); + + ImGui_ImplMetal_Init(_device); + + ImGui::StyleColorsDark(); + } + + return self; +} + +- (void)drawInMTKView:(MTKView *)view +{ + ImGuiIO &io = ImGui::GetIO(); + io.DisplaySize.x = view.bounds.size.width; + io.DisplaySize.y = view.bounds.size.height; + +#if TARGET_OS_OSX + CGFloat framebufferScale = view.window.screen.backingScaleFactor ?: NSScreen.mainScreen.backingScaleFactor; +#else + CGFloat framebufferScale = view.window.screen.scale ?: UIScreen.mainScreen.scale; +#endif + io.DisplayFramebufferScale = ImVec2(framebufferScale, framebufferScale); + + io.DeltaTime = 1 / float(view.preferredFramesPerSecond ?: 60); + + id commandBuffer = [self.commandQueue commandBuffer]; + + static bool show_demo_window = true; + static bool show_another_window = false; + static float clear_color[4] = { 0.28f, 0.36f, 0.5f, 1.0f }; + + MTLRenderPassDescriptor *renderPassDescriptor = view.currentRenderPassDescriptor; + if(renderPassDescriptor != nil) + { + renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); + + // Here, you could do additional rendering work, including other passes as necessary. + + id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; + + [renderEncoder pushDebugGroup:@"Draw ImGui"]; + + ImGui_ImplMetal_NewFrame(renderPassDescriptor); +#if TARGET_OS_OSX + ImGui_ImplOSX_NewFrame(view); +#endif + ImGui::NewFrame(); + + { + static float f = 0.0f; + static int counter = 0; + ImGui::Text("Hello, world!"); // Display some text (you can use a format string too) + ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f + ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color + + ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our windows open/close state + ImGui::Checkbox("Another Window", &show_another_window); + + if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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); + } + + // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows. + if (show_another_window) + { + ImGui::Begin("Another Window", &show_another_window); + ImGui::Text("Hello from another window!"); + if (ImGui::Button("Close Me")) + show_another_window = false; + ImGui::End(); + } + + // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui! + if (show_demo_window) + { + // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. + // Here we just want to make the demo initial state a bit more friendly! + ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); + ImGui::ShowDemoWindow(&show_demo_window); + } + + ImGui::Render(); + ImDrawData *drawData = ImGui::GetDrawData(); + ImGui_ImplMetal_RenderDrawData(drawData, commandBuffer, renderEncoder); + + [renderEncoder popDebugGroup]; + + [renderEncoder endEncoding]; + + [commandBuffer presentDrawable:view.currentDrawable]; + } + + [commandBuffer commit]; +} + +- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size +{ +} + +@end diff --git a/examples/example_apple_metal/Shared/ViewController.h b/examples/example_apple_metal/Shared/ViewController.h new file mode 100644 index 00000000..a8aade13 --- /dev/null +++ b/examples/example_apple_metal/Shared/ViewController.h @@ -0,0 +1,20 @@ + +#import +#import +#import "Renderer.h" + +#if TARGET_OS_IPHONE + +#import + +@interface ViewController : UIViewController +@end + +#else + +#import + +@interface ViewController : NSViewController +@end + +#endif diff --git a/examples/example_apple_metal/Shared/ViewController.mm b/examples/example_apple_metal/Shared/ViewController.mm new file mode 100644 index 00000000..6a9236c4 --- /dev/null +++ b/examples/example_apple_metal/Shared/ViewController.mm @@ -0,0 +1,130 @@ + +#import "ViewController.h" +#import "Renderer.h" +#include "imgui.h" + +#if TARGET_OS_OSX +#include "imgui_impl_osx.h" +#endif + +@interface ViewController () +@property (nonatomic, readonly) MTKView *mtkView; +@property (nonatomic, strong) Renderer *renderer; +@end + +@implementation ViewController + +- (MTKView *)mtkView { + return (MTKView *)self.view; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.mtkView.device = MTLCreateSystemDefaultDevice(); + + if (!self.mtkView.device) { + NSLog(@"Metal is not supported"); + abort(); + } + + self.renderer = [[Renderer alloc] initWithView:self.mtkView]; + + [self.renderer mtkView:self.mtkView drawableSizeWillChange:self.mtkView.bounds.size]; + + self.mtkView.delegate = self.renderer; + +#if TARGET_OS_OSX + // Add a tracking area in order to receive mouse events whenever the mouse is within the bounds of our view + NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect + options:NSTrackingMouseMoved | NSTrackingInVisibleRect | NSTrackingActiveAlways + owner:self + userInfo:nil]; + [self.view addTrackingArea:trackingArea]; + + // If we want to receive key events, we either need to be in the responder chain of the key view, + // or else we can install a local monitor. The consequence of this heavy-handed approach is that + // we receive events for all controls, not just ImGui widgets. If we had native controls in our + // window, we'd want to be much more careful than just ingesting the complete event stream, though + // we do make an effort to be good citizens by passing along events when ImGui doesn't want to capture. + NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged | NSEventTypeScrollWheel; + [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) { + BOOL wantsCapture = ImGui_ImplOSX_HandleEvent(event, self.view); + if (event.type == NSEventTypeKeyDown && wantsCapture) { + return nil; + } else { + return event; + } + + }]; + + ImGui_ImplOSX_Init(); +#endif +} + +#if TARGET_OS_OSX + +- (void)mouseMoved:(NSEvent *)event { + ImGui_ImplOSX_HandleEvent(event, self.view); +} + +- (void)mouseDown:(NSEvent *)event { + ImGui_ImplOSX_HandleEvent(event, self.view); +} + +- (void)mouseUp:(NSEvent *)event { + ImGui_ImplOSX_HandleEvent(event, self.view); +} + +- (void)mouseDragged:(NSEvent *)event { + ImGui_ImplOSX_HandleEvent(event, self.view); +} + +- (void)scrollWheel:(NSEvent *)event { + ImGui_ImplOSX_HandleEvent(event, self.view); +} + +#elif TARGET_OS_IOS + +// This touch mapping is super cheesy/hacky. We treat any touch on the screen +// as if it were a depressed left mouse button, and we don't bother handling +// multitouch correctly at all. This causes the "cursor" to behave very erratically +// when there are multiple active touches. But for demo purposes, single-touch +// interaction actually works surprisingly well. +- (void)updateIOWithTouchEvent:(UIEvent *)event { + UITouch *anyTouch = event.allTouches.anyObject; + CGPoint touchLocation = [anyTouch locationInView:self.view]; + ImGuiIO &io = ImGui::GetIO(); + io.MousePos = ImVec2(touchLocation.x, touchLocation.y); + + BOOL hasActiveTouch = NO; + for (UITouch *touch in event.allTouches) { + if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) { + hasActiveTouch = YES; + break; + } + } + io.MouseDown[0] = hasActiveTouch; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + [self updateIOWithTouchEvent:event]; +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + [self updateIOWithTouchEvent:event]; +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { + [self updateIOWithTouchEvent:event]; +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + [self updateIOWithTouchEvent:event]; +} + +#endif + +@end + diff --git a/examples/example_apple_metal/Shared/main.m b/examples/example_apple_metal/Shared/main.m new file mode 100644 index 00000000..cd8468a7 --- /dev/null +++ b/examples/example_apple_metal/Shared/main.m @@ -0,0 +1,23 @@ + +#import + +#if TARGET_OS_IPHONE + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} + +#else + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} + +#endif diff --git a/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj b/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj new file mode 100644 index 00000000..b1b6b4e7 --- /dev/null +++ b/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj @@ -0,0 +1,541 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 8307E7CC20E9F9C900473790 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7CB20E9F9C900473790 /* ViewController.mm */; }; + 8307E7CF20E9F9C900473790 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8307E7CD20E9F9C900473790 /* Main.storyboard */; }; + 8307E7DE20E9F9C900473790 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7DD20E9F9C900473790 /* AppDelegate.m */; }; + 8307E7E420E9F9C900473790 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8307E7E220E9F9C900473790 /* Main.storyboard */; }; + 8307E7E720E9F9C900473790 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7E620E9F9C900473790 /* main.m */; }; + 8307E7E820E9F9C900473790 /* Renderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7BC20E9F9C700473790 /* Renderer.mm */; }; + 8307E7E920E9F9C900473790 /* Renderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7BC20E9F9C700473790 /* Renderer.mm */; }; + 836D2A2E20EE208E0098E909 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */; }; + 836D2A3020EE4A180098E909 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */; }; + 836D2A3220EE4A900098E909 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */; }; + 83BBE9DE20EB3FFC00295997 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7E620E9F9C900473790 /* main.m */; }; + 83BBE9DF20EB40AE00295997 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7DD20E9F9C900473790 /* AppDelegate.m */; }; + 83BBE9E020EB42D000295997 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8307E7CB20E9F9C900473790 /* ViewController.mm */; }; + 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E420EB46B900295997 /* Metal.framework */; }; + 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E620EB46BD00295997 /* MetalKit.framework */; }; + 83BBE9E920EB46C100295997 /* ModelIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E820EB46C100295997 /* ModelIO.framework */; }; + 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EA20EB471700295997 /* MetalKit.framework */; }; + 83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EB20EB471700295997 /* Metal.framework */; }; + 83BBE9EF20EB471C00295997 /* ModelIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EE20EB471C00295997 /* ModelIO.framework */; }; + 83BBE9FE20EB54D800295997 /* imgui_impl_metal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */; }; + 83BBE9FF20EB54D800295997 /* imgui_impl_metal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */; }; + 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0120EB54E700295997 /* imgui_draw.cpp */; }; + 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0120EB54E700295997 /* imgui_draw.cpp */; }; + 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0220EB54E700295997 /* imgui_demo.cpp */; }; + 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0220EB54E700295997 /* imgui_demo.cpp */; }; + 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0320EB54E700295997 /* imgui.cpp */; }; + 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0320EB54E700295997 /* imgui.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 8307E7BB20E9F9C700473790 /* Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = ""; }; + 8307E7BC20E9F9C700473790 /* Renderer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Renderer.mm; sourceTree = ""; }; + 8307E7C420E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8307E7CA20E9F9C900473790 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 8307E7CB20E9F9C900473790 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = ""; }; + 8307E7CE20E9F9C900473790 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 8307E7D320E9F9C900473790 /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = ""; }; + 8307E7DA20E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 8307E7DC20E9F9C900473790 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 8307E7DD20E9F9C900473790 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 8307E7E320E9F9C900473790 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 8307E7E520E9F9C900473790 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = ""; }; + 8307E7E620E9F9C900473790 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 836D2A2C20EE208D0098E909 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../imgui_impl_osx.h; sourceTree = ""; }; + 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../imgui_impl_osx.mm; sourceTree = ""; }; + 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; + 83BBE9E420EB46B900295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; }; + 83BBE9E620EB46BD00295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/MetalKit.framework; sourceTree = DEVELOPER_DIR; }; + 83BBE9E820EB46C100295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/ModelIO.framework; sourceTree = DEVELOPER_DIR; }; + 83BBE9EA20EB471700295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; + 83BBE9EB20EB471700295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; + 83BBE9EE20EB471C00295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = System/Library/Frameworks/ModelIO.framework; sourceTree = SDKROOT; }; + 83BBE9FC20EB54D800295997 /* imgui_impl_metal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_metal.h; path = ../../imgui_impl_metal.h; sourceTree = ""; }; + 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_metal.mm; path = ../../imgui_impl_metal.mm; sourceTree = ""; }; + 83BBEA0020EB54E700295997 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; + 83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; + 83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; }; + 83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; + 83BBEA0420EB54E700295997 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8307E7C120E9F9C900473790 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 83BBE9E920EB46C100295997 /* ModelIO.framework in Frameworks */, + 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */, + 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8307E7D720E9F9C900473790 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 83BBE9EF20EB471C00295997 /* ModelIO.framework in Frameworks */, + 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */, + 83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8307E7B520E9F9C700473790 = { + isa = PBXGroup; + children = ( + 83BBE9F020EB544400295997 /* imgui */, + 8307E7BA20E9F9C700473790 /* Shared */, + 8307E7C620E9F9C900473790 /* iOS */, + 8307E7DB20E9F9C900473790 /* macOS */, + 8307E7C520E9F9C900473790 /* Products */, + 83BBE9E320EB46B800295997 /* Frameworks */, + ); + sourceTree = ""; + }; + 8307E7BA20E9F9C700473790 /* Shared */ = { + isa = PBXGroup; + children = ( + 83BBE9FC20EB54D800295997 /* imgui_impl_metal.h */, + 83BBE9FD20EB54D800295997 /* imgui_impl_metal.mm */, + 836D2A2C20EE208D0098E909 /* imgui_impl_osx.h */, + 836D2A2D20EE208E0098E909 /* imgui_impl_osx.mm */, + 8307E7DC20E9F9C900473790 /* AppDelegate.h */, + 8307E7DD20E9F9C900473790 /* AppDelegate.m */, + 8307E7BB20E9F9C700473790 /* Renderer.h */, + 8307E7BC20E9F9C700473790 /* Renderer.mm */, + 8307E7CA20E9F9C900473790 /* ViewController.h */, + 8307E7CB20E9F9C900473790 /* ViewController.mm */, + 8307E7E620E9F9C900473790 /* main.m */, + ); + path = Shared; + sourceTree = ""; + }; + 8307E7C520E9F9C900473790 /* Products */ = { + isa = PBXGroup; + children = ( + 8307E7C420E9F9C900473790 /* example_apple_metal.app */, + 8307E7DA20E9F9C900473790 /* example_apple_metal.app */, + ); + name = Products; + sourceTree = ""; + }; + 8307E7C620E9F9C900473790 /* iOS */ = { + isa = PBXGroup; + children = ( + 836D2A2F20EE4A180098E909 /* Default-568h@2x.png */, + 8307E7CD20E9F9C900473790 /* Main.storyboard */, + 8307E7D320E9F9C900473790 /* Info-iOS.plist */, + 836D2A3120EE4A900098E909 /* Launch Screen.storyboard */, + ); + path = iOS; + sourceTree = ""; + }; + 8307E7DB20E9F9C900473790 /* macOS */ = { + isa = PBXGroup; + children = ( + 8307E7E220E9F9C900473790 /* Main.storyboard */, + 8307E7E520E9F9C900473790 /* Info-macOS.plist */, + ); + path = macOS; + sourceTree = ""; + }; + 83BBE9E320EB46B800295997 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 83BBE9EE20EB471C00295997 /* ModelIO.framework */, + 83BBE9EB20EB471700295997 /* Metal.framework */, + 83BBE9EA20EB471700295997 /* MetalKit.framework */, + 83BBE9E820EB46C100295997 /* ModelIO.framework */, + 83BBE9E620EB46BD00295997 /* MetalKit.framework */, + 83BBE9E420EB46B900295997 /* Metal.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 83BBE9F020EB544400295997 /* imgui */ = { + isa = PBXGroup; + children = ( + 83BBEA0420EB54E700295997 /* imconfig.h */, + 83BBEA0020EB54E700295997 /* imgui.h */, + 83BBEA0220EB54E700295997 /* imgui_demo.cpp */, + 83BBEA0120EB54E700295997 /* imgui_draw.cpp */, + 83BBEA0320EB54E700295997 /* imgui.cpp */, + ); + name = imgui; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8307E7C320E9F9C900473790 /* example_apple_metal_ios */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8307E7F020E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_ios" */; + buildPhases = ( + 8307E7C020E9F9C900473790 /* Sources */, + 8307E7C120E9F9C900473790 /* Frameworks */, + 8307E7C220E9F9C900473790 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = example_apple_metal_ios; + productName = "imguiex iOS"; + productReference = 8307E7C420E9F9C900473790 /* example_apple_metal.app */; + productType = "com.apple.product-type.application"; + }; + 8307E7D920E9F9C900473790 /* example_apple_metal_macos */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8307E7F320E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_macos" */; + buildPhases = ( + 8307E7D620E9F9C900473790 /* Sources */, + 8307E7D720E9F9C900473790 /* Frameworks */, + 8307E7D820E9F9C900473790 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = example_apple_metal_macos; + productName = "imguiex macOS"; + productReference = 8307E7DA20E9F9C900473790 /* example_apple_metal.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8307E7B620E9F9C700473790 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0940; + ORGANIZATIONNAME = "Warren Moore"; + TargetAttributes = { + 8307E7C320E9F9C900473790 = { + CreatedOnToolsVersion = 9.4.1; + }; + 8307E7D920E9F9C900473790 = { + CreatedOnToolsVersion = 9.4.1; + }; + }; + }; + buildConfigurationList = 8307E7B920E9F9C700473790 /* Build configuration list for PBXProject "example_apple_metal" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8307E7B520E9F9C700473790; + productRefGroup = 8307E7C520E9F9C900473790 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8307E7C320E9F9C900473790 /* example_apple_metal_ios */, + 8307E7D920E9F9C900473790 /* example_apple_metal_macos */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8307E7C220E9F9C900473790 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 836D2A3220EE4A900098E909 /* Launch Screen.storyboard in Resources */, + 8307E7CF20E9F9C900473790 /* Main.storyboard in Resources */, + 836D2A3020EE4A180098E909 /* Default-568h@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8307E7D820E9F9C900473790 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8307E7E420E9F9C900473790 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8307E7C020E9F9C900473790 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8307E7E820E9F9C900473790 /* Renderer.mm in Sources */, + 8307E7CC20E9F9C900473790 /* ViewController.mm in Sources */, + 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */, + 83BBE9DF20EB40AE00295997 /* AppDelegate.m in Sources */, + 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */, + 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */, + 83BBE9FE20EB54D800295997 /* imgui_impl_metal.mm in Sources */, + 83BBE9DE20EB3FFC00295997 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8307E7D620E9F9C900473790 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 83BBE9E020EB42D000295997 /* ViewController.mm in Sources */, + 8307E7E920E9F9C900473790 /* Renderer.mm in Sources */, + 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */, + 8307E7E720E9F9C900473790 /* main.m in Sources */, + 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */, + 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */, + 83BBE9FF20EB54D800295997 /* imgui_impl_metal.mm in Sources */, + 836D2A2E20EE208E0098E909 /* imgui_impl_osx.mm in Sources */, + 8307E7DE20E9F9C900473790 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 8307E7CD20E9F9C900473790 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 8307E7CE20E9F9C900473790 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 8307E7E220E9F9C900473790 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 8307E7E320E9F9C900473790 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 8307E7EE20E9F9C900473790 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + }; + name = Debug; + }; + 8307E7EF20E9F9C900473790 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + }; + name = Release; + }; + 8307E7F120E9F9C900473790 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "$(SRCROOT)/iOS/Info-iOS.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-ios"; + PRODUCT_NAME = example_apple_metal; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 8307E7F220E9F9C900473790 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "$(SRCROOT)/iOS/Info-iOS.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-ios"; + PRODUCT_NAME = example_apple_metal; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 8307E7F420E9F9C900473790 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.13; + PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos"; + PRODUCT_NAME = example_apple_metal; + SDKROOT = macosx; + }; + name = Debug; + }; + 8307E7F520E9F9C900473790 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.13; + PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos"; + PRODUCT_NAME = example_apple_metal; + SDKROOT = macosx; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8307E7B920E9F9C700473790 /* Build configuration list for PBXProject "example_apple_metal" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8307E7EE20E9F9C900473790 /* Debug */, + 8307E7EF20E9F9C900473790 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8307E7F020E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_ios" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8307E7F120E9F9C900473790 /* Debug */, + 8307E7F220E9F9C900473790 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8307E7F320E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_macos" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8307E7F420E9F9C900473790 /* Debug */, + 8307E7F520E9F9C900473790 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8307E7B620E9F9C700473790 /* Project object */; +} diff --git a/examples/example_apple_metal/iOS/Base.lproj/Main.storyboard b/examples/example_apple_metal/iOS/Base.lproj/Main.storyboard new file mode 100644 index 00000000..24a4009e --- /dev/null +++ b/examples/example_apple_metal/iOS/Base.lproj/Main.storyboard @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/example_apple_metal/iOS/Default-568h@2x.png b/examples/example_apple_metal/iOS/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..e3ce940a36b6bebefdc8944e931dac246a1ec425 GIT binary patch literal 1673 zcmeHGJ7^R^7@j;(2?=PCLaT98iQdl4CimDSYfNtMyoGEyFAE;nxVJk=mSi8l0%a#sB~l zdQEEpFuVi6Xn1CXdyE^C62H!~N|P-IE39or6wEt8i$dMAR%wG;PP+M?&H^wp>6%T} zG!_**@I))ah=~_+HUP78Nod*Yl))BVb$wO%`f68zuA>S!^9DA;GF@|P+Yw#fUNY_N zbz63XxvOwCQMiCdnFSMX!;h6j6*{^Ke`jtazz&41tHM!IO`{IWK}2C*EaYr5gJDq? zNdeE~$rUJJQbah9a3P0@f=h}-VD|_-TI8%K4XxUZ#Vu7>V=Pn8D%9PCZg`mu zB@v7H4#Y4N-H(~&+f>(7fs;hnbre$2uq0Qfi^YX1A(c|8f~Cqd(MkneDCeuV$JGLR z%cDN)ah+rC%s_57eJ|vZH5$2hs8fvs4|b|l+`+k!fqGr8GdLG%AQ$muP&UgyX4`Y| zg~^`%P31;^*Qw7JJmQ=D?os-X|AJHXMYF>1G)*trpNssX9qQV=nH+rCe>(y2`0$J8 zzxLfHpU&M{-0>fbn?DanYx1?Zy~}&2vrlw#PCD>kc3^Yp!;jG#dGlI7I~2X#eF{dv Wx9{NM<9i1mvwHN(lJ;!j_TAqnTQ0Z& literal 0 HcmV?d00001 diff --git a/examples/example_apple_metal/iOS/Info-iOS.plist b/examples/example_apple_metal/iOS/Info-iOS.plist new file mode 100644 index 00000000..8d919d1e --- /dev/null +++ b/examples/example_apple_metal/iOS/Info-iOS.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + imgui + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + Launch Screen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + metal + + UIRequiresFullScreen + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortraitUpsideDown + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/example_apple_metal/iOS/Launch Screen.storyboard b/examples/example_apple_metal/iOS/Launch Screen.storyboard new file mode 100644 index 00000000..96047e1f --- /dev/null +++ b/examples/example_apple_metal/iOS/Launch Screen.storyboard @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/example_apple_metal/macOS/Base.lproj/Main.storyboard b/examples/example_apple_metal/macOS/Base.lproj/Main.storyboard new file mode 100644 index 00000000..cf414617 --- /dev/null +++ b/examples/example_apple_metal/macOS/Base.lproj/Main.storyboard @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/example_apple_metal/macOS/Info-macOS.plist b/examples/example_apple_metal/macOS/Info-macOS.plist new file mode 100644 index 00000000..52d99204 --- /dev/null +++ b/examples/example_apple_metal/macOS/Info-macOS.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + imgui + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2018 Warren Moore. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/examples/imgui_impl_metal.h b/examples/imgui_impl_metal.h new file mode 100644 index 00000000..c4f958b4 --- /dev/null +++ b/examples/imgui_impl_metal.h @@ -0,0 +1,25 @@ +// ImGui Renderer for: Metal +// This needs to be used along with a Platform Binding (e.g. OSX) + +// Implemented features: +// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +@class MTLRenderPassDescriptor; +@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder; + +IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id device); +IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); +IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor); +IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, + id commandBuffer, + id commandEncoder); + +// Called by Init/NewFrame/Shutdown +IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id device); +IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture(); +IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id device); +IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm new file mode 100644 index 00000000..99fdec7b --- /dev/null +++ b/examples/imgui_impl_metal.mm @@ -0,0 +1,490 @@ +// ImGui Renderer for: Metal +// This needs to be used along with a Platform Binding (e.g. OSX) + +// Implemented features: +// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. + +// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. +// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. +// https://github.com/ocornut/imgui + +// CHANGELOG +// (minor and older changes stripped away, please see git history for details) +// 2018-07-05: Metal: Added new Metal backend implementation + +#include "imgui.h" +#include "imgui_impl_metal.h" + +#import +#import +#import + +#pragma mark - Support classes + +// A wrapper around a MTLBuffer object that knows the last time it was reused +@interface MetalBuffer : NSObject +@property (nonatomic, strong) id buffer; +@property (nonatomic, assign) NSTimeInterval lastReuseTime; +- (instancetype)initWithBuffer:(id)buffer; +@end + +// An object that encapsulates the data necessary to uniquely identify a +// render pipeline state. These are used as cache keys. +@interface FramebufferDescriptor : NSObject +@property (nonatomic, assign) unsigned long sampleCount; +@property (nonatomic, assign) MTLPixelFormat colorPixelFormat; +@property (nonatomic, assign) MTLPixelFormat depthPixelFormat; +@property (nonatomic, assign) MTLPixelFormat stencilPixelFormat; +- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor; +@end + +// A singleton that stores long-lived objects that are needed by the Metal +// renderer backend. Stores the render pipeline state cache and the default +// font texture, and manages the reusable buffer cache. +@interface MetalContext : NSObject +@property (nonatomic, strong) id depthStencilState; +@property (nonatomic, strong) FramebufferDescriptor *framebufferDescriptor; // framebuffer descriptor for current frame; transient +@property (nonatomic, strong) NSMutableDictionary *renderPipelineStateCache; // pipeline cache; keyed on framebuffer descriptors +@property (nonatomic, strong, nullable) id fontTexture; +@property (nonatomic, strong) NSMutableArray *bufferCache; +@property (nonatomic, assign) NSTimeInterval lastBufferCachePurge; +- (void)makeDeviceObjectsWithDevice:(id)device; +- (void)makeFontTextureWithDevice:(id)device; +- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device; +- (void)enqueueReusableBuffer:(MetalBuffer *)buffer; +- (id)renderPipelineStateForFrameAndDevice:(id)device; +- (void)emptyRenderPipelineStateCache; +- (void)renderDrawData:(ImDrawData *)drawData + commandBuffer:(id)commandBuffer + commandEncoder:(id)commandEncoder; +@end + +static MetalContext *g_sharedMetalContext = nil; + +#pragma mark - ImGui API implementation + +bool ImGui_ImplMetal_Init(id device) +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + g_sharedMetalContext = [[MetalContext alloc] init]; + }); + + ImGui_ImplMetal_CreateDeviceObjects(device); + + return true; +} + +void ImGui_ImplMetal_Shutdown() +{ + ImGui_ImplMetal_DestroyDeviceObjects(); +} + +void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor) +{ + IM_ASSERT(g_sharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init?"); + + g_sharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor]; +} + +// Metal Render function. +void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id commandBuffer, id commandEncoder) +{ + [g_sharedMetalContext renderDrawData:draw_data commandBuffer:commandBuffer commandEncoder:commandEncoder]; +} + +bool ImGui_ImplMetal_CreateFontsTexture(id device) +{ + [g_sharedMetalContext makeFontTextureWithDevice:device]; + + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture; + + return (g_sharedMetalContext.fontTexture != nil); +} + +void ImGui_ImplMetal_DestroyFontsTexture() +{ + ImGuiIO& io = ImGui::GetIO(); + g_sharedMetalContext.fontTexture = nil; + io.Fonts->TexID = nullptr; +} + +bool ImGui_ImplMetal_CreateDeviceObjects(id device) +{ + [g_sharedMetalContext makeDeviceObjectsWithDevice:device]; + + ImGui_ImplMetal_CreateFontsTexture(device); + + return true; +} + +void ImGui_ImplMetal_DestroyDeviceObjects() +{ + ImGui_ImplMetal_DestroyFontsTexture(); + [g_sharedMetalContext emptyRenderPipelineStateCache]; +} + +#pragma mark - MetalBuffer implementation + +@implementation MetalBuffer +- (instancetype)initWithBuffer:(id)buffer { + if ((self = [super init])) { + _buffer = buffer; + _lastReuseTime = [NSDate date].timeIntervalSince1970; + } + return self; +} +@end + +#pragma mark - FramebufferDescriptor implementation + +@implementation FramebufferDescriptor +- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor { + if ((self = [super init])) { + _sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount; + _colorPixelFormat = renderPassDescriptor.colorAttachments[0].texture.pixelFormat; + _depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat; + _stencilPixelFormat = renderPassDescriptor.stencilAttachment.texture.pixelFormat; + } + return self; +} + +- (nonnull id)copyWithZone:(nullable NSZone *)zone { + FramebufferDescriptor *copy = [[FramebufferDescriptor allocWithZone:zone] init]; + copy.sampleCount = self.sampleCount; + copy.colorPixelFormat = self.colorPixelFormat; + copy.depthPixelFormat = self.depthPixelFormat; + copy.stencilPixelFormat = self.stencilPixelFormat; + return copy; +} + +- (NSUInteger)hash { + NSUInteger sc = _sampleCount & 0x3; + NSUInteger cf = _colorPixelFormat & 0x3FF; + NSUInteger df = _depthPixelFormat & 0x3FF; + NSUInteger sf = _stencilPixelFormat & 0x3FF; + NSUInteger hash = (sf << 22) | (df << 12) | (cf << 2) | sc; + return hash; +} + +- (BOOL)isEqual:(id)object { + FramebufferDescriptor *other = object; + if (![other isKindOfClass:[FramebufferDescriptor class]]) { + return NO; + } + return other.sampleCount == self.sampleCount && + other.colorPixelFormat == self.colorPixelFormat && + other.depthPixelFormat == self.depthPixelFormat && + other.stencilPixelFormat == self.stencilPixelFormat; +} + +@end + +#pragma mark - MetalContext implementation + +@implementation MetalContext +- (instancetype)init { + if ((self = [super init])) { + _renderPipelineStateCache = [NSMutableDictionary dictionary]; + _bufferCache = [NSMutableArray array]; + _lastBufferCachePurge = [NSDate date].timeIntervalSince1970; + } + return self; +} + +- (void)makeDeviceObjectsWithDevice:(id)device { + MTLDepthStencilDescriptor *depthStencilDescriptor = [[MTLDepthStencilDescriptor alloc] init]; + depthStencilDescriptor.depthWriteEnabled = NO; + depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways; + self.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; +} + +- (void)makeFontTextureWithDevice:(id)device { + ImGuiIO &io = ImGui::GetIO(); + unsigned char* pixels; + int width, height; + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); + MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm + width:width + height:height + mipmapped:NO]; + textureDescriptor.usage = MTLTextureUsageShaderRead; +#if TARGET_OS_OSX + textureDescriptor.storageMode = MTLStorageModeManaged; +#else + textureDescriptor.storageMode = MTLStorageModeShared; +#endif + id texture = [device newTextureWithDescriptor:textureDescriptor]; + [texture replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:pixels bytesPerRow:width * 4]; + self.fontTexture = texture; +} + +- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device { + NSTimeInterval now = [NSDate date].timeIntervalSince1970; + + // Purge old buffers that haven't been useful for a while + if (now - self.lastBufferCachePurge > 1.0) { + NSMutableArray *survivors = [NSMutableArray array]; + for (MetalBuffer *candidate in self.bufferCache) { + if (candidate.lastReuseTime > self.lastBufferCachePurge) { + [survivors addObject:candidate]; + } + } + self.bufferCache = [survivors mutableCopy]; + self.lastBufferCachePurge = now; + } + + // See if we have a buffer we can reuse + MetalBuffer *bestCandidate = nil; + for (MetalBuffer *candidate in self.bufferCache) { + if (candidate.buffer.length >= length && (bestCandidate == nil || bestCandidate.lastReuseTime > candidate.lastReuseTime)) { + bestCandidate = candidate; + } + } + + if (bestCandidate != nil) { + [self.bufferCache removeObject:bestCandidate]; + bestCandidate.lastReuseTime = now; + return bestCandidate; + } + + // No luck; make a new buffer + id backing = [device newBufferWithLength:length options:MTLResourceStorageModeShared]; + return [[MetalBuffer alloc] initWithBuffer:backing]; +} + +- (void)enqueueReusableBuffer:(MetalBuffer *)buffer { + [self.bufferCache addObject:buffer]; +} + +- (_Nullable id)renderPipelineStateForFrameAndDevice:(id)device { + // Try to retrieve a render pipeline state that is compatible with the framebuffer config for this frame + // Thie hit rate for this cache should be very near 100%. + id renderPipelineState = self.renderPipelineStateCache[self.framebufferDescriptor]; + + if (renderPipelineState == nil) { + // No luck; make a new render pipeline state + renderPipelineState = [self _renderPipelineStateForFramebufferDescriptor:self.framebufferDescriptor device:device]; + // Cache render pipeline state for later reuse + self.renderPipelineStateCache[self.framebufferDescriptor] = renderPipelineState; + } + + return renderPipelineState; +} + +- (id)_renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor *)descriptor device:(id)device +{ + NSError *error = nil; + + NSString *shaderSource = @"" + "#include \n" + "using namespace metal;\n" + "\n" + "struct Uniforms {\n" + " float4x4 projectionMatrix;\n" + "};\n" + "\n" + "struct VertexIn {\n" + " float2 position [[attribute(0)]];\n" + " float2 texCoords [[attribute(1)]];\n" + " uchar4 color [[attribute(2)]];\n" + "};\n" + "\n" + "struct VertexOut {\n" + " float4 position [[position]];\n" + " float2 texCoords;\n" + " float4 color;\n" + "};\n" + "\n" + "vertex VertexOut vertex_main(VertexIn in [[stage_in]],\n" + " constant Uniforms &uniforms [[buffer(1)]]) {\n" + " VertexOut out;\n" + " out.position = uniforms.projectionMatrix * float4(in.position, 0, 1);\n" + " out.texCoords = in.texCoords;\n" + " out.color = float4(in.color) / float4(255.0);\n" + " return out;\n" + "}\n" + "\n" + "fragment half4 fragment_main(VertexOut in [[stage_in]],\n" + " texture2d texture [[texture(0)]]) {\n" + " constexpr sampler linearSampler(coord::normalized, min_filter::linear, mag_filter::linear, mip_filter::linear);\n" + " half4 texColor = texture.sample(linearSampler, in.texCoords);\n" + " return half4(in.color) * texColor;\n" + "}\n"; + + id library = [device newLibraryWithSource:shaderSource options:nil error:&error]; + if (library == nil) { + NSLog(@"Error: failed to create Metal library: %@", error); + return nil; + } + + id vertexFunction = [library newFunctionWithName:@"vertex_main"]; + id fragmentFunction = [library newFunctionWithName:@"fragment_main"]; + + if (vertexFunction == nil || fragmentFunction == nil) { + NSLog(@"Error: failed to find Metal shader functions in library: %@", error); + return nil; + } + + MTLVertexDescriptor *vertexDescriptor = [MTLVertexDescriptor vertexDescriptor]; + vertexDescriptor.attributes[0].offset = IM_OFFSETOF(ImDrawVert, pos); + vertexDescriptor.attributes[0].format = MTLVertexFormatFloat2; // position + vertexDescriptor.attributes[0].bufferIndex = 0; + vertexDescriptor.attributes[1].offset = IM_OFFSETOF(ImDrawVert, uv); + vertexDescriptor.attributes[1].format = MTLVertexFormatFloat2; // texCoords + vertexDescriptor.attributes[1].bufferIndex = 0; + vertexDescriptor.attributes[2].offset = IM_OFFSETOF(ImDrawVert, col); + vertexDescriptor.attributes[2].format = MTLVertexFormatUChar4; // color + vertexDescriptor.attributes[2].bufferIndex = 0; + vertexDescriptor.layouts[0].stepRate = 1; + vertexDescriptor.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; + vertexDescriptor.layouts[0].stride = sizeof(ImDrawVert); + + MTLRenderPipelineDescriptor *pipelineDescriptor = [[MTLRenderPipelineDescriptor alloc] init]; + pipelineDescriptor.vertexFunction = vertexFunction; + pipelineDescriptor.fragmentFunction = fragmentFunction; + pipelineDescriptor.vertexDescriptor = vertexDescriptor; + pipelineDescriptor.sampleCount = self.framebufferDescriptor.sampleCount; + pipelineDescriptor.colorAttachments[0].pixelFormat = self.framebufferDescriptor.colorPixelFormat; + pipelineDescriptor.colorAttachments[0].blendingEnabled = YES; + pipelineDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd; + pipelineDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd; + pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha; + pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha; + pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha; + pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha; + pipelineDescriptor.depthAttachmentPixelFormat = self.framebufferDescriptor.depthPixelFormat; + pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat; + + id renderPipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDescriptor error:&error]; + if (error != nil) { + NSLog(@"Error: failed to create Metal pipeline state: %@", error); + } + + return renderPipelineState; +} + +- (void)emptyRenderPipelineStateCache { + [self.renderPipelineStateCache removeAllObjects]; +} + +- (void)renderDrawData:(ImDrawData *)drawData + commandBuffer:(id)commandBuffer + commandEncoder:(id)commandEncoder +{ + // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) + ImGuiIO &io = ImGui::GetIO(); + int fb_width = (int)(drawData->DisplaySize.x * io.DisplayFramebufferScale.x); + int fb_height = (int)(drawData->DisplaySize.y * io.DisplayFramebufferScale.y); + if (fb_width <= 0 || fb_height <= 0 || drawData->CmdListsCount == 0) + return; + drawData->ScaleClipRects(io.DisplayFramebufferScale); + + [commandEncoder setCullMode:MTLCullModeNone]; + [commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState]; + + // Setup viewport, orthographic projection matrix + // Our visible imgui space lies from draw_data->DisplayPps (top left) to + // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. + MTLViewport viewport = { .originX = 0.0, + .originY = 0.0, + .width = double(fb_width), + .height = double(fb_height), + .znear = 0.0, + .zfar = 1.0 }; + [commandEncoder setViewport:viewport]; + float L = drawData->DisplayPos.x; + float R = drawData->DisplayPos.x + drawData->DisplaySize.x; + float T = drawData->DisplayPos.y; + float B = drawData->DisplayPos.y + drawData->DisplaySize.y; + float N = viewport.znear; + float F = viewport.zfar; + const float ortho_projection[4][4] = + { + { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, + { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, + { 0.0f, 0.0f, 1/(F-N), 0.0f }, + { (R+L)/(L-R), (T+B)/(B-T), N/(F-N), 1.0f }, + }; + + [commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1]; + + size_t vertexBufferLength = 0; + size_t indexBufferLength = 0; + for (int n = 0; n < drawData->CmdListsCount; n++) { + const ImDrawList* cmd_list = drawData->CmdLists[n]; + vertexBufferLength += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); + indexBufferLength += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx); + } + + MetalBuffer *vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device]; + MetalBuffer *indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device]; + + id renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device]; + [commandEncoder setRenderPipelineState:renderPipelineState]; + + [commandEncoder setVertexBuffer:vertexBuffer.buffer offset:0 atIndex:0]; + + size_t vertexBufferOffset = 0; + size_t indexBufferOffset = 0; + ImVec2 pos = drawData->DisplayPos; + for (int n = 0; n < drawData->CmdListsCount; n++) + { + const ImDrawList* cmd_list = drawData->CmdLists[n]; + ImDrawIdx idx_buffer_offset = 0; + + memcpy((char *)vertexBuffer.buffer.contents + vertexBufferOffset, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); + memcpy((char *)indexBuffer.buffer.contents + indexBufferOffset, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); + + [commandEncoder setVertexBufferOffset:vertexBufferOffset atIndex:0]; + + for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; + if (pcmd->UserCallback) + { + // User callback (registered via ImDrawList::AddCallback) + pcmd->UserCallback(cmd_list, pcmd); + } + else + { + ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pos.x, pcmd->ClipRect.w - pos.y); + if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) + { + // Apply scissor/clipping rectangle + MTLScissorRect scissorRect = { .x = NSUInteger(clip_rect.x), + .y = NSUInteger(clip_rect.y), + .width = NSUInteger(clip_rect.z - clip_rect.x), + .height = NSUInteger(clip_rect.w - clip_rect.y) }; + [commandEncoder setScissorRect:scissorRect]; + + + // Bind texture, Draw + if (pcmd->TextureId != NULL) { + [commandEncoder setFragmentTexture:(__bridge id)(pcmd->TextureId) atIndex:0]; + } + [commandEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle + indexCount:pcmd->ElemCount + indexType:sizeof(ImDrawIdx) == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 + indexBuffer:indexBuffer.buffer + indexBufferOffset:indexBufferOffset + idx_buffer_offset]; + } + } + idx_buffer_offset += pcmd->ElemCount * sizeof(ImDrawIdx); + } + + vertexBufferOffset += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); + indexBufferOffset += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx); + } + + __weak id weakSelf = self; + [commandBuffer addCompletedHandler:^(id) { + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf enqueueReusableBuffer:vertexBuffer]; + [weakSelf enqueueReusableBuffer:indexBuffer]; + }); + }]; +} + +@end diff --git a/examples/imgui_impl_osx.h b/examples/imgui_impl_osx.h index bbe72fc9..6ad4bc38 100644 --- a/examples/imgui_impl_osx.h +++ b/examples/imgui_impl_osx.h @@ -2,9 +2,8 @@ // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) @class NSEvent; -@class NSVew; +@class NSView; -// FIXME-OSX: Try replacing with NSView IMGUI_API bool ImGui_ImplOSX_Init(); IMGUI_API void ImGui_ImplOSX_Shutdown(); IMGUI_API void ImGui_ImplOSX_NewFrame(NSView *_Nonnull view); From 42bf149ac6940040c4cb629fe8710e972e28f5c9 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 6 Jul 2018 15:30:21 +0200 Subject: [PATCH 10/16] Removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor `io.OptResizeWindowsFromEdges=true` to enable the feature globally. (#1495) The feature is not currently enabled by default because it is not satisfying enough. --- CHANGELOG.txt | 7 +++++++ imgui.cpp | 9 +++++++-- imgui.h | 9 ++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 64f399ca..d2482ff1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -33,16 +33,23 @@ HOW TO UPDATE? VERSION 1.63 WIP (IN PROGRESS) ----------------------------------------------------------------------- +Breaking Changes: + + - Removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor `io.OptResizeWindowsFromEdges=true` to enable the feature globally. (#1495) + The feature is not currently enabled by default because it is not satisfying enough. + Other Changes: - ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat). - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. - Window: Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) + - Window: Added global io.OptResizeWindowsFromEdges option to enable resizing windows from their edges and from the lower-left corner. (#1495) - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) - Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor. + ----------------------------------------------------------------------- VERSION 1.62 (Released 2018-06-22) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index aed77b6f..9dcd918b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -305,6 +305,7 @@ When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. + - 2018/07/06 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.OptResizeWindowsFromEdges to enable the feature. - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set. - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details. - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more. @@ -3715,6 +3716,10 @@ void ImGui::NewFrame() if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation."); + // The beta io.OptResizeWindowsFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. + if (g.IO.OptResizeWindowsFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors)) + g.IO.OptResizeWindowsFromEdges = false; + // Load settings on first frame (if not explicitly loaded manually before) if (!g.SettingsLoaded) { @@ -5936,7 +5941,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) return; - const int resize_border_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 4 : 0; + const int resize_border_count = g.IO.OptResizeWindowsFromEdges ? 4 : 0; const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f); const float grip_hover_size = (float)(int)(grip_draw_size * 0.75f); @@ -6337,7 +6342,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Handle manual resize: Resize Grips, Borders, Gamepad int border_held = -1; ImU32 resize_grip_col[4] = { 0 }; - const int resize_grip_count = (flags & ImGuiWindowFlags_ResizeFromAnySide) ? 2 : 1; // 4 + const int resize_grip_count = g.IO.OptResizeWindowsFromEdges ? 2 : 1; // 4 const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f); if (!window->Collapsed) UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]); diff --git a/imgui.h b/imgui.h index 1e4d26a7..d4bba375 100644 --- a/imgui.h +++ b/imgui.h @@ -595,7 +595,6 @@ enum ImGuiWindowFlags_ ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set. ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame - //ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items (OBSOLETE! Use e.g. style.FrameBorderSize=1.0f to enable borders). ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs, hovering test with pass through. ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar @@ -605,7 +604,6 @@ enum ImGuiWindowFlags_ ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y) ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x) ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient) - ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // [BETA] Enable resize from any corners and borders. Your back-end needs to honor the different values of io.MouseCursor set by imgui. ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB) ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, @@ -617,6 +615,10 @@ enum ImGuiWindowFlags_ ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup() ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal() ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu() + + // [Obsolete] + //ImGuiWindowFlags_ShowBorders = 1 << 7, // --> Set style.FrameBorderSize=1.0f / style.WindowBorderSize=1.0f to enable borders around windows and items + //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.OptResizeWindowsFromEdges and make sure mouse cursors are supported by back-end (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) }; // Flags for ImGui::InputText() @@ -1079,9 +1081,10 @@ struct ImGuiIO ImVec2 DisplayVisibleMin; // (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area. ImVec2 DisplayVisibleMax; // (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize - // Advanced/subtle behaviors + // Miscellaneous options bool OptMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl bool OptCursorBlink; // = true // Enable blinking cursor, for users who consider it annoying. + bool OptResizeWindowsFromEdges;// = false // [BETA] Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be the ImGuiWindowFlags_ResizeFromAnySide flag) //------------------------------------------------------------------ // Settings (User Functions) From 93950b8c3262daeb6cb13abf6bc5472f5d871ac0 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 6 Jul 2018 14:54:22 +0200 Subject: [PATCH 11/16] Internals: Removed unused ShadeVertsLinearAlphaGradientForLeftToRightText code. --- imgui_draw.cpp | 17 ----------------- imgui_internal.h | 1 - 2 files changed, 18 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 5ab40ac9..dfb8bb4b 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1267,23 +1267,6 @@ void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDra } } -// Scan and shade backward from the end of given vertices. Assume vertices are text only (= vert_start..vert_end going left to right) so we can break as soon as we are out the gradient bounds. -void ImGui::ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x) -{ - float gradient_extent_x = gradient_p1_x - gradient_p0_x; - float gradient_inv_length2 = 1.0f / (gradient_extent_x * gradient_extent_x); - int full_alpha_count = 0; - for (ImDrawVert* vert = vert_end - 1; vert >= vert_start; vert--) - { - float d = (vert->pos.x - gradient_p0_x) * (gradient_extent_x); - float alpha_mul = 1.0f - ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); - if (alpha_mul >= 1.0f && ++full_alpha_count > 2) - return; // Early out - int a = (int)(((vert->col >> IM_COL32_A_SHIFT) & 0xFF) * alpha_mul); - vert->col = (vert->col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); - } -} - // Distribute UV over (a, b) rectangle void ImGui::ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp) { diff --git a/imgui_internal.h b/imgui_internal.h index cc5c77c0..d4737042 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1175,7 +1175,6 @@ namespace ImGui // Shade functions (write over already created vertices) IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1); - IMGUI_API void ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x); IMGUI_API void ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp); } // namespace ImGui From d11d211e5d2cc2082dc5198263d85262d429d293 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 6 Jul 2018 18:28:12 +0200 Subject: [PATCH 12/16] Allow popup from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) Wider generalization of b16603745c9c8c0f8f4a1c5721f221e01aa7bcce. --- imgui.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 9dcd918b..1ed13760 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5831,8 +5831,10 @@ static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents) else { // When the window cannot fit all contents (either because of constraints, either because screen is too small): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding. - ImVec2 size_min(0.0f, 0.0f); - if (!(window->Flags & ImGuiWindowFlags_ChildMenu)) + const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0 && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0; + const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0; + ImVec2 size_min(1.0f, 1.0f); + if (!is_popup && !is_menu) size_min = style.WindowMinSize; ImVec2 size_auto_fit = ImClamp(size_contents, size_min, ImMax(size_min, g.IO.DisplaySize - style.DisplaySafeAreaPadding * 2.0f)); ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit); From c3f9220c1588720f35a1f77f6b51731c6b3fa270 Mon Sep 17 00:00:00 2001 From: Omar Cornut Date: Sun, 8 Jul 2018 10:47:31 +0200 Subject: [PATCH 13/16] Apple: Fixed example_osx_opengl2, renamed to example_apple_opengl2 + misc comments --- CHANGELOG.txt | 5 +++++ README.md | 6 +++--- examples/README.txt | 11 +++++++++-- .../example_apple_opengl2.xcodeproj}/project.pbxproj | 0 .../main.mm | 12 ++++++------ examples/imgui_impl_metal.mm | 2 +- examples/imgui_impl_osx.h | 5 +++++ examples/imgui_impl_osx.mm | 6 +++--- 8 files changed, 32 insertions(+), 15 deletions(-) rename examples/{example_osx_opengl2/example_osx_opengl2.xcodeproj => example_apple_opengl2/example_apple_opengl2.xcodeproj}/project.pbxproj (100%) rename examples/{example_osx_opengl2 => example_apple_opengl2}/main.mm (98%) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 664c5646..a2bb195a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -41,8 +41,13 @@ Other Changes: - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) + - Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm] + - Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut] + - Examples: Added mac OSX & iOS + Metal example in example_apple_metal/. (#1929, #1873) [@warrenm] + - Examples: Added mac OSX + OpenGL2 example in example_apple_opengl2/. (#1873) - Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor. + ----------------------------------------------------------------------- VERSION 1.62 (Released 2018-06-22) ----------------------------------------------------------------------- diff --git a/README.md b/README.md index 953d5ad6..2abaf031 100644 --- a/README.md +++ b/README.md @@ -125,10 +125,9 @@ Languages: (third-party bindings) - Swift [swift-imgui](https://github.com/mnmly/Swift-imgui) Frameworks: -- Renderers: DirectX 9, DirectX 10, DirectX 11, DirectX 12, OpenGL2, OpenGL3+, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples) -- Platform: GLFW, SDL, Win32, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples) +- Renderers: DirectX 9, DirectX 10, DirectX 11, DirectX 12, Metal, OpenGL2, OpenGL3+, Vulkan: [examples/](https://github.com/ocornut/imgui/tree/master/examples) +- Platform: GLFW, SDL, Win32, OSX, Freeglut: [examples/](https://github.com/ocornut/imgui/tree/master/examples) - Framework: Allegro 5, Marmalade: [examples/](https://github.com/ocornut/imgui/tree/master/examples) -- Unmerged Branch: OSX platform without GLFW/SDL: [#1873](https://github.com/ocornut/imgui/tree/osx) - Unmerged PR: SDL2 + OpenGLES + Emscripten: [#336](https://github.com/ocornut/imgui/pull/336) - Unmerged PR: Native Win32 and OSX: [#281](https://github.com/ocornut/imgui/pull/281) - Unmerged PR: Android: [#421](https://github.com/ocornut/imgui/pull/421) @@ -170,6 +169,7 @@ User screenshots:
[Gallery Part 4](https://github.com/ocornut/imgui/issues/973) (Jan 2017 to Aug 2017)
[Gallery Part 5](https://github.com/ocornut/imgui/issues/1269) (Aug 2017 to Feb 2018)
[Gallery Part 6](https://github.com/ocornut/imgui/issues/1607) (Feb 2018 onward) +
[Gallery Part 6](https://github.com/ocornut/imgui/issues/1902) (June 2018 onward)
Also see the [Mega screenshots](https://github.com/ocornut/imgui/issues/1273) for an idea of the available features. Various tools diff --git a/examples/README.txt b/examples/README.txt index a7c7e222..766729d7 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -113,7 +113,8 @@ List of Renderer Bindings in this repository: imgui_impl_dx9.cpp ; DirectX9 imgui_impl_dx10.cpp ; DirectX10 imgui_impl_dx11.cpp ; DirectX11 - imgui_impl_dx12.cpp ; DirectX12 + imgui_impl_dx12.cpp ; DirectX12 + imgui_impl_metal.mm ; Metal (with ObjC) imgui_impl_opengl2.cpp ; OpenGL2 (legacy, fixed pipeline <- don't use with modern OpenGL context) imgui_impl_opengl3.cpp ; OpenGL3 (modern programmable pipeline) imgui_impl_vulkan.cpp ; Vulkan @@ -144,6 +145,7 @@ Building: - Makefiles for Linux/OSX - Batch files for Visual Studio 2008+ - A .sln project file for Visual Studio 2010+ + - Xcode project files for the Apple examples Please let me know if they don't work with your setup! You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those directly with a command-line compiler. @@ -208,7 +210,12 @@ example_sdl_vulkan/ This is quite long and tedious, because: Vulkan. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp -example_osx_opengl2/ +example_apple_metal/ + OSX & iOS + Metal. + It is based on the cross-platform game template provided with Xcode as of Xcode 9. + = game template + imgui_impl_osx.mm + imgui_impl_metal.mm + +example_apple_opengl2/ OSX Cocoa + OpenGL2. = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp diff --git a/examples/example_osx_opengl2/example_osx_opengl2.xcodeproj/project.pbxproj b/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj similarity index 100% rename from examples/example_osx_opengl2/example_osx_opengl2.xcodeproj/project.pbxproj rename to examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj diff --git a/examples/example_osx_opengl2/main.mm b/examples/example_apple_opengl2/main.mm similarity index 98% rename from examples/example_osx_opengl2/main.mm rename to examples/example_apple_opengl2/main.mm index 710ffe24..a8f4d364 100644 --- a/examples/example_osx_opengl2/main.mm +++ b/examples/example_apple_opengl2/main.mm @@ -144,12 +144,12 @@ } // Forward Mouse/Keyboard events to dear imgui OSX back-end. It returns true when imgui is expecting to use the event. --(void)keyUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } --(void)keyDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } --(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } --(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } --(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } --(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event); } +-(void)keyUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } +-(void)keyDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } +-(void)flagsChanged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } +-(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } +-(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } +-(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } @end diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm index 99fdec7b..8ee0643f 100644 --- a/examples/imgui_impl_metal.mm +++ b/examples/imgui_impl_metal.mm @@ -10,7 +10,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) -// 2018-07-05: Metal: Added new Metal backend implementation +// 2018-07-05: Metal: Added new Metal backend implementation. #include "imgui.h" #include "imgui_impl_metal.h" diff --git a/examples/imgui_impl_osx.h b/examples/imgui_impl_osx.h index 6ad4bc38..1ae2cc01 100644 --- a/examples/imgui_impl_osx.h +++ b/examples/imgui_impl_osx.h @@ -1,5 +1,10 @@ // ImGui Platform Binding for: OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) +// [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac. + +// Issues: +// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. +// [ ] Platform: Mouse cursor shapes and visibility are not supported (see end of https://github.com/glfw/glfw/issues/427) @class NSEvent; @class NSView; diff --git a/examples/imgui_impl_osx.mm b/examples/imgui_impl_osx.mm index d0b7efd2..cd242149 100644 --- a/examples/imgui_impl_osx.mm +++ b/examples/imgui_impl_osx.mm @@ -1,10 +1,10 @@ // ImGui Platform Binding for: OSX / Cocoa // This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) +// [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac. // Issues: // [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. -// [ ] Platform: Mouse cursor shapes are not supported (see end of https://github.com/glfw/glfw/issues/427) -// [ ] Test with another renderer back-end than OpenGL2. e.g. OpenGL3. +// [ ] Platform: Mouse cursor shapes and visibility are not supported (see end of https://github.com/glfw/glfw/issues/427) #include "imgui.h" #include "imgui_impl_osx.h" @@ -12,7 +12,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) -// 2018-06-XX: Initial version. +// 2018-07-07: Initial version. // Data static clock_t g_Time = 0; From 569e0f07f18f7391d956fd982ce4a5aa1dfd7a23 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 8 Jul 2018 10:57:16 +0200 Subject: [PATCH 14/16] Examples: Removed old example_apple/ + tweak comments (#1873) --- examples/README.txt | 42 +- examples/example_apple/README.md | 43 - .../example_apple/imguiex-ios/AppDelegate.h | 13 - .../example_apple/imguiex-ios/AppDelegate.m | 41 - .../imguiex-ios/Base.lproj/LaunchScreen.xib | 32 - .../imguiex-ios/Base.lproj/Main.storyboard | 44 - .../imguiex-ios/GameViewController.h | 12 - .../imguiex-ios/GameViewController.m | 472 ---------- .../AppIcon.appiconset/Contents.json | 77 -- .../icon_imgui_60@2x~iphone.png | Bin 3974 -> 0 bytes .../icon_imgui_60@3x~iphone.png | Bin 5953 -> 0 bytes .../icon_imgui_76@2x~ipad.png | Bin 4959 -> 0 bytes .../AppIcon.appiconset/icon_imgui_76~ipad.png | Bin 2576 -> 0 bytes examples/example_apple/imguiex-ios/Info.plist | 49 -- .../imguiex-ios/Shaders/Shader.fsh | 10 - .../imguiex-ios/Shaders/Shader.vsh | 25 - .../example_apple/imguiex-ios/debug_hud.cpp | 73 -- .../example_apple/imguiex-ios/debug_hud.h | 26 - .../imguiex-ios/imgui_ex_icon.png | Bin 12653 -> 0 bytes .../imguiex-ios/imgui_impl_ios.h | 22 - .../imguiex-ios/imgui_impl_ios.mm | 803 ------------------ examples/example_apple/imguiex-ios/main.m | 13 - .../example_apple/imguiex-osx/AppDelegate.h | 15 - .../example_apple/imguiex-osx/AppDelegate.m | 26 - .../AppIcon.appiconset/Contents.json | 64 -- .../AppIcon.appiconset/icon_imgui_180x180.png | Bin 5953 -> 0 bytes .../imguiex-osx/Assets.xcassets/Contents.json | 6 - examples/example_apple/imguiex-osx/Info.plist | 34 - examples/example_apple/imguiex-osx/main.m | 13 - .../imguiex.xcodeproj/project.pbxproj | 544 ------------ 30 files changed, 16 insertions(+), 2483 deletions(-) delete mode 100644 examples/example_apple/README.md delete mode 100644 examples/example_apple/imguiex-ios/AppDelegate.h delete mode 100644 examples/example_apple/imguiex-ios/AppDelegate.m delete mode 100644 examples/example_apple/imguiex-ios/Base.lproj/LaunchScreen.xib delete mode 100644 examples/example_apple/imguiex-ios/Base.lproj/Main.storyboard delete mode 100644 examples/example_apple/imguiex-ios/GameViewController.h delete mode 100644 examples/example_apple/imguiex-ios/GameViewController.m delete mode 100644 examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png delete mode 100644 examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png delete mode 100644 examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png delete mode 100644 examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png delete mode 100644 examples/example_apple/imguiex-ios/Info.plist delete mode 100644 examples/example_apple/imguiex-ios/Shaders/Shader.fsh delete mode 100644 examples/example_apple/imguiex-ios/Shaders/Shader.vsh delete mode 100644 examples/example_apple/imguiex-ios/debug_hud.cpp delete mode 100644 examples/example_apple/imguiex-ios/debug_hud.h delete mode 100644 examples/example_apple/imguiex-ios/imgui_ex_icon.png delete mode 100644 examples/example_apple/imguiex-ios/imgui_impl_ios.h delete mode 100644 examples/example_apple/imguiex-ios/imgui_impl_ios.mm delete mode 100644 examples/example_apple/imguiex-ios/main.m delete mode 100644 examples/example_apple/imguiex-osx/AppDelegate.h delete mode 100644 examples/example_apple/imguiex-osx/AppDelegate.m delete mode 100644 examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/icon_imgui_180x180.png delete mode 100644 examples/example_apple/imguiex-osx/Assets.xcassets/Contents.json delete mode 100644 examples/example_apple/imguiex-osx/Info.plist delete mode 100644 examples/example_apple/imguiex-osx/main.m delete mode 100644 examples/example_apple/imguiex.xcodeproj/project.pbxproj diff --git a/examples/README.txt b/examples/README.txt index 766729d7..5535c8dd 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -90,22 +90,17 @@ Most the example bindings are split in 2 parts: - Road-map: Dear ImGui 1.70 (WIP currently in the "viewport" branch) will allows imgui windows to be seamlessly detached from the main application window. This is achieved using an extra layer to the - platform and renderer bindings, which allows imgui to communicate platform-specific requests such as - "create an additional OS window", "create a render context", "get the OS position of this window" etc. - When using this feature, the coupling with your OS/renderer becomes much tighter than a regular imgui - integration. It is also much more complicated and require more work to integrate correctly. - If you are new to imgui and you are trying to integrate it into your application, first try to ignore - everything related to Viewport and Platform Windows. You'll be able to come back to it later! - Note that if you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit - from improvements and fixes related to viewports and platform windows without extra work on your side. - See 'ImGuiPlatformIO' for details. + platform and renderer bindings, which allows imgui to communicate platform-specific requests. + If you decide to use unmodified imgui_impl_xxxx.cpp files, you will automatically benefit from + improvements and fixes related to viewports and platform windows without extra work on your side. + List of Platforms Bindings in this repository: imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/ imgui_impl_osx.mm ; macOS native API imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org - imgui_impl_win32.cpp ; Windows native API (Windows) + imgui_impl_win32.cpp ; Win32 native API (Windows) imgui_impl_freeglut.cpp ; FreeGLUT (if you really miss the 90's) List of Renderer Bindings in this repository: @@ -168,6 +163,17 @@ example_win32_directx12/ This is quite long and tedious, because: DirectX12. = main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp +example_apple_metal/ + OSX & iOS + Metal. + It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. + Note that instead of the OSX bindings, you may want to use GLFW or SDL which will also support Windows, Linux along with OSX. + = game template + imgui_impl_osx.mm + imgui_impl_metal.mm + +example_apple_opengl2/ + OSX + OpenGL2. + Note that instead of the OSX bindings, you may want to use GLFW or SDL which will also support Windows, Linux along with OSX. + = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp + example_glfw_opengl2/ **DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** **Prefer using OPENGL3 code (with gl3w/glew/glad, you can replace the OpenGL function loader)** @@ -210,22 +216,6 @@ example_sdl_vulkan/ This is quite long and tedious, because: Vulkan. = main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp -example_apple_metal/ - OSX & iOS + Metal. - It is based on the cross-platform game template provided with Xcode as of Xcode 9. - = game template + imgui_impl_osx.mm + imgui_impl_metal.mm - -example_apple_opengl2/ - OSX Cocoa + OpenGL2. - = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp - -example_apple/ - OSX & iOS example + OpenGL2. - THIS EXAMPLE HAS NOT BEEN MAINTAINED PROPERLY AND NEEDS A MAINTAINER. - Consider using the example_glfw_opengl3/ or example_osx_opengl2/ example instead. - On iOS, Using Synergy to access keyboard/mouse data from server computer. - Synergy keyboard integration is rather hacky. - example_allegro5/ Allegro 5 example. = main.cpp + imgui_impl_allegro5.cpp diff --git a/examples/example_apple/README.md b/examples/example_apple/README.md deleted file mode 100644 index c2c8348b..00000000 --- a/examples/example_apple/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# iOS / OSX example - -## Introduction - -THIS EXAMPLE HAS NOT BEEN MAINTAINED PROPERLY AND NEEDS A MAINTAINER. - -This example is the default XCode "OpenGL" example code, modified to support ImGui and [Synergy](http://synergy-project.org/) to share mouse/keyboard on an iOS device. - -It is a rather complex and messy example because of all of the faff required to get an XCode/iOS application running. Refer to the regular OpenGL examples if you want to learn about integrating ImGui. **The code in example_glfw_opengl3/ should also work on OS X and is much simpler.** This is an integration for iOS with Synergy. - -Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use ImGui without it. Synergy includes a "uSynergy" library that allows embedding a synergy client, this is what is used here. ImGui supports "TouchPadding", and this is enabled when Synergy is not active. - -## How to Use on iOS - -* In Synergy, go to Preferences, and uncheck "Use SSL encryption" -* Run the example app. -* Tap the "servername" button in the corner -* Enter the name or the IP of your synergy host -* If you had previously connected to a server, you may need to kill and re-start the app. - -## How to Build on OSX - -* Make sure you have install `brew`, if not, please refer to [Homebrew Website](http://brew.sh) -* Run the command: `brew install glfw3` -* Double click `imguiex.xcodeproj` and select `imguiex-osx` scheme -* Click `Run` button - -## Notes and TODOs - -Things that would be nice but I didn't get around to doing: - -* iOS software keyboard not supported for text inputs -* iOS hardware (bluetooth) keyboards not supported -* Graceful disconnect/reconnect from uSynergy. -* Copy/Paste not well-supported - -## C++ on iOS / OSX - -ImGui is a c++ library. If you want to include it directly, rename your Obj-C file to have the ".mm" extension. - -Alternatively, you can wrap your debug code in a C interface, this is what I am demonstrating here with the "debug_hud.h" interface. Either approach works, use whatever you prefer. - -In my case, most of my game code is already in C++ so it's not really an issue and I can use ImGui directly. diff --git a/examples/example_apple/imguiex-ios/AppDelegate.h b/examples/example_apple/imguiex-ios/AppDelegate.h deleted file mode 100644 index 82f1542e..00000000 --- a/examples/example_apple/imguiex-ios/AppDelegate.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// AppDelegate.h -// imguiex - -#import - -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - - -@end - diff --git a/examples/example_apple/imguiex-ios/AppDelegate.m b/examples/example_apple/imguiex-ios/AppDelegate.m deleted file mode 100644 index ab83101e..00000000 --- a/examples/example_apple/imguiex-ios/AppDelegate.m +++ /dev/null @@ -1,41 +0,0 @@ -// -// AppDelegate.m -// imguiex - -#import "AppDelegate.h" - -@interface AppDelegate () - -@end - -@implementation AppDelegate - - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. -} - -@end diff --git a/examples/example_apple/imguiex-ios/Base.lproj/LaunchScreen.xib b/examples/example_apple/imguiex-ios/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 5717c00e..00000000 --- a/examples/example_apple/imguiex-ios/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/example_apple/imguiex-ios/Base.lproj/Main.storyboard b/examples/example_apple/imguiex-ios/Base.lproj/Main.storyboard deleted file mode 100644 index 90dfb2e6..00000000 --- a/examples/example_apple/imguiex-ios/Base.lproj/Main.storyboard +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/example_apple/imguiex-ios/GameViewController.h b/examples/example_apple/imguiex-ios/GameViewController.h deleted file mode 100644 index 3323cfd5..00000000 --- a/examples/example_apple/imguiex-ios/GameViewController.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// GameViewController.h -// imguiex - -// This is the OpenGL Example template from XCode, modified to support ImGui - -#import -#import - -@interface GameViewController : GLKViewController - -@end diff --git a/examples/example_apple/imguiex-ios/GameViewController.m b/examples/example_apple/imguiex-ios/GameViewController.m deleted file mode 100644 index 83444e98..00000000 --- a/examples/example_apple/imguiex-ios/GameViewController.m +++ /dev/null @@ -1,472 +0,0 @@ -// -// GameViewController.m -// imguiex -// -#import "GameViewController.h" -#import - -#import "imgui_impl_ios.h" -#import "debug_hud.h" - -#define BUFFER_OFFSET(i) ((char *)NULL + (i)) -#define SERVERNAME_KEY @"ServerName" -#define SERVERNAME_ALERT_TAG 10 - -// Uniform index. -enum -{ - UNIFORM_MODELVIEWPROJECTION_MATRIX, - UNIFORM_NORMAL_MATRIX, - UNIFORM_DIFFUSE_COLOR, - UNIFORM_COUNT_ -}; -static GLint uniforms[UNIFORM_COUNT_]; - -// Attribute index. -enum -{ - ATTRIB_VERTEX, - ATTRIB_NORMAL, - ATTRIB_COUNT_ -}; - -static const GLfloat gCubeVertexData[216] = -{ - // Data layout for each line below is: - // pos x/y/z, normal x/y/z, - 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, - 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, - 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, - 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, - - 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, - -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, - -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - - -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, - -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, - -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, - -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, - -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, - -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, - - -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, - 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, - -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, - -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, - 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, - 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, - - 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, - 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, - 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, - - 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, - -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, - 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, - 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, - -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, - -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f -}; - -@interface GameViewController () -{ - GLuint _program; - GLKMatrix4 _modelViewProjectionMatrix; - GLKMatrix3 _normalMatrix; - float _rotation; - GLuint _vertexArray; - GLuint _vertexBuffer; - DebugHUD _hud; -} -@property (strong, nonatomic) EAGLContext* context; -@property (strong, nonatomic) GLKBaseEffect* effect; -@property (strong, nonatomic) ImGuiHelper* imgui; -@property (weak, nonatomic) IBOutlet UIButton* btnServername; -@property (strong, nonatomic) NSString* serverName; - -- (IBAction)onServernameTapped:(id)sender; - -- (void)setupGL; -- (void)tearDownGL; - -- (BOOL)loadShaders; -- (BOOL)compileShader:(GLuint*)shader type:(GLenum)type file:(NSString*)file; -- (BOOL)linkProgram:(GLuint)prog; -- (BOOL)validateProgram:(GLuint)prog; -@end - -@implementation GameViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - - if (!self.context) - NSLog(@"Failed to create ES context"); - - GLKView *view = (GLKView *)self.view; - view.context = self.context; - view.drawableDepthFormat = GLKViewDrawableDepthFormat24; - - [self.btnServername setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; - - [self setupGL]; - - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - self.serverName = [userDefaults objectForKey: SERVERNAME_KEY ]; - self.imgui = [[ImGuiHelper alloc] initWithView:self.view ]; - if (self.serverName) - { - [self.btnServername setTitle:self.serverName forState:UIControlStateNormal]; - [self.imgui connectServer: self.serverName ]; - } - - DebugHUD_InitDefaults(&_hud); -} - -- (void)dealloc -{ - [self tearDownGL]; - - if ([EAGLContext currentContext] == self.context) - [EAGLContext setCurrentContext:nil]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - - if ([self isViewLoaded] && ([[self view] window] == nil)) - { - self.view = nil; - - [self tearDownGL]; - - if ([EAGLContext currentContext] == self.context) - [EAGLContext setCurrentContext:nil]; - self.context = nil; - } - - // Dispose of any resources that can be recreated. -} - - -- (BOOL)prefersStatusBarHidden -{ - return YES; -} - -- (IBAction)onServernameTapped:(id)sender -{ - UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Set Server" message:@"Enter server name or IP for uSynergy" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil ]; - alert.alertViewStyle = UIAlertViewStylePlainTextInput; - alert.tag = SERVERNAME_ALERT_TAG; // cheezy way to tell which alert view we're responding to - [alert show]; -} - -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex -{ - if ((buttonIndex==0) && (alertView.tag == SERVERNAME_ALERT_TAG)) - { - // This is really janky. I usually just hardcode the servername since I'm building it anyway. - // If you want to properly handle updating the server, you'll want to tear down and recreate - // the usynergy stuff in connectServer - BOOL serverNameWasSet = self.serverName.length > 0; - NSString *serverName = [[alertView textFieldAtIndex:0] text]; - - if ([serverName length] > 0) - { - self.serverName = serverName; - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - [userDefaults setObject:serverName forKey:SERVERNAME_KEY ]; - [userDefaults synchronize]; - - [self.btnServername setTitle:self.serverName forState:UIControlStateNormal]; - - // If we hadn't previously connected, try now - if (!serverNameWasSet) - { - [self.imgui connectServer:self.serverName]; - } - else - { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Servername Updated" - message:@"Restart the app to connect the server" - delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; - [alert show]; - } - } - } -} - -- (void)setupGL -{ - [EAGLContext setCurrentContext:self.context]; - - [self loadShaders]; - - self.effect = [[GLKBaseEffect alloc] init]; - self.effect.light0.enabled = GL_TRUE; - self.effect.light0.diffuseColor = GLKVector4Make(1.0f, 0.4f, 0.4f, 1.0f); - - glEnable(GL_DEPTH_TEST); - - glGenVertexArraysOES(1, &_vertexArray); - glBindVertexArrayOES(_vertexArray); - - glGenBuffers(1, &_vertexBuffer); - glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW); - - glEnableVertexAttribArray(GLKVertexAttribPosition); - glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0)); - glEnableVertexAttribArray(GLKVertexAttribNormal); - glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12)); - - glBindVertexArrayOES(0); -} - -- (void)tearDownGL -{ - [EAGLContext setCurrentContext:self.context]; - - glDeleteBuffers(1, &_vertexBuffer); - glDeleteVertexArraysOES(1, &_vertexArray); - - self.effect = nil; - - if (_program) - { - glDeleteProgram(_program); - _program = 0; - } -} - -#pragma mark - GLKView and GLKViewController delegate methods - -- (void)update -{ - float aspect = fabs(self.view.bounds.size.width / self.view.bounds.size.height); - GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f); - - self.effect.transform.projectionMatrix = projectionMatrix; - - GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f); - baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, _rotation, 0.0f, 1.0f, 0.0f); - - // Compute the model view matrix for the object rendered with GLKit - GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -1.5f); - modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f); - modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); - - self.effect.transform.modelviewMatrix = modelViewMatrix; - - // Compute the model view matrix for the object rendered with ES2 - modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f); - modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f); - modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); - - _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL); - _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix); - _rotation += self.timeSinceLastUpdate * (_hud.rotation_speed * (M_PI / 180.0)); -} - - -- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect -{ - // Start the dear imgui frame - [self.imgui newFrame]; - - // Create some UI elements - DebugHUD_DoInterface( &_hud ); - - // Render - glClearColor(0.65f, 0.65f, 0.65f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glBindVertexArrayOES(_vertexArray); - - // Render the object with GLKit - [self.effect prepareToDraw]; - glDrawArrays(GL_TRIANGLES, 0, 36); - - // Render the object again with ES2 - glUseProgram(_program); - glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, _modelViewProjectionMatrix.m); - glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, _normalMatrix.m); - glUniform3f(uniforms[UNIFORM_DIFFUSE_COLOR], _hud.cubeColor1[0], _hud.cubeColor1[1], _hud.cubeColor1[2] ); - glDrawArrays(GL_TRIANGLES, 0, 36); - - self.effect.light0.diffuseColor = GLKVector4Make( _hud.cubeColor2[0], _hud.cubeColor2[1], _hud.cubeColor2[2], 1.0f); - - // Render dear imgui as the last thing in the frame if possible - [self.imgui render]; -} - -#pragma mark - OpenGL ES 2 shader compilation - -- (BOOL)loadShaders -{ - GLuint vertShader, fragShader; - NSString *vertShaderPathname, *fragShaderPathname; - - // Create shader program. - _program = glCreateProgram(); - - // Create and compile vertex shader. - vertShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"vsh"]; - if (![self compileShader:&vertShader type:GL_VERTEX_SHADER file:vertShaderPathname]) { - NSLog(@"Failed to compile vertex shader"); - return NO; - } - - // Create and compile fragment shader. - fragShaderPathname = [[NSBundle mainBundle] pathForResource:@"Shader" ofType:@"fsh"]; - if (![self compileShader:&fragShader type:GL_FRAGMENT_SHADER file:fragShaderPathname]) { - NSLog(@"Failed to compile fragment shader"); - return NO; - } - - // Attach vertex shader to program. - glAttachShader(_program, vertShader); - - // Attach fragment shader to program. - glAttachShader(_program, fragShader); - - // Bind attribute locations. - // This needs to be done prior to linking. - glBindAttribLocation(_program, GLKVertexAttribPosition, "position"); - glBindAttribLocation(_program, GLKVertexAttribNormal, "normal"); - - // Link program. - if (![self linkProgram:_program]) - { - NSLog(@"Failed to link program: %d", _program); - - if (vertShader) { - glDeleteShader(vertShader); - vertShader = 0; - } - if (fragShader) { - glDeleteShader(fragShader); - fragShader = 0; - } - if (_program) { - glDeleteProgram(_program); - _program = 0; - } - - return NO; - } - - // Get uniform locations. - uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX] = glGetUniformLocation(_program, "modelViewProjectionMatrix"); - uniforms[UNIFORM_NORMAL_MATRIX] = glGetUniformLocation(_program, "normalMatrix"); - uniforms[UNIFORM_DIFFUSE_COLOR] = glGetUniformLocation(_program, "diffuseColor"); - - // Release vertex and fragment shaders. - if (vertShader) - { - glDetachShader(_program, vertShader); - glDeleteShader(vertShader); - } - if (fragShader) - { - glDetachShader(_program, fragShader); - glDeleteShader(fragShader); - } - - return YES; -} - -- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file -{ - GLint status; - const GLchar *source; - - source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String]; - if (!source) - { - NSLog(@"Failed to load vertex shader"); - return NO; - } - - *shader = glCreateShader(type); - glShaderSource(*shader, 1, &source, NULL); - glCompileShader(*shader); - -#if defined(DEBUG) - GLint logLength; - glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength); - if (logLength > 0) { - GLchar *log = (GLchar *)malloc(logLength); - glGetShaderInfoLog(*shader, logLength, &logLength, log); - NSLog(@"Shader compile log:\n%s", log); - free(log); - } -#endif - - glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); - if (status == 0) - { - glDeleteShader(*shader); - return NO; - } - - return YES; -} - -- (BOOL)linkProgram:(GLuint)prog -{ - GLint status; - glLinkProgram(prog); - -#if defined(DEBUG) - GLint logLength; - glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength); - if (logLength > 0) - { - GLchar *log = (GLchar *)malloc(logLength); - glGetProgramInfoLog(prog, logLength, &logLength, log); - NSLog(@"Program link log:\n%s", log); - free(log); - } -#endif - - glGetProgramiv(prog, GL_LINK_STATUS, &status); - if (status == 0) - return NO; - return YES; -} - -- (BOOL)validateProgram:(GLuint)prog -{ - GLint logLength, status; - - glValidateProgram(prog); - glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength); - if (logLength > 0) { - GLchar *log = (GLchar *)malloc(logLength); - glGetProgramInfoLog(prog, logLength, &logLength, log); - NSLog(@"Program validate log:\n%s", log); - free(log); - } - - glGetProgramiv(prog, GL_VALIDATE_STATUS, &status); - if (status == 0) - return NO; - return YES; -} - -@end diff --git a/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json b/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 06b60d8b..00000000 --- a/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon_imgui_60@2x~iphone.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon_imgui_60@3x~iphone.png", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "icon_imgui_76~ipad.png", - "scale" : "1x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "icon_imgui_76@2x~ipad.png", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png b/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@2x~iphone.png deleted file mode 100644 index d728bc3fe627b885d0c9df2ce95ddd9bc89ee419..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3974 zcmV;14|(v3P)#-701_q?R~1MyQ{|Q3 zR_|`S{MvVD1O@;i9o!OW@p=q=>Dd55Nkn3y8I)7p0L$8;{h8Cx*Xs*WG7xAKs_LAJG2Fa;xu15%TG#%NmV3SIo8S2Ir$6zu zs4|20p-M#h`nS%nU%S(&C#pJqnpID%e6&$t2r&itAs(Vc=aQ2rR^PdGd0@F>(J{t9 zUcB<^E1#lK{OiiitJ7*3BB9khw$M5rBm?-7nIy(AS6|5M_|EP-juR!VEOm%TtJ%14 z@!xO#{cTYVA?lDAg^1obx0Ypr88nq(apB}x0b5j#ESz9hSgttU0a4^9=hqluW)!HB zbNs)zH!uD9TC>?Gq)!>DlK5Jqv7jO#9R8mou^ zi8^*59xJP<5{TG&B_dQUI*PPfjf-pR>sN0xBLpF$U;p;4jm>wH#H-SjqB-ODds-9_ zOsEBCAnk`ApIaj$=Qz)NzxvJJ@>(S_rJ5B$h^cC%aR7*lUXci@)r&3`b+dlq;+4Uo ze)GaVuV3G2G>TL=odBF=y)^3qW2xX6vtEA>V5%tIm0`!-ZhHQwmx$3vOA4pXc_ zxN-X*{eBzZ364pb(e0(*|KXd3<>?0;Lb|bay|9Kyl>&7x+1kC)>%9lKCozxqo~g_f zPn6nw+jlpv0StCZdO)}40ANnGc5dw4zsWq_q|`mL`VtvLfXf$YxBp(F)~eO!_Sb~M zugk9x)6LEQ?%uyuSS~S+Xmg#Wod@l$H0u(ffQzgZ`n~r32Y2%F((S#=?5V`~o1pnicK6FMUi509DuMA!JmydohiJF&m;yv|*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*CD@SnG6VG-3^EMi&W6J$C9e97aJTqXPX00|P@tvXwqQ;aj)b z+S(+h2|?Tz78b>&XBwKCVxvFgxw^tVRFc@FWLQ7NnvKAhBor0oWTXERW@H_Rj_T>_ z18Tqs!6t)_H4+rX#3clcnq^pc;Zo(Qx84d5-Aekx;?GNwp19NK$cB!)cWdf?LVdp3 z*o0z}lo03S=olwR!7w11DfV!_t^O`-ONb4Z+dnV>d|nu6QXJIk-QnTOy*&3PCXsVe z#w?)ID1}P(uU}h{xj$a7%gHamlA0tA*zK3*78o5L6YY)$P9y=_!nY}`hZGnCw+Tez zT#5Lz<3&)CD#<|F!WW}Xoy2;w9u$0X?DXl3v{YQCh^44w6NknnQoiEC#ZyH`QQTgc zJ$t3MH#iCe$YHa`Q}aYAFnD8gGZGHe0aIR-ItXpCIqU__^Fg>hy}cmQ@fHAgG_*}E zx6hVW6ciSr^01gJl6nxtegZm>Lq|RZ+=qCqs# gAev~RK{V000Rc@npWJ{1ApigX07*qoM6N<$g2?NtdjJ3c diff --git a/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png b/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_60@3x~iphone.png deleted file mode 100644 index f48b799dba2cf05b31924886eb4fc9d803ea4a83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5953 zcmY+IbyO5U*Z&s~mXK~(kX*V!I+q0mrE_VJP`W#$L0CGL7U`7k5Trv8SxP}*k?!u- z=Q;0r&+qrg+_`7YoSE;P`#Dpwn(E5IX1b9acHVLf|;1`5Ce<3HOTNdq-6m0#X-tG_jZ zCXx1+H@A5Eh_t1$Snf`Sa#+jbR*MW=oQ%ePzPMemdpGE{`ukxHC@`MH8o^yN@$!hL zxIJpKDO#U^f%ElC`W*Yf{FvD$rs<9?i9vKf5?Kltb0IMJ6l)WBbSq1}KgvHK?SA}G zCpGaSQw4Pz{hoXnwv{9I;?~GooqZjX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ed$_x7*#?8gaGa+{UfqldMkWRZC-oC;KHr`fl>kRgQmvuRQKLEwu{1MsJ zfUBev`FLpUI z{A4(4*aM*!xmP1)W(IA|Y_JK7nD>VGVpj;uvWg^FE7IGtloVfI^Y&!8VuTa1TK0(d z6B3@x-Rr7T^IGfMme|Epm3s>O`l;m$o9nux7AW2s zn&k^yj3fJ;mPa{!-Mg7wi{v7JUw?BOHl#f#bz@2dF-tUdkYHe%*pwBdmevRbbO_>RasM#?)D@zhfaJu+MB9SJ5F9CXiBTGnWlP%rz9!4 z+7+}n|Bb~EeY-jMdj>4yAr!4zKtQ}5CQ5^_(9#mPpl`Tk(t#u1o?3iFIj{%h0Fib@Zh9f` zHM8T0+Vdz*>`$W831QS_k%v&LxKkMu+%PG0Qj$~T4%)$UbNcYgx~A2~UaQ#=W!W{! z=pMgKQj_<_=2p_HVtE;Dtt1fai}f#-z}pn<3jR+;w%$^CLCBGe66{p|9k_C2p%r-n z*OBrxH)o05gU|$cFe}pRpmjfFU4eMQv6xQVmG1N@R7?)UKtKeH!T5%@4sZkf*Z%*F aW)oPOXB1N~w0~dYfLBm;#aac6u>S!7Vo}-v diff --git a/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png b/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76@2x~ipad.png deleted file mode 100644 index 67b08b84c6c5ceb4982bd6f278c46138b73c20b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4959 zcmV-l6QJygP)0ssI2m!P+H000vvNklF8rH#l-*!w1?iM_u>P^Q!ES+sYphofOF0RP$kt6!bdMMSV<4FNCP4nz}3m) z`A4N(^S%Tyk>(b=X{*)R-feECX^Yttfri!@rA8Vep;kR{;`phF$`lbuRf|u6h>$~s zEbDC7S2wqof@BOwqz539nd#$E5vB1%Rp(|td;HiVcXRn)f7C;jh`|ik?(D9tUCUR; zUP(tPQbb#=4iWlR2V%y=L}?5)F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yRfOr;Q) zdFRgmYh^TPI4n4jEx;1&IX{yi40`tbg<~hv^>uYI5YCQn7>G@gdFSrktei6ym6ZgF z0N(TCP4>mTwr<~HYSLxA!zTnHk}1DEX1o4=;}0-K2nr|`G7{>+T;y^}60}d-y$35O zpr{$`TgCo?j?UY{hSA5|xL%mtT*E~IQWHtt06vMf4=sA?=nC9%Q?#(DB29-R6$D}L=d zh`KQ`D)cAI7l-xg(cR6SOo_=b_w|iAZ zkqZ=Cz5P(@(78)vb=l=wVIe3|*8z!=-}U6==H}*~!ziq2{H9Q6(hf5v5#pc)0AOFN z%q;0o-GAZu^*-G&C5SWoq`uCmnoEZ|G9IAIRh=$>D)XB1_o-u)^Zf@ zS5)FseEU+Ul^(IHsYwSzLt&7q++twK@tSo>A;qeWqGJ8UdNK9A>T;Bf$hpx}=oyq^ z-=llCNls3Q>yu=RY(%0KGd$L~a;;FH)|XYaG6$ej6b9n|YwwP65QL!s41;PZhBJ7gPj@#Y~FOC2J002ovPDHLkV1i~^jllo_ diff --git a/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png b/examples/example_apple/imguiex-ios/Images.xcassets/AppIcon.appiconset/icon_imgui_76~ipad.png deleted file mode 100644 index ae88e04d9c50882bb5636c6514ef03ba7214e3d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2576 zcmV+r3h(uaP)5w)ZN`N+nG%XDQ%wY`F2R5=~-FkYv{p;I0kiXvavdK5I0q zojtzae&2rIYW2*G9`{N{iU^m%5lSePDOEml9M22!>I~X3fY{NX5RAZt#z&)Zxowa# zk#stv$=D6=l#*yP7z{NL661ML&|857O*kTPty+tMDDt<36I71uUUqw~DCnUTTk%LV zSbx1T5NPa}^TzH9LY+?hO0FYeIDo;d9#6pS@ryzyb8;|OPPg6;doLIhYz&9v@Dfm{ zsXOcQH!w~OkPulW8`qT;$kLU6SNfNs1@ zVwbP}BNmgGo^6G{VXYwWp>TB9J4cue0gS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e)Ilbr_;&evn0io z>>y$;#o_&fONtTRV9e^8+IRQ7@3h-t8RqB9UtGF*E1Z)oTJYS@)~t2A8!;&emCeHW z1HqyP3Lh*kTKe)&VQTP0+nZYwdcal2j2gLi!$!6l5c-;YzUtaKtJS*V)itOz8I7B^ zY#lLdDBNl1?%gm*^QT2nHkpiwv9GN9`LZ7`Zg9IdZrKWtg2rqK*s!2w?-q;Y@X=#f z3#Z+&Zo_7KwoOt-W02+h4 z!I$i|Y|Mpn;;c?6!Cr07!@81Q`OK^#(m5 zHyDJ*F?j@Gug?#SR6#OM3`g5JENT!6Bej1|t!Dg0zm6aFq?A`g+b_)`Tq3397N2)b mUu3D2G-Mhw4Vi{aL;f4Eji$yBE*?7o0000`q-%e diff --git a/examples/example_apple/imguiex-ios/Info.plist b/examples/example_apple/imguiex-ios/Info.plist deleted file mode 100644 index bc6f548c..00000000 --- a/examples/example_apple/imguiex-ios/Info.plist +++ /dev/null @@ -1,49 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - org.imgui.example.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UIStatusBarHidden - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/examples/example_apple/imguiex-ios/Shaders/Shader.fsh b/examples/example_apple/imguiex-ios/Shaders/Shader.fsh deleted file mode 100644 index 4000524f..00000000 --- a/examples/example_apple/imguiex-ios/Shaders/Shader.fsh +++ /dev/null @@ -1,10 +0,0 @@ -// -// Shader.fsh -// imguiex - -varying lowp vec4 colorVarying; - -void main() -{ - gl_FragColor = colorVarying; -} diff --git a/examples/example_apple/imguiex-ios/Shaders/Shader.vsh b/examples/example_apple/imguiex-ios/Shaders/Shader.vsh deleted file mode 100644 index 313c3d7a..00000000 --- a/examples/example_apple/imguiex-ios/Shaders/Shader.vsh +++ /dev/null @@ -1,25 +0,0 @@ -// -// Shader.vsh -// imguiex - -attribute vec4 position; -attribute vec3 normal; - -varying lowp vec4 colorVarying; - -uniform vec3 diffuseColor; -uniform mat4 modelViewProjectionMatrix; -uniform mat3 normalMatrix; - -void main() -{ - vec3 eyeNormal = normalize(normalMatrix * normal); - vec3 lightPosition = vec3(0.0, 0.0, 1.0); - - float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition))); - - vec3 colorLit = diffuseColor * nDotVP; - colorVarying = vec4( colorLit.x, colorLit.y, colorLit.z, 1.0 ); - - gl_Position = modelViewProjectionMatrix * position; -} diff --git a/examples/example_apple/imguiex-ios/debug_hud.cpp b/examples/example_apple/imguiex-ios/debug_hud.cpp deleted file mode 100644 index 28722b56..00000000 --- a/examples/example_apple/imguiex-ios/debug_hud.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// debug_hud.cpp -// imguiex - -#include - -#include "debug_hud.h" -#include "imgui.h" - -void DebugHUD_InitDefaults( DebugHUD *hud ) -{ - hud->show_demo_window = true; - hud->show_another_window = true; - hud->rotation_speed = 15.0f; - - hud->cubeColor1[0] = 0.4f; - hud->cubeColor1[1] = 0.4f; - hud->cubeColor1[2] = 1.0f; - hud->cubeColor1[3] = 1.0f; - - hud->cubeColor2[0] = 1.0f; - hud->cubeColor2[1] = 0.4f; - hud->cubeColor2[2] = 0.4f; - hud->cubeColor2[3] = 1.0f; - - hud->clearColor[0] = 0.45f; - hud->clearColor[1] = 0.55f; - hud->clearColor[2] = 0.60f; - hud->clearColor[3] = 1.00f; -} - -void DebugHUD_DoInterface(DebugHUD *hud) -{ - // 1. Show a simple window. - // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug". - { - static float f = 0.0f; - static int counter = 0; - ImGui::Text("Hello, world!"); // Display some text (you can use a format string too) - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", hud->clearColor); // Edit 3 floats representing a color - - ImGui::Checkbox("Demo Window", &hud->show_demo_window); // Edit bools storing our windows open/close state - ImGui::Checkbox("Another Window", &hud->show_another_window); - - if (ImGui::Button("Button")) // Buttons return true when clicked (NB: 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); - } - - // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows. - if (hud->show_another_window) - { - ImGui::Begin("Another Window", &hud->show_another_window); - ImGui::Text("Hello from another window!"); - ImGui::ColorEdit3("Cube 1 Color", hud->cubeColor1); - ImGui::ColorEdit3("Cube 2 Color", hud->cubeColor2); - ImGui::SliderFloat("Rotation Speed", &hud->rotation_speed, 0.0f, 200.0f); - if (ImGui::Button("Close Me")) - hud->show_another_window = false; - ImGui::End(); - } - - // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui! - if (hud->show_demo_window) - { - ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly! - ImGui::ShowDemoWindow(&hud->show_demo_window); - } -} diff --git a/examples/example_apple/imguiex-ios/debug_hud.h b/examples/example_apple/imguiex-ios/debug_hud.h deleted file mode 100644 index 0a905911..00000000 --- a/examples/example_apple/imguiex-ios/debug_hud.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// debug_hud.h -// imguiex - -#pragma once - -typedef struct DebugHUD -{ - bool show_demo_window; - bool show_another_window; - float rotation_speed; - float cubeColor1[4]; - float cubeColor2[4]; - float clearColor[4]; -} DebugHUD; - -#if __cplusplus -extern "C" { -#endif - -void DebugHUD_InitDefaults(DebugHUD *hud); -void DebugHUD_DoInterface(DebugHUD *hud); - -#if __cplusplus -} -#endif diff --git a/examples/example_apple/imguiex-ios/imgui_ex_icon.png b/examples/example_apple/imguiex-ios/imgui_ex_icon.png deleted file mode 100644 index 820e4d73e3bdb406ce26f87d09a0a38018e3bbf4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12653 zcmch7bx>SS*XA7<+zEl;B)Ge~dw>LjGe8JIf)1{O6P(~K!94^>aCdiihu{``=lAaZ zu~qwiTi@1OwYTb4ceUI;_vzDpo<4oPs=t-TLMK57002u-LFOF*Ai%Q-0O~)9Cy8`9 z0C4gs%1COu8U0z-g%a$(>|N(x7G)i_kPIWlWh_xJ*#5KHq5Xt=i&}rCeX7NFPVDFx zD~pTzMTH601va?15D%Eb|-E3!fz zrroReEZYHXNukv6!O{e0r{}YVuSpoCN!oE9OdXz!s@}7ZD^0=2HhyKUy(^)1<34B= zw`0E?7x1v7VX}B5ia>=AR4qU&?!DA*Vl4G0yfSwwwxA)m!yL0ga5?w>>>VC9o9Wio zBpwPi-rJ$~Hl`z5@B&q3bvYN}!s4fypXN=x8p|Q&NEXCki9$%*m+4+W4{ zUPp=ZSlwLy{*5BWS&)GBnwO?2>fg(KM^2TsxSnKO+ zR{ii@F_^;N&J*AJG>GB1QxSc=`(=6Gcq<_N`rw!>W^Q6*aQi{SB#9mtV_1KuF2yUv z$2tupUyeP0AH;_)`145tfnRK&wl^kH1I?_3#m}yw#jjv~ErY=(bjAv`|5TsEsnOHW z_>yFti$Iu=IX2(-{-N3NC$R|uQ0IsKgl{LL*BGq-7I~WX*Tghlh<@vq2p)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+c< z3gzl(Yb{S*I&OFV9O)Rv^~UI%6&Fes$+oSx&g1j5iooFK!AL3}%+RjAeG-)+zBC7@ zt04E)V_fz9kx}JBsW_q12U5eCjmLG=sbMdl)Pf8bVX-Wt@Z*u=<<5^_mUd!5{kF8U z^UUPTs4Lc)?4XMh`=I&`1CVHn5fBt3{&V!%-IlV}2m}}yl2fWq>|eT;ijM#W1OZke zW;LIdw1KBW>_07A@g#WzPFzSY?T0~H8q`|pQc{U`BR@Q|_pu=^ -#include - -@interface ImGuiHelper : NSObject - -- (id) initWithView: (UIView *)view; - -- (void)connectServer: (NSString*)serverName; - -- (void)render; -- (void)newFrame; - -@end diff --git a/examples/example_apple/imguiex-ios/imgui_impl_ios.mm b/examples/example_apple/imguiex-ios/imgui_impl_ios.mm deleted file mode 100644 index df2df27c..00000000 --- a/examples/example_apple/imguiex-ios/imgui_impl_ios.mm +++ /dev/null @@ -1,803 +0,0 @@ -// ImGui iOS+OpenGL+Synergy binding -// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp. -// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much. -// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application. - -// TODO: -// - Clipboard is not supported. - -#import -#import - -#include -#include -#include -#include - -#include "imgui_impl_ios.h" -#include "imgui.h" - -#include "uSynergy.h" - -// From Carbon HIToolbox/Events.h -// FIXME: Keyboard mapping is hacked in because Synergy doesn't give us character but only keycode which aren't really portable if you consider keyboard locale. See https://github.com/ocornut/imgui/pull/247 -enum { - kVK_ANSI_A = 0x00, - kVK_ANSI_S = 0x01, - kVK_ANSI_D = 0x02, - kVK_ANSI_F = 0x03, - kVK_ANSI_H = 0x04, - kVK_ANSI_G = 0x05, - kVK_ANSI_Z = 0x06, - kVK_ANSI_X = 0x07, - kVK_ANSI_C = 0x08, - kVK_ANSI_V = 0x09, - kVK_ANSI_B = 0x0B, - kVK_ANSI_Q = 0x0C, - kVK_ANSI_W = 0x0D, - kVK_ANSI_E = 0x0E, - kVK_ANSI_R = 0x0F, - kVK_ANSI_Y = 0x10, - kVK_ANSI_T = 0x11, - kVK_ANSI_1 = 0x12, - kVK_ANSI_2 = 0x13, - kVK_ANSI_3 = 0x14, - kVK_ANSI_4 = 0x15, - kVK_ANSI_6 = 0x16, - kVK_ANSI_5 = 0x17, - kVK_ANSI_Equal = 0x18, - kVK_ANSI_9 = 0x19, - kVK_ANSI_7 = 0x1A, - kVK_ANSI_Minus = 0x1B, - kVK_ANSI_8 = 0x1C, - kVK_ANSI_0 = 0x1D, - kVK_ANSI_RightBracket = 0x1E, - kVK_ANSI_O = 0x1F, - kVK_ANSI_U = 0x20, - kVK_ANSI_LeftBracket = 0x21, - kVK_ANSI_I = 0x22, - kVK_ANSI_P = 0x23, - kVK_ANSI_L = 0x25, - kVK_ANSI_J = 0x26, - kVK_ANSI_Quote = 0x27, - kVK_ANSI_K = 0x28, - kVK_ANSI_Semicolon = 0x29, - kVK_ANSI_Backslash = 0x2A, - kVK_ANSI_Comma = 0x2B, - kVK_ANSI_Slash = 0x2C, - kVK_ANSI_N = 0x2D, - kVK_ANSI_M = 0x2E, - kVK_ANSI_Period = 0x2F, - kVK_ANSI_Grave = 0x32, - kVK_ANSI_KeypadDecimal = 0x41, - kVK_ANSI_KeypadMultiply = 0x43, - kVK_ANSI_KeypadPlus = 0x45, - kVK_ANSI_KeypadClear = 0x47, - kVK_ANSI_KeypadDivide = 0x4B, - kVK_ANSI_KeypadEnter = 0x4C, - kVK_ANSI_KeypadMinus = 0x4E, - kVK_ANSI_KeypadEquals = 0x51, - kVK_ANSI_Keypad0 = 0x52, - kVK_ANSI_Keypad1 = 0x53, - kVK_ANSI_Keypad2 = 0x54, - kVK_ANSI_Keypad3 = 0x55, - kVK_ANSI_Keypad4 = 0x56, - kVK_ANSI_Keypad5 = 0x57, - kVK_ANSI_Keypad6 = 0x58, - kVK_ANSI_Keypad7 = 0x59, - kVK_ANSI_Keypad8 = 0x5B, - kVK_ANSI_Keypad9 = 0x5C -}; - -/* keycodes for keys that are independent of keyboard layout*/ -enum { - kVK_Return = 0x24, - kVK_Tab = 0x30, - kVK_Space = 0x31, - kVK_Delete = 0x33, - kVK_Escape = 0x35, - kVK_Command = 0x37, - kVK_Shift = 0x38, - kVK_CapsLock = 0x39, - kVK_Option = 0x3A, - kVK_Control = 0x3B, - kVK_RightShift = 0x3C, - kVK_RightOption = 0x3D, - kVK_RightControl = 0x3E, - kVK_Function = 0x3F, - kVK_F17 = 0x40, - kVK_VolumeUp = 0x48, - kVK_VolumeDown = 0x49, - kVK_Mute = 0x4A, - kVK_F18 = 0x4F, - kVK_F19 = 0x50, - kVK_F20 = 0x5A, - kVK_F5 = 0x60, - kVK_F6 = 0x61, - kVK_F7 = 0x62, - kVK_F3 = 0x63, - kVK_F8 = 0x64, - kVK_F9 = 0x65, - kVK_F11 = 0x67, - kVK_F13 = 0x69, - kVK_F16 = 0x6A, - kVK_F14 = 0x6B, - kVK_F10 = 0x6D, - kVK_F12 = 0x6F, - kVK_F15 = 0x71, - kVK_Help = 0x72, - kVK_Home = 0x73, - kVK_PageUp = 0x74, - kVK_ForwardDelete = 0x75, - kVK_F4 = 0x76, - kVK_End = 0x77, - kVK_F2 = 0x78, - kVK_PageDown = 0x79, - kVK_F1 = 0x7A, - kVK_LeftArrow = 0x7B, - kVK_RightArrow = 0x7C, - kVK_DownArrow = 0x7D, - kVK_UpArrow = 0x7E -}; - -static char g_keycodeCharUnshifted[256] = {}; -static char g_keycodeCharShifted[256] = {}; - -//static double g_Time = 0.0f; -static bool g_MousePressed[3] = { false, false, false }; -static float g_mouseWheelX = 0.0f; -static float g_mouseWheelY = 0.0f; - -static GLuint g_FontTexture = 0; -static int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0; -static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; -static int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0; -static size_t g_VboSize = 0; -static unsigned int g_VboHandle = 0, g_VaoHandle = 0; -static float g_displayScale; - -static int usynergy_sockfd; -static bool g_synergyPtrActive = false; -static uint16_t g_mousePosX = 0; -static uint16_t g_mousePosY = 0; - -static void ImGui_ImplIOS_RenderDrawLists (ImDrawData *draw_data); -bool ImGui_ImplIOS_CreateDeviceObjects(); - -static NSString *g_serverName; - -uSynergyBool ImGui_ConnectFunc(uSynergyCookie cookie) -{ - // NOTE: You need to turn off "Use SSL Encryption" in Synergy preferences, since - // uSynergy does not support SSL. - - NSLog( @"Connect Func!"); - struct addrinfo hints, *res; - - // first, load up address structs with getaddrinfo(): - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever - hints.ai_socktype = SOCK_STREAM; - - // get server address - getaddrinfo([g_serverName UTF8String], "24800", &hints, &res); - - if (!res) - { - NSLog( @"Could not find server: %@", g_serverName ); - return USYNERGY_FALSE; - } - - // make a socket: - usynergy_sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - - // connect it to the address and port we passed in to getaddrinfo(): - int ret = connect(usynergy_sockfd, res->ai_addr, res->ai_addrlen); - if (!ret) { - NSLog( @"Connect succeeded..."); - } else { - NSLog( @"Connect failed, %d", ret ); - } - - - return USYNERGY_TRUE; -} - -uSynergyBool ImGui_SendFunc(uSynergyCookie cookie, const uint8_t *buffer, int length) -{ -// NSLog( @"Send Func" ); - send( usynergy_sockfd, buffer, length, 0 ); - - return USYNERGY_TRUE; -} - -uSynergyBool ImGui_RecvFunc(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength) -{ - *outLength = (int)recv( usynergy_sockfd, buffer, maxLength, 0 ); - - return USYNERGY_TRUE; -} - -void ImGui_SleepFunc(uSynergyCookie cookie, int timeMs) -{ - usleep( timeMs * 1000 ); -} - -uint32_t ImGui_GetTimeFunc() -{ - struct timeval tv; - gettimeofday(&tv, NULL); - - return (int32_t)((tv.tv_sec) * 1000 + (tv.tv_usec) / 1000); -} - -void ImGui_TraceFunc(uSynergyCookie cookie, const char *text) -{ - puts(text); -} - -void ImGui_ScreenActiveCallback(uSynergyCookie cookie, uSynergyBool active) -{ - g_synergyPtrActive = active; -// printf( "Synergy: screen activate %s\n", active?"YES":"NO" ); -} - -void ImGui_MouseCallback(uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, - uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle) -{ -// printf("Synergy: mouse callback %d %d -- wheel %d %d\n", x, y, wheelX, wheelY ); - uSynergyContext *ctx = (uSynergyContext*)cookie; - g_mousePosX = x; - g_mousePosY = y; - g_mouseWheelX = wheelX; - g_mouseWheelY = wheelY; - g_MousePressed[0] = buttonLeft; - g_MousePressed[1] = buttonMiddle; - g_MousePressed[2] = buttonRight; - - ctx->m_mouseWheelX = 0; - ctx->m_mouseWheelY = 0; -} - -void ImGui_KeyboardCallback(uSynergyCookie cookie, uint16_t key, - uint16_t modifiers, uSynergyBool down, uSynergyBool repeat) -{ - int scanCode = key-1; - // printf("Synergy: keyboard callback: 0x%02X (%s)", scanCode, down?"true":"false"); - ImGuiIO& io = ImGui::GetIO(); - io.KeysDown[key] = down; - io.KeyShift = (modifiers & USYNERGY_MODIFIER_SHIFT); - io.KeyCtrl = (modifiers & USYNERGY_MODIFIER_CTRL); - io.KeyAlt = (modifiers & USYNERGY_MODIFIER_ALT); - io.KeySuper = (modifiers & USYNERGY_MODIFIER_WIN); - - // Add this as keyboard input - if ((down) && (key) && (scanCode<256) && !(modifiers & USYNERGY_MODIFIER_CTRL)) - { - // If this key maps to a character input, apply it - int charForKeycode = (modifiers & USYNERGY_MODIFIER_SHIFT) ? g_keycodeCharShifted[scanCode] : g_keycodeCharUnshifted[scanCode]; - io.AddInputCharacter((unsigned short)charForKeycode); - } -} - -void ImGui_JoystickCallback(uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY) -{ - printf("Synergy: joystick callback TODO\n"); -} - -void ImGui_ClipboardCallback(uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size) -{ - printf("Synergy: clipboard callback TODO\n" ); -} - -@interface ImGuiHelper () -{ - BOOL _mouseDown; - BOOL _mouseTapped; - CGPoint _touchPos; - - uSynergyContext _synergyCtx; - dispatch_queue_t _synergyQueue; -} -@property (nonatomic, weak) UIView *view; -@property (nonatomic, strong) NSString *serverName; - -@end - -@implementation ImGuiHelper - -- (id) initWithView: (UIView *)view -{ - self = [super init]; - if (self) - { - self.view = view; - - [self setupImGuiHooks]; - } - return self; -} - -- (void)setupKeymaps -{ - // The keyboard mapping is a big headache. I tried for a while to find a better way to do this, - // but this was the best I could come up with. There are some device independent API's available - // to convert scan codes to unicode characters, but these are only available on mac and not - // on iOS as far as I can tell (it's part of Carbon). I didn't see any better way to do - // this or any way to get the character codes out of usynergy. - g_keycodeCharUnshifted[ kVK_ANSI_A ]='a'; - g_keycodeCharUnshifted[ kVK_ANSI_S ]='s'; - g_keycodeCharUnshifted[ kVK_ANSI_D ]='d'; - g_keycodeCharUnshifted[ kVK_ANSI_F ]='f'; - g_keycodeCharUnshifted[ kVK_ANSI_H ]='h'; - g_keycodeCharUnshifted[ kVK_ANSI_G ]='g'; - g_keycodeCharUnshifted[ kVK_ANSI_Z ]='z'; - g_keycodeCharUnshifted[ kVK_ANSI_X ]='x'; - g_keycodeCharUnshifted[ kVK_ANSI_C ]='c'; - g_keycodeCharUnshifted[ kVK_ANSI_V ]='v'; - g_keycodeCharUnshifted[ kVK_ANSI_B ]='b'; - g_keycodeCharUnshifted[ kVK_ANSI_Q ]='q'; - g_keycodeCharUnshifted[ kVK_ANSI_W ]='w'; - g_keycodeCharUnshifted[ kVK_ANSI_E ]='e'; - g_keycodeCharUnshifted[ kVK_ANSI_R ]='r'; - g_keycodeCharUnshifted[ kVK_ANSI_Y ]='y'; - g_keycodeCharUnshifted[ kVK_ANSI_T ]='t'; - g_keycodeCharUnshifted[ kVK_ANSI_1 ]='1'; - g_keycodeCharUnshifted[ kVK_ANSI_2 ]='2'; - g_keycodeCharUnshifted[ kVK_ANSI_3 ]='3'; - g_keycodeCharUnshifted[ kVK_ANSI_4 ]='4'; - g_keycodeCharUnshifted[ kVK_ANSI_6 ]='6'; - g_keycodeCharUnshifted[ kVK_ANSI_5 ]='5'; - g_keycodeCharUnshifted[ kVK_ANSI_Equal ]='='; - g_keycodeCharUnshifted[ kVK_ANSI_9 ]='9'; - g_keycodeCharUnshifted[ kVK_ANSI_7 ]='7'; - g_keycodeCharUnshifted[ kVK_ANSI_Minus ]='-'; - g_keycodeCharUnshifted[ kVK_ANSI_8 ]='8'; - g_keycodeCharUnshifted[ kVK_ANSI_0 ]='0'; - g_keycodeCharUnshifted[ kVK_ANSI_RightBracket ]=']'; - g_keycodeCharUnshifted[ kVK_ANSI_O ]='o'; - g_keycodeCharUnshifted[ kVK_ANSI_U ]='u'; - g_keycodeCharUnshifted[ kVK_ANSI_LeftBracket ]='['; - g_keycodeCharUnshifted[ kVK_ANSI_I ]='i'; - g_keycodeCharUnshifted[ kVK_ANSI_P ]='p'; - g_keycodeCharUnshifted[ kVK_ANSI_L ]='l'; - g_keycodeCharUnshifted[ kVK_ANSI_J ]='j'; - g_keycodeCharUnshifted[ kVK_ANSI_Quote ]='\''; - g_keycodeCharUnshifted[ kVK_ANSI_K ]='k'; - g_keycodeCharUnshifted[ kVK_ANSI_Semicolon ]=';'; - g_keycodeCharUnshifted[ kVK_ANSI_Backslash ]='\\'; - g_keycodeCharUnshifted[ kVK_ANSI_Comma ]=','; - g_keycodeCharUnshifted[ kVK_ANSI_Slash ]='/'; - g_keycodeCharUnshifted[ kVK_ANSI_N ]='n'; - g_keycodeCharUnshifted[ kVK_ANSI_M ]='m'; - g_keycodeCharUnshifted[ kVK_ANSI_Period ]='.'; - g_keycodeCharUnshifted[ kVK_ANSI_Grave ]='`'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadDecimal ]='.'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadMultiply ]='*'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadPlus ]='+'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadDivide ]='/'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadEnter ]='\n'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadMinus ]='-'; - g_keycodeCharUnshifted[ kVK_ANSI_KeypadEquals ]='='; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad0 ]='0'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad1 ]='1'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad2 ]='2'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad3 ]='3'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad4 ]='4'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad5 ]='5'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad6 ]='6'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad7 ]='7'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad8 ]='8'; - g_keycodeCharUnshifted[ kVK_ANSI_Keypad9 ]='9'; - g_keycodeCharUnshifted[ kVK_Space ]=' '; - - g_keycodeCharShifted[ kVK_ANSI_A ]='A'; - g_keycodeCharShifted[ kVK_ANSI_S ]='S'; - g_keycodeCharShifted[ kVK_ANSI_D ]='D'; - g_keycodeCharShifted[ kVK_ANSI_F ]='F'; - g_keycodeCharShifted[ kVK_ANSI_H ]='H'; - g_keycodeCharShifted[ kVK_ANSI_G ]='G'; - g_keycodeCharShifted[ kVK_ANSI_Z ]='Z'; - g_keycodeCharShifted[ kVK_ANSI_X ]='X'; - g_keycodeCharShifted[ kVK_ANSI_C ]='C'; - g_keycodeCharShifted[ kVK_ANSI_V ]='V'; - g_keycodeCharShifted[ kVK_ANSI_B ]='B'; - g_keycodeCharShifted[ kVK_ANSI_Q ]='Q'; - g_keycodeCharShifted[ kVK_ANSI_W ]='W'; - g_keycodeCharShifted[ kVK_ANSI_E ]='E'; - g_keycodeCharShifted[ kVK_ANSI_R ]='R'; - g_keycodeCharShifted[ kVK_ANSI_Y ]='Y'; - g_keycodeCharShifted[ kVK_ANSI_T ]='T'; - g_keycodeCharShifted[ kVK_ANSI_1 ]='!'; - g_keycodeCharShifted[ kVK_ANSI_2 ]='@'; - g_keycodeCharShifted[ kVK_ANSI_3 ]='#'; - g_keycodeCharShifted[ kVK_ANSI_4 ]='$'; - g_keycodeCharShifted[ kVK_ANSI_6 ]='^'; - g_keycodeCharShifted[ kVK_ANSI_5 ]='%'; - g_keycodeCharShifted[ kVK_ANSI_Equal ]='+'; - g_keycodeCharShifted[ kVK_ANSI_9 ]='('; - g_keycodeCharShifted[ kVK_ANSI_7 ]='&'; - g_keycodeCharShifted[ kVK_ANSI_Minus ]='_'; - g_keycodeCharShifted[ kVK_ANSI_8 ]='*'; - g_keycodeCharShifted[ kVK_ANSI_0 ]=')'; - g_keycodeCharShifted[ kVK_ANSI_RightBracket ]='}'; - g_keycodeCharShifted[ kVK_ANSI_O ]='O'; - g_keycodeCharShifted[ kVK_ANSI_U ]='U'; - g_keycodeCharShifted[ kVK_ANSI_LeftBracket ]='{'; - g_keycodeCharShifted[ kVK_ANSI_I ]='I'; - g_keycodeCharShifted[ kVK_ANSI_P ]='P'; - g_keycodeCharShifted[ kVK_ANSI_L ]='L'; - g_keycodeCharShifted[ kVK_ANSI_J ]='J'; - g_keycodeCharShifted[ kVK_ANSI_Quote ]='\"'; - g_keycodeCharShifted[ kVK_ANSI_K ]='K'; - g_keycodeCharShifted[ kVK_ANSI_Semicolon ]=':'; - g_keycodeCharShifted[ kVK_ANSI_Backslash ]='|'; - g_keycodeCharShifted[ kVK_ANSI_Comma ]='<'; - g_keycodeCharShifted[ kVK_ANSI_Slash ]='?'; - g_keycodeCharShifted[ kVK_ANSI_N ]='N'; - g_keycodeCharShifted[ kVK_ANSI_M ]='M'; - g_keycodeCharShifted[ kVK_ANSI_Period ]='>'; - g_keycodeCharShifted[ kVK_ANSI_Grave ]='~'; - g_keycodeCharShifted[ kVK_ANSI_KeypadDecimal ]='.'; - g_keycodeCharShifted[ kVK_ANSI_KeypadMultiply ]='*'; - g_keycodeCharShifted[ kVK_ANSI_KeypadPlus ]='+'; - g_keycodeCharShifted[ kVK_ANSI_KeypadDivide ]='/'; - g_keycodeCharShifted[ kVK_ANSI_KeypadEnter ]='\n'; - g_keycodeCharShifted[ kVK_ANSI_KeypadMinus ]='-'; - g_keycodeCharShifted[ kVK_ANSI_KeypadEquals ]='='; - g_keycodeCharShifted[ kVK_ANSI_Keypad0 ]='0'; - g_keycodeCharShifted[ kVK_ANSI_Keypad1 ]='1'; - g_keycodeCharShifted[ kVK_ANSI_Keypad2 ]='2'; - g_keycodeCharShifted[ kVK_ANSI_Keypad3 ]='3'; - g_keycodeCharShifted[ kVK_ANSI_Keypad4 ]='4'; - g_keycodeCharShifted[ kVK_ANSI_Keypad5 ]='5'; - g_keycodeCharShifted[ kVK_ANSI_Keypad6 ]='6'; - g_keycodeCharShifted[ kVK_ANSI_Keypad7 ]='7'; - g_keycodeCharShifted[ kVK_ANSI_Keypad8 ]='8'; - g_keycodeCharShifted[ kVK_ANSI_Keypad9 ]='9'; - g_keycodeCharShifted[ kVK_Space ]=' '; -} - -- (void)setupImGuiHooks -{ - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - - [self setupKeymaps]; - - // Account for retina display for glScissor - g_displayScale = [[UIScreen mainScreen] scale]; - - ImGuiStyle& style = ImGui::GetStyle(); - style.TouchExtraPadding = ImVec2( 4.0, 4.0 ); - - io.RenderDrawListsFn = ImGui_ImplIOS_RenderDrawLists; - - UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(viewDidPan:) ]; - [self.view addGestureRecognizer:panRecognizer]; - - UITapGestureRecognizer *tapRecoginzer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector( viewDidTap:)]; - [self.view addGestureRecognizer:tapRecoginzer]; - - // Fill out the Synergy key map - // (for some reason synergy scan codes are off by 1) - io.KeyMap[ImGuiKey_Tab] = kVK_Tab+1; - io.KeyMap[ImGuiKey_LeftArrow] = kVK_LeftArrow+1; - io.KeyMap[ImGuiKey_RightArrow] = kVK_RightArrow+1; - io.KeyMap[ImGuiKey_UpArrow] = kVK_UpArrow+1; - io.KeyMap[ImGuiKey_DownArrow] = kVK_DownArrow+1; - io.KeyMap[ImGuiKey_Home] = kVK_Home+1; - io.KeyMap[ImGuiKey_End] = kVK_End+1; - io.KeyMap[ImGuiKey_Insert] = kVK_Help+1; - io.KeyMap[ImGuiKey_Delete] = kVK_ForwardDelete+1; - io.KeyMap[ImGuiKey_Backspace] = kVK_Delete+1; - io.KeyMap[ImGuiKey_Space] = kVK_Space+1; - io.KeyMap[ImGuiKey_Enter] = kVK_Return+1; - io.KeyMap[ImGuiKey_Escape] = kVK_Escape+1; - io.KeyMap[ImGuiKey_A] = kVK_ANSI_A+1; - io.KeyMap[ImGuiKey_C] = kVK_ANSI_C+1; - io.KeyMap[ImGuiKey_V] = kVK_ANSI_V+1; - io.KeyMap[ImGuiKey_X] = kVK_ANSI_X+1; - io.KeyMap[ImGuiKey_Y] = kVK_ANSI_Y+1; - io.KeyMap[ImGuiKey_Z] = kVK_ANSI_Z+1; -} - -- (void)connectServer: (NSString*)serverName -{ - self.serverName = serverName; - g_serverName = serverName; - - // Init synergy - NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]; - - uSynergyInit( &_synergyCtx ); - _synergyCtx.m_clientName = strdup( [bundleName UTF8String] ); - _synergyCtx.m_clientWidth = self.view.bounds.size.width; - _synergyCtx.m_clientHeight = self.view.bounds.size.height; - - _synergyCtx.m_connectFunc = ImGui_ConnectFunc; - _synergyCtx.m_sendFunc = ImGui_SendFunc; - _synergyCtx.m_receiveFunc = ImGui_RecvFunc; - _synergyCtx.m_sleepFunc = ImGui_SleepFunc; - _synergyCtx.m_traceFunc = ImGui_TraceFunc; - _synergyCtx.m_getTimeFunc = ImGui_GetTimeFunc; - - _synergyCtx.m_traceFunc = ImGui_TraceFunc; - _synergyCtx.m_screenActiveCallback = ImGui_ScreenActiveCallback; - _synergyCtx.m_mouseCallback = ImGui_MouseCallback; - _synergyCtx.m_keyboardCallback = ImGui_KeyboardCallback; - - _synergyCtx.m_cookie = (uSynergyCookie)&_synergyCtx; - - // Create a background thread for synergy - _synergyQueue = dispatch_queue_create( "imgui-usynergy", NULL ); - dispatch_async( _synergyQueue, ^{ - while (1) - uSynergyUpdate(&_synergyCtx); - }); -} - - -- (void)viewDidPan: (UIPanGestureRecognizer *)recognizer -{ - - if ((recognizer.state == UIGestureRecognizerStateBegan) || - (recognizer.state == UIGestureRecognizerStateChanged)) - { - _mouseDown = YES; - _touchPos = [recognizer locationInView:self.view]; - } - else - { - _mouseDown = NO; - _touchPos = CGPointMake( -1, -1 ); - } -} - -- (void)viewDidTap: (UITapGestureRecognizer*)recognizer -{ - _touchPos = [recognizer locationInView:self.view]; - _mouseTapped = YES; -} - -- (void)render -{ - ImGui::Render(); -} - -- (void)newFrame -{ - ImGuiIO& io = ImGui::GetIO(); - ImGuiStyle& style = ImGui::GetStyle(); - - if (!g_FontTexture) - ImGui_ImplIOS_CreateDeviceObjects(); - - io.DisplaySize = ImVec2(_view.bounds.size.width, _view.bounds.size.height); - - io.MouseDrawCursor = g_synergyPtrActive; - if (g_synergyPtrActive) - { - style.TouchExtraPadding = ImVec2(0.0, 0.0); - io.MousePos = ImVec2(g_mousePosX, g_mousePosY); - for (int i=0; i < 3; i++) - io.MouseDown[i] = g_MousePressed[i]; - - // This is an arbitrary scaling factor that works for me. Not sure what units these mousewheel values from synergy are supposed to be in. - io.MouseWheel = g_mouseWheelY / 500.0; - io.MouseWheelH = g_mouseWheelX / 500.0; - } - else - { - // Synergy not active, use touch events - style.TouchExtraPadding = ImVec2(4.0, 4.0); - io.MousePos = ImVec2(_touchPos.x, _touchPos.y); - if ((_mouseDown) || (_mouseTapped)) - { - io.MouseDown[0] = true; - _mouseTapped = NO; - } - else - { - io.MouseDown[0] = false; - } - } - - ImGui::NewFrame(); -} -@end - -// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) -// If text or lines are blurry when integrating ImGui in your engine: -// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f) -// NOTE: this is copied pretty much entirely from the example_glfw_opengl3, with only minor changes for ES -static void ImGui_ImplIOS_RenderDrawLists (ImDrawData *draw_data) -{ - // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled - // FIXME: Backport changes from imgui_impl_glfw_gl3.cpp - GLint last_program, last_texture; - glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glEnable(GL_SCISSOR_TEST); - glActiveTexture(GL_TEXTURE0); - - // Setup orthographic projection matrix - const float width = ImGui::GetIO().DisplaySize.x; - const float height = ImGui::GetIO().DisplaySize.y; - const float ortho_projection[4][4] = - { - { 2.0f/width, 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/-height, 0.0f, 0.0f }, - { 0.0f, 0.0f, -1.0f, 0.0f }, - { -1.0f, 1.0f, 0.0f, 1.0f }, - }; - glUseProgram(g_ShaderHandle); - glUniform1i(g_AttribLocationTex, 0); - glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); - glBindVertexArray(g_VaoHandle); - - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - ImDrawList* cmd_list = draw_data->CmdLists[n]; - ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front(); - - glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); - const int needed_vtx_size = cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); - if (g_VboSize < needed_vtx_size) - { - // Grow our buffer if needed - g_VboSize = needed_vtx_size + 2000 * sizeof(ImDrawVert); - glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)g_VboSize, NULL, GL_STREAM_DRAW); - } - - unsigned char* vtx_data = (unsigned char*)glMapBufferRange(GL_ARRAY_BUFFER, 0, needed_vtx_size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); - if (!vtx_data) - continue; - memcpy(vtx_data, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - glUnmapBuffer(GL_ARRAY_BUFFER); - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId); - glScissor((int)(pcmd->ClipRect.x * g_displayScale), - (int)((height - pcmd->ClipRect.w) * g_displayScale), - (int)((pcmd->ClipRect.z - pcmd->ClipRect.x) * g_displayScale), - (int)((pcmd->ClipRect.w - pcmd->ClipRect.y) * g_displayScale)); - glDrawElements( GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer ); - } - idx_buffer += pcmd->ElemCount; - } - } - - // Restore modified state - glBindVertexArray(0); - glBindBuffer( GL_ARRAY_BUFFER, 0); - glEnable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); - glUseProgram(last_program); - glDisable(GL_SCISSOR_TEST); - glBindTexture(GL_TEXTURE_2D, last_texture); -} - -void ImGui_ImplIOS_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader. - - // Upload texture to graphics system - GLint last_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGenTextures(1, &g_FontTexture); - glBindTexture(GL_TEXTURE_2D, g_FontTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - // Store our identifier - io.Fonts->TexID = (void *)(intptr_t)g_FontTexture; - - // Restore state - glBindTexture(GL_TEXTURE_2D, last_texture); -} - -bool ImGui_ImplIOS_CreateDeviceObjects() -{ - const GLchar *vertex_shader = - "uniform mat4 ProjMtx;\n" - "attribute highp vec2 Position;\n" - "attribute highp vec2 UV;\n" - "attribute highp vec4 Color;\n" - "varying vec2 Frag_UV;\n" - "varying vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* fragment_shader = - "uniform sampler2D Texture;\n" - "varying highp vec2 Frag_UV;\n" - "varying highp vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " gl_FragColor = Frag_Color * texture2D( Texture, Frag_UV.st);\n" - "}\n"; - - g_ShaderHandle = glCreateProgram(); - g_VertHandle = glCreateShader(GL_VERTEX_SHADER); - g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(g_VertHandle, 1, &vertex_shader, 0); - glShaderSource(g_FragHandle, 1, &fragment_shader, 0); - glCompileShader(g_VertHandle); - -#if defined(DEBUG) - GLint logLength; - glGetShaderiv( g_VertHandle, GL_INFO_LOG_LENGTH, &logLength); - if (logLength > 0) { - GLchar *log = (GLchar *)malloc(logLength); - glGetShaderInfoLog(g_VertHandle, logLength, &logLength, log); - NSLog(@"VERTEX Shader compile log:\n%s", log); - free(log); - } -#endif - - glCompileShader(g_FragHandle); - -#if defined(DEBUG) - glGetShaderiv( g_FragHandle, GL_INFO_LOG_LENGTH, &logLength); - if (logLength > 0) { - GLchar *log = (GLchar *)malloc(logLength); - glGetShaderInfoLog(g_FragHandle, logLength, &logLength, log); - NSLog(@"FRAGMENT Shader compile log:\n%s", log); - free(log); - } -#endif - - glAttachShader(g_ShaderHandle, g_VertHandle); - glAttachShader(g_ShaderHandle, g_FragHandle); - glLinkProgram(g_ShaderHandle); - - g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture"); - g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx"); - g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position"); - g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV"); - g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color"); - - glGenBuffers(1, &g_VboHandle); - - glGenVertexArrays(1, &g_VaoHandle); - glBindVertexArray(g_VaoHandle); - glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); - glEnableVertexAttribArray(g_AttribLocationPosition); - glEnableVertexAttribArray(g_AttribLocationUV); - glEnableVertexAttribArray(g_AttribLocationColor); - - glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos)); - glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv)); - glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col)); - - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - ImGui_ImplIOS_CreateFontsTexture(); - - return true; -} diff --git a/examples/example_apple/imguiex-ios/main.m b/examples/example_apple/imguiex-ios/main.m deleted file mode 100644 index faba0992..00000000 --- a/examples/example_apple/imguiex-ios/main.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// main.m -// imguiex -// - -#import -#import "AppDelegate.h" - -int main(int argc, char * argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/examples/example_apple/imguiex-osx/AppDelegate.h b/examples/example_apple/imguiex-osx/AppDelegate.h deleted file mode 100644 index 33d199bb..00000000 --- a/examples/example_apple/imguiex-osx/AppDelegate.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// AppDelegate.h -// imguiex-osx -// -// Created by James Chen on 4/5/16. -// Copyright © 2016 Joel Davis. All rights reserved. -// - -#import - -@interface AppDelegate : NSObject - - -@end - diff --git a/examples/example_apple/imguiex-osx/AppDelegate.m b/examples/example_apple/imguiex-osx/AppDelegate.m deleted file mode 100644 index 59e877b3..00000000 --- a/examples/example_apple/imguiex-osx/AppDelegate.m +++ /dev/null @@ -1,26 +0,0 @@ -// -// AppDelegate.m -// imguiex-osx -// -// Created by James Chen on 4/5/16. -// Copyright © 2016 Joel Davis. All rights reserved. -// - -#import "AppDelegate.h" - -@interface AppDelegate () - -@property (weak) IBOutlet NSWindow *window; -@end - -@implementation AppDelegate - -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // Insert code here to initialize your application -} - -- (void)applicationWillTerminate:(NSNotification *)aNotification { - // Insert code here to tear down your application -} - -@end diff --git a/examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index b13908fc..00000000 --- a/examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "size" : "16x16", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "16x16", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "32x32", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "32x32", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "128x128", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "128x128", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "256x256", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "256x256", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "512x512", - "scale" : "1x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "icon_imgui_180x180.png", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "512x512", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/icon_imgui_180x180.png b/examples/example_apple/imguiex-osx/Assets.xcassets/AppIcon.appiconset/icon_imgui_180x180.png deleted file mode 100644 index f48b799dba2cf05b31924886eb4fc9d803ea4a83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5953 zcmY+IbyO5U*Z&s~mXK~(kX*V!I+q0mrE_VJP`W#$L0CGL7U`7k5Trv8SxP}*k?!u- z=Q;0r&+qrg+_`7YoSE;P`#Dpwn(E5IX1b9acHVLf|;1`5Ce<3HOTNdq-6m0#X-tG_jZ zCXx1+H@A5Eh_t1$Snf`Sa#+jbR*MW=oQ%ePzPMemdpGE{`ukxHC@`MH8o^yN@$!hL zxIJpKDO#U^f%ElC`W*Yf{FvD$rs<9?i9vKf5?Kltb0IMJ6l)WBbSq1}KgvHK?SA}G zCpGaSQw4Pz{hoXnwv{9I;?~GooqZjXGY51~nLrgIS3oJs_@*^zwb7edUegYg?Qd1& z_ASfz&isotGH+^k;vPB^7Zb;=5?ekS8*)ByL?7_i&4EtHDN8XAdH>NoU*_WWCONsI zxn+wii}(fAor!gzoh|lTM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I^Y&!8VuTa1TK0(d z6B3@x-Rr7T^IGfMme|Epm3s>O`l;m$o9nux7AW2s zn&k^yj3fJ;mPa{!-Mg7wi{v7JUw?BOHl#f#bz@2dF-tUdkYHe%*pwBdmevRbbO_>RasM#?)D@zhfaJu+MB9SJ5F9CXiBTGnWlP%rz9!4 z+7+}n|Bb~EeY-jMdj>4yAr!4zKtQ}5CQ5^_(9#mPpl`Tk(t#u1o?3iFIj{%h0Fib@Zh9f` zHM8T0+Vdz*>`$W831QS_k%v&LxKkMu+%PG0Qj$~T4%)$UbNcYgx~A2~UaQ#=W!W{! z=pMgKQj_<_=2p_HVtE;Dtt1fai}f#-z}pn<3jR+;w%$^CLCBGe66{p|9k_C2p%r-n z*OBrxH)o05gU|$cFe}pRpmjfFU4eMQv6xQVmG1N@R7?)UKtKeH!T5%@4sZkf*Z%*F aW)oPOXB1N~w0~dYfLBm;#aac6u>S!7Vo}-v diff --git a/examples/example_apple/imguiex-osx/Assets.xcassets/Contents.json b/examples/example_apple/imguiex-osx/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c..00000000 --- a/examples/example_apple/imguiex-osx/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/examples/example_apple/imguiex-osx/Info.plist b/examples/example_apple/imguiex-osx/Info.plist deleted file mode 100644 index ba1c2bb0..00000000 --- a/examples/example_apple/imguiex-osx/Info.plist +++ /dev/null @@ -1,34 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSHumanReadableCopyright - Copyright © 2016 Joel Davis. All rights reserved. - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/examples/example_apple/imguiex-osx/main.m b/examples/example_apple/imguiex-osx/main.m deleted file mode 100644 index 20b07313..00000000 --- a/examples/example_apple/imguiex-osx/main.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// main.m -// imguiex-osx -// -// Created by James Chen on 4/5/16. -// Copyright © 2016 Joel Davis. All rights reserved. -// - -#import - -int main(int argc, const char * argv[]) { - return NSApplicationMain(argc, argv); -} diff --git a/examples/example_apple/imguiex.xcodeproj/project.pbxproj b/examples/example_apple/imguiex.xcodeproj/project.pbxproj deleted file mode 100644 index c41ba35a..00000000 --- a/examples/example_apple/imguiex.xcodeproj/project.pbxproj +++ /dev/null @@ -1,544 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 07DB0B2E20E3767000FF57F1 /* imgui_impl_opengl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DB0B2B20E3767000FF57F1 /* imgui_impl_opengl2.cpp */; }; - 07DB0B2F20E3767000FF57F1 /* imgui_impl_glfw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DB0B2D20E3767000FF57F1 /* imgui_impl_glfw.cpp */; }; - 07DB0B3120E3768400FF57F1 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DB0B3020E3768400FF57F1 /* main.cpp */; }; - 197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */; }; - 197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; }; - 1A1A0F231CB39FB50090F036 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A1A0F221CB39FB50090F036 /* AppDelegate.m */; }; - 1A1A0F281CB39FB50090F036 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A1A0F271CB39FB50090F036 /* Assets.xcassets */; }; - 1A1A0F301CB3A0DA0090F036 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */; }; - 1A1A0F311CB3A0DA0090F036 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5861B2E64AB00C130BA /* imgui.cpp */; }; - 1A1A0F321CB3A0DE0090F036 /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; }; - 1A1A0F331CB3A0E10090F036 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; }; - 1A1A0F341CB3A0EC0090F036 /* debug_hud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */; }; - 1A1A0F4E1CB3C54D0090F036 /* libglfw.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */; }; - 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; }; - 6D2FC55A1B2E632000C130BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5591B2E632000C130BA /* main.m */; }; - 6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC55C1B2E632000C130BA /* AppDelegate.m */; }; - 6D2FC55F1B2E632000C130BA /* Shader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC55E1B2E632000C130BA /* Shader.fsh */; }; - 6D2FC5611B2E632000C130BA /* Shader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5601B2E632000C130BA /* Shader.vsh */; }; - 6D2FC5641B2E632000C130BA /* GameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5631B2E632000C130BA /* GameViewController.m */; }; - 6D2FC5671B2E632000C130BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5651B2E632000C130BA /* Main.storyboard */; }; - 6D2FC5691B2E632000C130BA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC5681B2E632000C130BA /* Images.xcassets */; }; - 6D2FC56C1B2E632000C130BA /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */; }; - 6D2FC5831B2E63A100C130BA /* imgui_impl_ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */; }; - 6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5861B2E64AB00C130BA /* imgui.cpp */; }; - 6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */; }; - 6D2FC5911B30773F00C130BA /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2FC5901B30773F00C130BA /* CFNetwork.framework */; }; - 6D2FC5931B30774900C130BA /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 07DB0B2A20E3767000FF57F1 /* imgui_impl_glfw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_glfw.h; path = ../../imgui_impl_glfw.h; sourceTree = ""; }; - 07DB0B2B20E3767000FF57F1 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../../imgui_impl_opengl2.cpp; sourceTree = ""; }; - 07DB0B2C20E3767000FF57F1 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../../imgui_impl_opengl2.h; sourceTree = ""; }; - 07DB0B2D20E3767000FF57F1 /* imgui_impl_glfw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_glfw.cpp; path = ../../imgui_impl_glfw.cpp; sourceTree = ""; }; - 07DB0B3020E3768400FF57F1 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../example_glfw_opengl2/main.cpp; sourceTree = ""; }; - 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; - 197E1E881B89443600E3FE6A /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../../imgui_demo.cpp; sourceTree = ""; }; - 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "imguiex-osx.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 1A1A0F211CB39FB50090F036 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 1A1A0F221CB39FB50090F036 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 1A1A0F271CB39FB50090F036 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 1A1A0F2C1CB39FB50090F036 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libglfw.dylib; path = /usr/local/lib/libglfw.dylib; sourceTree = ""; }; - 6D1E39151B35EEF10017B40F /* uSynergy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uSynergy.c; sourceTree = ""; }; - 6D1E39161B35EEF10017B40F /* uSynergy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uSynergy.h; sourceTree = ""; }; - 6D2FC5541B2E632000C130BA /* imguiex-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "imguiex-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 6D2FC5581B2E632000C130BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 6D2FC5591B2E632000C130BA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 6D2FC55B1B2E632000C130BA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 6D2FC55C1B2E632000C130BA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 6D2FC55E1B2E632000C130BA /* Shader.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.fsh; path = Shaders/Shader.fsh; sourceTree = ""; }; - 6D2FC5601B2E632000C130BA /* Shader.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = Shader.vsh; path = Shaders/Shader.vsh; sourceTree = ""; }; - 6D2FC5621B2E632000C130BA /* GameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameViewController.h; sourceTree = ""; }; - 6D2FC5631B2E632000C130BA /* GameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameViewController.m; sourceTree = ""; }; - 6D2FC5661B2E632000C130BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 6D2FC5681B2E632000C130BA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 6D2FC56B1B2E632000C130BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = imgui_impl_ios.mm; sourceTree = ""; }; - 6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = imgui_impl_ios.h; sourceTree = ""; }; - 6D2FC5851B2E64AB00C130BA /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; }; - 6D2FC5861B2E64AB00C130BA /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; - 6D2FC5871B2E64AB00C130BA /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; - 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = debug_hud.cpp; sourceTree = ""; }; - 6D2FC58A1B2E6A5500C130BA /* debug_hud.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug_hud.h; sourceTree = ""; }; - 6D2FC5901B30773F00C130BA /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; - 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 1A1A0F1C1CB39FB50090F036 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 1A1A0F4E1CB3C54D0090F036 /* libglfw.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 6D2FC5511B2E632000C130BA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 6D2FC5931B30774900C130BA /* SystemConfiguration.framework in Frameworks */, - 6D2FC5911B30773F00C130BA /* CFNetwork.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 07DB0B2920E3762C00FF57F1 /* example_glfw_gl2 */ = { - isa = PBXGroup; - children = ( - 07DB0B3020E3768400FF57F1 /* main.cpp */, - 07DB0B2D20E3767000FF57F1 /* imgui_impl_glfw.cpp */, - 07DB0B2A20E3767000FF57F1 /* imgui_impl_glfw.h */, - 07DB0B2B20E3767000FF57F1 /* imgui_impl_opengl2.cpp */, - 07DB0B2C20E3767000FF57F1 /* imgui_impl_opengl2.h */, - ); - name = example_glfw_gl2; - sourceTree = ""; - }; - 1A1A0F201CB39FB50090F036 /* imguiex-osx */ = { - isa = PBXGroup; - children = ( - 07DB0B2920E3762C00FF57F1 /* example_glfw_gl2 */, - 1A1A0F4D1CB3C54D0090F036 /* libglfw.dylib */, - 1A1A0F211CB39FB50090F036 /* AppDelegate.h */, - 1A1A0F221CB39FB50090F036 /* AppDelegate.m */, - 1A1A0F271CB39FB50090F036 /* Assets.xcassets */, - 1A1A0F2C1CB39FB50090F036 /* Info.plist */, - 1A1A0F241CB39FB50090F036 /* Supporting Files */, - ); - path = "imguiex-osx"; - sourceTree = ""; - }; - 1A1A0F241CB39FB50090F036 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 6D1E39141B35EEF10017B40F /* usynergy */ = { - isa = PBXGroup; - children = ( - 6D1E39151B35EEF10017B40F /* uSynergy.c */, - 6D1E39161B35EEF10017B40F /* uSynergy.h */, - ); - name = usynergy; - path = ../libs/usynergy; - sourceTree = ""; - }; - 6D2FC54B1B2E632000C130BA = { - isa = PBXGroup; - children = ( - 6D1E39141B35EEF10017B40F /* usynergy */, - 6D2FC5841B2E648D00C130BA /* imgui */, - 6D2FC5561B2E632000C130BA /* imguiex-ios */, - 1A1A0F201CB39FB50090F036 /* imguiex-osx */, - 6D2FC5551B2E632000C130BA /* Products */, - ); - sourceTree = ""; - }; - 6D2FC5551B2E632000C130BA /* Products */ = { - isa = PBXGroup; - children = ( - 6D2FC5541B2E632000C130BA /* imguiex-ios.app */, - 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */, - ); - name = Products; - sourceTree = ""; - }; - 6D2FC5561B2E632000C130BA /* imguiex-ios */ = { - isa = PBXGroup; - children = ( - 6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */, - 6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */, - 197E1E881B89443600E3FE6A /* imgui_demo.cpp */, - 6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */, - 6D2FC58A1B2E6A5500C130BA /* debug_hud.h */, - 6D2FC55B1B2E632000C130BA /* AppDelegate.h */, - 6D2FC55C1B2E632000C130BA /* AppDelegate.m */, - 6D2FC55E1B2E632000C130BA /* Shader.fsh */, - 6D2FC5601B2E632000C130BA /* Shader.vsh */, - 6D2FC5621B2E632000C130BA /* GameViewController.h */, - 6D2FC5631B2E632000C130BA /* GameViewController.m */, - 6D2FC5651B2E632000C130BA /* Main.storyboard */, - 6D2FC5681B2E632000C130BA /* Images.xcassets */, - 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */, - 6D2FC5571B2E632000C130BA /* Supporting Files */, - ); - path = "imguiex-ios"; - sourceTree = ""; - }; - 6D2FC5571B2E632000C130BA /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 6D2FC5921B30774900C130BA /* SystemConfiguration.framework */, - 6D2FC5901B30773F00C130BA /* CFNetwork.framework */, - 6D2FC5581B2E632000C130BA /* Info.plist */, - 6D2FC5591B2E632000C130BA /* main.m */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 6D2FC5841B2E648D00C130BA /* imgui */ = { - isa = PBXGroup; - children = ( - 6D2FC5851B2E64AB00C130BA /* imconfig.h */, - 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */, - 6D2FC5861B2E64AB00C130BA /* imgui.cpp */, - 6D2FC5871B2E64AB00C130BA /* imgui.h */, - ); - name = imgui; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 1A1A0F1E1CB39FB50090F036 /* imguiex-osx */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1A1A0F2F1CB39FB50090F036 /* Build configuration list for PBXNativeTarget "imguiex-osx" */; - buildPhases = ( - 1A1A0F1B1CB39FB50090F036 /* Sources */, - 1A1A0F1C1CB39FB50090F036 /* Frameworks */, - 1A1A0F1D1CB39FB50090F036 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "imguiex-osx"; - productName = "imguiex-osx"; - productReference = 1A1A0F1F1CB39FB50090F036 /* imguiex-osx.app */; - productType = "com.apple.product-type.application"; - }; - 6D2FC5531B2E632000C130BA /* imguiex-ios */ = { - isa = PBXNativeTarget; - buildConfigurationList = 6D2FC57B1B2E632000C130BA /* Build configuration list for PBXNativeTarget "imguiex-ios" */; - buildPhases = ( - 6D2FC5501B2E632000C130BA /* Sources */, - 6D2FC5511B2E632000C130BA /* Frameworks */, - 6D2FC5521B2E632000C130BA /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "imguiex-ios"; - productName = imguiex; - productReference = 6D2FC5541B2E632000C130BA /* imguiex-ios.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 6D2FC54C1B2E632000C130BA /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0630; - ORGANIZATIONNAME = "Joel Davis"; - TargetAttributes = { - 1A1A0F1E1CB39FB50090F036 = { - CreatedOnToolsVersion = 7.3; - }; - 6D2FC5531B2E632000C130BA = { - CreatedOnToolsVersion = 6.3.2; - }; - }; - }; - buildConfigurationList = 6D2FC54F1B2E632000C130BA /* Build configuration list for PBXProject "imguiex" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 6D2FC54B1B2E632000C130BA; - productRefGroup = 6D2FC5551B2E632000C130BA /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 6D2FC5531B2E632000C130BA /* imguiex-ios */, - 1A1A0F1E1CB39FB50090F036 /* imguiex-osx */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 1A1A0F1D1CB39FB50090F036 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1A1A0F281CB39FB50090F036 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 6D2FC5521B2E632000C130BA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 6D2FC56C1B2E632000C130BA /* LaunchScreen.xib in Resources */, - 6D2FC5671B2E632000C130BA /* Main.storyboard in Resources */, - 6D2FC5691B2E632000C130BA /* Images.xcassets in Resources */, - 6D2FC5611B2E632000C130BA /* Shader.vsh in Resources */, - 6D2FC55F1B2E632000C130BA /* Shader.fsh in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 1A1A0F1B1CB39FB50090F036 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1A1A0F301CB3A0DA0090F036 /* imgui_draw.cpp in Sources */, - 1A1A0F311CB3A0DA0090F036 /* imgui.cpp in Sources */, - 07DB0B3120E3768400FF57F1 /* main.cpp in Sources */, - 1A1A0F331CB3A0E10090F036 /* imgui_demo.cpp in Sources */, - 1A1A0F341CB3A0EC0090F036 /* debug_hud.cpp in Sources */, - 07DB0B2E20E3767000FF57F1 /* imgui_impl_opengl2.cpp in Sources */, - 1A1A0F321CB3A0DE0090F036 /* uSynergy.c in Sources */, - 1A1A0F231CB39FB50090F036 /* AppDelegate.m in Sources */, - 07DB0B2F20E3767000FF57F1 /* imgui_impl_glfw.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 6D2FC5501B2E632000C130BA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */, - 6D2FC5831B2E63A100C130BA /* imgui_impl_ios.mm in Sources */, - 6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */, - 6D2FC5641B2E632000C130BA /* GameViewController.m in Sources */, - 6D2FC55A1B2E632000C130BA /* main.m in Sources */, - 6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */, - 6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */, - 197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */, - 197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 6D2FC5651B2E632000C130BA /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 6D2FC5661B2E632000C130BA /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 6D2FC56A1B2E632000C130BA /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - 6D2FC56B1B2E632000C130BA /* Base */, - ); - name = LaunchScreen.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 1A1A0F2D1CB39FB50090F036 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ANALYZER_NONNULL = YES; - CODE_SIGN_IDENTITY = "-"; - COMBINE_HIDPI_IMAGES = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_TESTABILITY = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../", - /usr/local/include, - ); - INFOPLIST_FILE = "imguiex-osx/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - LIBRARY_SEARCH_PATHS = /usr/local/lib; - MACOSX_DEPLOYMENT_TARGET = 10.7; - PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.imguiex.imguiex-osx"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = ""; - }; - name = Debug; - }; - 1A1A0F2E1CB39FB50090F036 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ANALYZER_NONNULL = YES; - CODE_SIGN_IDENTITY = "-"; - COMBINE_HIDPI_IMAGES = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "$(SRCROOT)/../../", - /usr/local/include, - ); - INFOPLIST_FILE = "imguiex-osx/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - LIBRARY_SEARCH_PATHS = /usr/local/lib; - MACOSX_DEPLOYMENT_TARGET = 10.7; - PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.imguiex.imguiex-osx"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = ""; - }; - name = Release; - }; - 6D2FC5791B2E632000C130BA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "$(SRCROOT)/../../"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; - }; - name = Debug; - }; - 6D2FC57A1B2E632000C130BA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "$(SRCROOT)/../../"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ""; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 6D2FC57C1B2E632000C130BA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = "imguiex-ios/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 6D2FC57D1B2E632000C130BA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - INFOPLIST_FILE = "imguiex-ios/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1A1A0F2F1CB39FB50090F036 /* Build configuration list for PBXNativeTarget "imguiex-osx" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1A1A0F2D1CB39FB50090F036 /* Debug */, - 1A1A0F2E1CB39FB50090F036 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 6D2FC54F1B2E632000C130BA /* Build configuration list for PBXProject "imguiex" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6D2FC5791B2E632000C130BA /* Debug */, - 6D2FC57A1B2E632000C130BA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 6D2FC57B1B2E632000C130BA /* Build configuration list for PBXNativeTarget "imguiex-ios" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 6D2FC57C1B2E632000C130BA /* Debug */, - 6D2FC57D1B2E632000C130BA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 6D2FC54C1B2E632000C130BA /* Project object */; -} From 89e2ddf07f30c9f00f2df924e8f236ced434daa8 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 8 Jul 2018 11:16:11 +0200 Subject: [PATCH 15/16] Examples: Comments + shallow coding convention tweak to be consistent across examples and with imgui_impl_osx --- examples/README.txt | 4 +- examples/example_apple_metal/README.md | 4 +- examples/imgui_impl_metal.mm | 97 ++++++++++++++++---------- 3 files changed, 67 insertions(+), 38 deletions(-) diff --git a/examples/README.txt b/examples/README.txt index 5535c8dd..e84fae8b 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -166,12 +166,12 @@ example_win32_directx12/ example_apple_metal/ OSX & iOS + Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. - Note that instead of the OSX bindings, you may want to use GLFW or SDL which will also support Windows, Linux along with OSX. + (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) = game template + imgui_impl_osx.mm + imgui_impl_metal.mm example_apple_opengl2/ OSX + OpenGL2. - Note that instead of the OSX bindings, you may want to use GLFW or SDL which will also support Windows, Linux along with OSX. + (NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) = main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp example_glfw_opengl2/ diff --git a/examples/example_apple_metal/README.md b/examples/example_apple_metal/README.md index d43b4925..4f620327 100644 --- a/examples/example_apple_metal/README.md +++ b/examples/example_apple_metal/README.md @@ -2,5 +2,7 @@ ## Introduction -This example shows how to render ImGui with Metal. It is based on the cross-platform game template provided with Xcode as of Xcode 9. +This example shows how to integrate Dear ImGui with Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. + +(NB: you may still want to use GLFW or SDL which will also support Windows, Linux along with OSX.) diff --git a/examples/imgui_impl_metal.mm b/examples/imgui_impl_metal.mm index 8ee0643f..a4d235c9 100644 --- a/examples/imgui_impl_metal.mm +++ b/examples/imgui_impl_metal.mm @@ -128,8 +128,10 @@ void ImGui_ImplMetal_DestroyDeviceObjects() #pragma mark - MetalBuffer implementation @implementation MetalBuffer -- (instancetype)initWithBuffer:(id)buffer { - if ((self = [super init])) { +- (instancetype)initWithBuffer:(id)buffer +{ + if ((self = [super init])) + { _buffer = buffer; _lastReuseTime = [NSDate date].timeIntervalSince1970; } @@ -140,8 +142,10 @@ void ImGui_ImplMetal_DestroyDeviceObjects() #pragma mark - FramebufferDescriptor implementation @implementation FramebufferDescriptor -- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor { - if ((self = [super init])) { +- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor +{ + if ((self = [super init])) + { _sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount; _colorPixelFormat = renderPassDescriptor.colorAttachments[0].texture.pixelFormat; _depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat; @@ -150,7 +154,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() return self; } -- (nonnull id)copyWithZone:(nullable NSZone *)zone { +- (nonnull id)copyWithZone:(nullable NSZone *)zone +{ FramebufferDescriptor *copy = [[FramebufferDescriptor allocWithZone:zone] init]; copy.sampleCount = self.sampleCount; copy.colorPixelFormat = self.colorPixelFormat; @@ -159,7 +164,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() return copy; } -- (NSUInteger)hash { +- (NSUInteger)hash +{ NSUInteger sc = _sampleCount & 0x3; NSUInteger cf = _colorPixelFormat & 0x3FF; NSUInteger df = _depthPixelFormat & 0x3FF; @@ -168,12 +174,12 @@ void ImGui_ImplMetal_DestroyDeviceObjects() return hash; } -- (BOOL)isEqual:(id)object { +- (BOOL)isEqual:(id)object +{ FramebufferDescriptor *other = object; - if (![other isKindOfClass:[FramebufferDescriptor class]]) { + if (![other isKindOfClass:[FramebufferDescriptor class]]) return NO; - } - return other.sampleCount == self.sampleCount && + return other.sampleCount == self.sampleCount && other.colorPixelFormat == self.colorPixelFormat && other.depthPixelFormat == self.depthPixelFormat && other.stencilPixelFormat == self.stencilPixelFormat; @@ -185,7 +191,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() @implementation MetalContext - (instancetype)init { - if ((self = [super init])) { + if ((self = [super init])) + { _renderPipelineStateCache = [NSMutableDictionary dictionary]; _bufferCache = [NSMutableArray array]; _lastBufferCachePurge = [NSDate date].timeIntervalSince1970; @@ -193,14 +200,20 @@ void ImGui_ImplMetal_DestroyDeviceObjects() return self; } -- (void)makeDeviceObjectsWithDevice:(id)device { +- (void)makeDeviceObjectsWithDevice:(id)device +{ MTLDepthStencilDescriptor *depthStencilDescriptor = [[MTLDepthStencilDescriptor alloc] init]; depthStencilDescriptor.depthWriteEnabled = NO; depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways; self.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; } -- (void)makeFontTextureWithDevice:(id)device { +// We are retrieving and uploading the font atlas as a 4-channels RGBA texture here. +// In theory we could call GetTexDataAsAlpha8() and upload a 1-channel texture to save on memory access bandwidth. +// However, using a shader designed for 1-channel texture would make it less obvious to use the ImTextureID facility to render users own textures. +// You can make that change in your implementation. +- (void)makeFontTextureWithDevice:(id)device +{ ImGuiIO &io = ImGui::GetIO(); unsigned char* pixels; int width, height; @@ -220,14 +233,18 @@ void ImGui_ImplMetal_DestroyDeviceObjects() self.fontTexture = texture; } -- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device { +- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device +{ NSTimeInterval now = [NSDate date].timeIntervalSince1970; // Purge old buffers that haven't been useful for a while - if (now - self.lastBufferCachePurge > 1.0) { + if (now - self.lastBufferCachePurge > 1.0) + { NSMutableArray *survivors = [NSMutableArray array]; - for (MetalBuffer *candidate in self.bufferCache) { - if (candidate.lastReuseTime > self.lastBufferCachePurge) { + for (MetalBuffer *candidate in self.bufferCache) + { + if (candidate.lastReuseTime > self.lastBufferCachePurge) + { [survivors addObject:candidate]; } } @@ -237,13 +254,12 @@ void ImGui_ImplMetal_DestroyDeviceObjects() // See if we have a buffer we can reuse MetalBuffer *bestCandidate = nil; - for (MetalBuffer *candidate in self.bufferCache) { - if (candidate.buffer.length >= length && (bestCandidate == nil || bestCandidate.lastReuseTime > candidate.lastReuseTime)) { + for (MetalBuffer *candidate in self.bufferCache) + if (candidate.buffer.length >= length && (bestCandidate == nil || bestCandidate.lastReuseTime > candidate.lastReuseTime)) bestCandidate = candidate; - } - } - if (bestCandidate != nil) { + if (bestCandidate != nil) + { [self.bufferCache removeObject:bestCandidate]; bestCandidate.lastReuseTime = now; return bestCandidate; @@ -254,16 +270,19 @@ void ImGui_ImplMetal_DestroyDeviceObjects() return [[MetalBuffer alloc] initWithBuffer:backing]; } -- (void)enqueueReusableBuffer:(MetalBuffer *)buffer { +- (void)enqueueReusableBuffer:(MetalBuffer *)buffer +{ [self.bufferCache addObject:buffer]; } -- (_Nullable id)renderPipelineStateForFrameAndDevice:(id)device { +- (_Nullable id)renderPipelineStateForFrameAndDevice:(id)device +{ // Try to retrieve a render pipeline state that is compatible with the framebuffer config for this frame // Thie hit rate for this cache should be very near 100%. id renderPipelineState = self.renderPipelineStateCache[self.framebufferDescriptor]; - if (renderPipelineState == nil) { + if (renderPipelineState == nil) + { // No luck; make a new render pipeline state renderPipelineState = [self _renderPipelineStateForFramebufferDescriptor:self.framebufferDescriptor device:device]; // Cache render pipeline state for later reuse @@ -314,7 +333,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() "}\n"; id library = [device newLibraryWithSource:shaderSource options:nil error:&error]; - if (library == nil) { + if (library == nil) + { NSLog(@"Error: failed to create Metal library: %@", error); return nil; } @@ -322,7 +342,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() id vertexFunction = [library newFunctionWithName:@"vertex_main"]; id fragmentFunction = [library newFunctionWithName:@"fragment_main"]; - if (vertexFunction == nil || fragmentFunction == nil) { + if (vertexFunction == nil || fragmentFunction == nil) + { NSLog(@"Error: failed to find Metal shader functions in library: %@", error); return nil; } @@ -358,14 +379,16 @@ void ImGui_ImplMetal_DestroyDeviceObjects() pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat; id renderPipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDescriptor error:&error]; - if (error != nil) { + if (error != nil) + { NSLog(@"Error: failed to create Metal pipeline state: %@", error); } return renderPipelineState; } -- (void)emptyRenderPipelineStateCache { +- (void)emptyRenderPipelineStateCache +{ [self.renderPipelineStateCache removeAllObjects]; } @@ -387,12 +410,15 @@ void ImGui_ImplMetal_DestroyDeviceObjects() // Setup viewport, orthographic projection matrix // Our visible imgui space lies from draw_data->DisplayPps (top left) to // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. - MTLViewport viewport = { .originX = 0.0, + MTLViewport viewport = + { + .originX = 0.0, .originY = 0.0, .width = double(fb_width), .height = double(fb_height), .znear = 0.0, - .zfar = 1.0 }; + .zfar = 1.0 + }; [commandEncoder setViewport:viewport]; float L = drawData->DisplayPos.x; float R = drawData->DisplayPos.x + drawData->DisplaySize.x; @@ -412,7 +438,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() size_t vertexBufferLength = 0; size_t indexBufferLength = 0; - for (int n = 0; n < drawData->CmdListsCount; n++) { + for (int n = 0; n < drawData->CmdListsCount; n++) + { const ImDrawList* cmd_list = drawData->CmdLists[n]; vertexBufferLength += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); indexBufferLength += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx); @@ -461,9 +488,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() // Bind texture, Draw - if (pcmd->TextureId != NULL) { + if (pcmd->TextureId != NULL) [commandEncoder setFragmentTexture:(__bridge id)(pcmd->TextureId) atIndex:0]; - } [commandEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle indexCount:pcmd->ElemCount indexType:sizeof(ImDrawIdx) == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 @@ -479,7 +505,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects() } __weak id weakSelf = self; - [commandBuffer addCompletedHandler:^(id) { + [commandBuffer addCompletedHandler:^(id) + { dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf enqueueReusableBuffer:vertexBuffer]; [weakSelf enqueueReusableBuffer:indexBuffer]; From c790723cfaa9f6cc32ded60cd30c9ec66cd14d50 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 8 Jul 2018 13:03:39 +0200 Subject: [PATCH 16/16] Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes related to the addition of IsItemDeactivated()). (#1875, #143) --- CHANGELOG.txt | 2 ++ imgui.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index aa7af662..b3471c38 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -44,6 +44,8 @@ Other Changes: - ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. - Window: Allow menu windows from ignoring the style.WindowMinSize values so short menus are not padded. (#1909) - Window: Added global io.OptResizeWindowsFromEdges option to enable resizing windows from their edges and from the lower-left corner. (#1495) + - Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes + related to the addition of IsItemDeactivated()). (#1875, #143) - Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] - Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. - Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) diff --git a/imgui.cpp b/imgui.cpp index 1ed13760..0915767f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2299,7 +2299,7 @@ void ImGui::MarkItemValueChanged(ImGuiID id) // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data. (void)id; // Avoid unused variable warnings when asserts are compiled out. ImGuiContext& g = *GImGui; - IM_ASSERT(g.ActiveId == id || g.ActiveId == 0); + IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive); g.ActiveIdValueChanged = true; }