diff --git a/examples/example_apple_metal/Makefile b/examples/example_apple_metal/Makefile new file mode 100644 index 000000000..a15fc431c --- /dev/null +++ b/examples/example_apple_metal/Makefile @@ -0,0 +1,25 @@ +# Makefile for example_apple_metal, for macOS only (**not iOS**) +TARGET := example_apple_metal +CXX := clang++ +CXXFLAGS := -std=c++17 -ObjC++ -fobjc-arc -Wall -Wextra \ + -I../../ \ + -I../../backends +FRAMEWORKS := -framework AppKit -framework Metal -framework MetalKit -framework QuartzCore -framework GameController +IMGUI_SRC := ../../imgui.cpp ../../imgui_draw.cpp ../../imgui_demo.cpp \ + ../../imgui_tables.cpp ../../imgui_widgets.cpp +BACKENDS := ../../backends/imgui_impl_metal.mm ../../backends/imgui_impl_osx.mm +SRC := main.mm $(IMGUI_SRC) $(BACKENDS) + +.PHONY: all run clean + + +all: $(TARGET) + +$(TARGET): $(SRC) + $(CXX) $(CXXFLAGS) $^ $(FRAMEWORKS) -o $@ + +run: all + ./$(TARGET) + +clean: + rm -f $(TARGET) *.o diff --git a/examples/example_apple_metal/main.mm b/examples/example_apple_metal/main.mm index 830f1aed3..3ad7cff46 100644 --- a/examples/example_apple_metal/main.mm +++ b/examples/example_apple_metal/main.mm @@ -319,9 +319,20 @@ #if TARGET_OS_OSX -int main(int argc, const char * argv[]) +int main(int, const char**) { - return NSApplicationMain(argc, argv); + @autoreleasepool + { + [NSApplication sharedApplication]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + + AppDelegate *appDelegate = [[AppDelegate alloc] init]; // creates window + [NSApp setDelegate:appDelegate]; + + [NSApp activateIgnoringOtherApps:YES]; + [NSApp run]; + } + return 0; } #else diff --git a/examples/example_apple_opengl2/Makefile b/examples/example_apple_opengl2/Makefile new file mode 100644 index 000000000..02b4fba58 --- /dev/null +++ b/examples/example_apple_opengl2/Makefile @@ -0,0 +1,25 @@ +IMGUI_DIR = ../../ +CXX = clang++ +CXXFLAGS = -std=c++17 -ObjC++ -Wall -Wextra -g -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends +FRAMEWORKS = -framework Cocoa -framework OpenGL -framework GameController + +SOURCES = \ + main.mm \ + $(IMGUI_DIR)/backends/imgui_impl_osx.mm \ + $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp \ + $(IMGUI_DIR)/imgui.cpp \ + $(IMGUI_DIR)/imgui_draw.cpp \ + $(IMGUI_DIR)/imgui_demo.cpp \ + $(IMGUI_DIR)/imgui_tables.cpp \ + $(IMGUI_DIR)/imgui_widgets.cpp + +TARGET = imgui_example_apple_opengl2 + +all: $(TARGET) + +$(TARGET): $(SOURCES) + $(CXX) $(CXXFLAGS) $(SOURCES) -o imgui_example_apple_opengl2 $(FRAMEWORKS) + +clean: + rm -f $(TARGET) + rm -rf $(TARGET).dSYM