Kaynağa Gözat

Examples: Apple: Amend build scripts and gitignore, fix misc OSX warnings. (#8637)

# Conflicts:
#	backends/imgui_impl_metal.mm
ocornut 3 ay önce
ebeveyn
işleme
b5a73033ab

+ 3 - 1
.gitignore

@@ -32,9 +32,10 @@ JSON/
 ## Commonly used CMake directories
 build*/
 
-## Xcode artifacts
+## Xcode & macOS artifacts
 project.xcworkspace
 xcuserdata
+examples/*/*.dSYM
 
 ## Emscripten artifacts
 examples/*.o.tmp
@@ -54,6 +55,7 @@ cmake-build-*
 
 ## Unix executables from our example Makefiles
 examples/example_apple_metal/example_apple_metal
+examples/example_apple_opengl2/example_apple_opengl2
 examples/example_glfw_metal/example_glfw_metal
 examples/example_glfw_opengl2/example_glfw_opengl2
 examples/example_glfw_opengl3/example_glfw_opengl3

+ 1 - 1
backends/imgui_impl_osx.mm

@@ -477,7 +477,7 @@ bool ImGui_ImplOSX_Init(NSView* view)
     [view addSubview:bd->KeyEventResponder];
     ImGui_ImplOSX_AddTrackingArea(view);
 
-    platform_io.Platform_SetImeDataFn = [](ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
+    platform_io.Platform_SetImeDataFn = [](ImGuiContext*, ImGuiViewport*, ImGuiPlatformImeData* data) -> void
     {
         ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
         if (data->WantVisible)

+ 1 - 0
docs/CHANGELOG.txt

@@ -130,6 +130,7 @@ Other changes:
 - Backends: Vulkan: fixed validation errors in window create/resize helpers used by examples
   and by multi-viewports implementation, which would typically trigger errors while detaching
   secondary viewports. (#8600, #8176) [@ChrisTom-94]
+- Examples: Apple+Metal, Apple+OpenGL: add Makefile (CLion opens them nicely). (#8637) [@pthom]
 - Examples: DirectX12+Win32: also test for IsIconic() for sleeping since we don't seem to
   get a DXGI_STATUS_OCCLUDED signal when minimized. (#8603) [@dooann]
 

+ 12 - 16
examples/example_apple_metal/Makefile

@@ -1,25 +1,21 @@
 # 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)
+CXX = clang++
+EXE = example_apple_metal
+IMGUI_DIR = ../../
+SOURCES = main.mm
+SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
+SOURCES += $(IMGUI_DIR)/backends/imgui_impl_osx.mm $(IMGUI_DIR)/backends/imgui_impl_metal.mm
 
-.PHONY: all run clean
+CXXFLAGS = -std=c++11 -ObjC++ -fobjc-arc -Wall -Wextra -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
+FRAMEWORKS = -framework AppKit -framework Metal -framework MetalKit -framework QuartzCore -framework GameController
 
+all: $(EXE)
 
-all: $(TARGET)
-
-$(TARGET): $(SRC)
+$(EXE): $(SOURCES)
 	$(CXX) $(CXXFLAGS) $^ $(FRAMEWORKS) -o $@
 
 run: all
-	./$(TARGET)
+	./$(EXE)
 
 clean:
-	rm -f $(TARGET) *.o
+	rm -f $(EXE) *.o

+ 14 - 18
examples/example_apple_opengl2/Makefile

@@ -1,25 +1,21 @@
-IMGUI_DIR = ../../
+# Makefile for example_apple_metal, for macOS only (**not iOS**)
 CXX = clang++
-CXXFLAGS = -std=c++17 -ObjC++ -Wall -Wextra -g -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
-FRAMEWORKS = -framework Cocoa -framework OpenGL -framework GameController
+EXE = example_apple_opengl2
+IMGUI_DIR = ../../
+SOURCES = main.mm
+SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
+SOURCES += $(IMGUI_DIR)/backends/imgui_impl_osx.mm $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp
 
-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
+CXXFLAGS = -std=c++11 -ObjC++ -fobjc-arc -Wall -Wextra -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
+FRAMEWORKS = -framework Cocoa -framework OpenGL -framework GameController
 
-TARGET = imgui_example_apple_opengl2
+all: $(EXE)
 
-all: $(TARGET)
+$(EXE): $(SOURCES)
+	$(CXX) $(CXXFLAGS) $(SOURCES) -o $(EXE) $(FRAMEWORKS)
 
-$(TARGET): $(SOURCES)
-	$(CXX) $(CXXFLAGS) $(SOURCES) -o imgui_example_apple_opengl2 $(FRAMEWORKS)
+run: all
+	./$(EXE)
 
 clean:
-	rm -f $(TARGET)
-	rm -rf $(TARGET).dSYM
+	rm -f $(EXE) *.o