summaryrefslogtreecommitdiffstats
path: root/Common/NativeApp
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-12-26 22:01:16 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-12-26 22:01:16 +0000
commit47a09a94bec2d5f6a7f732b57f39348a36443d3e (patch)
tree0c8cc000b23ab1cc2df4c7017a7047b95d31ebbe /Common/NativeApp
parentFixed swap chain size scaling on Mac (diff)
downloadDiligentEngine-47a09a94bec2d5f6a7f732b57f39348a36443d3e.tar.gz
DiligentEngine-47a09a94bec2d5f6a7f732b57f39348a36443d3e.zip
Added API selection on Mac
Diffstat (limited to 'Common/NativeApp')
-rw-r--r--Common/NativeApp/Apple/Data/OSX/Base.lproj/Main.storyboard49
-rw-r--r--Common/NativeApp/Apple/Source/Classes/OSX/AppDelegate.m20
-rw-r--r--Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.h30
-rw-r--r--Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.mm78
-rw-r--r--Common/NativeApp/CMakeLists.txt4
5 files changed, 158 insertions, 23 deletions
diff --git a/Common/NativeApp/Apple/Data/OSX/Base.lproj/Main.storyboard b/Common/NativeApp/Apple/Data/OSX/Base.lproj/Main.storyboard
index 7d318c2..d01e912 100644
--- a/Common/NativeApp/Apple/Data/OSX/Base.lproj/Main.storyboard
+++ b/Common/NativeApp/Apple/Data/OSX/Base.lproj/Main.storyboard
@@ -3,6 +3,7 @@
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ <capability name="system font weights other than Regular or Bold" minToolsVersion="7.0"/>
</dependencies>
<scenes>
<!--Application-->
@@ -126,7 +127,7 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" customClass="WindowController" sceneMemberID="viewController">
- <window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
+ <window key="window" title="Diligent Engine" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
@@ -137,7 +138,7 @@
</connections>
</window>
<connections>
- <segue destination="VWH-wR-9QD" kind="relationship" relationship="window.shadowedContentViewController" id="emZ-jG-HLe"/>
+ <segue destination="lYj-9Z-eqp" kind="relationship" relationship="window.shadowedContentViewController" id="aXj-gz-HUq"/>
</connections>
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
@@ -169,5 +170,49 @@
<customObject id="CmR-bq-0b7" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
</scene>
+ <!--Mode Selection View Controller-->
+ <scene sceneID="rTr-Qo-t8b">
+ <objects>
+ <viewController id="lYj-9Z-eqp" customClass="ModeSelectionViewController" sceneMemberID="viewController">
+ <view key="view" id="SPq-vc-rSb">
+ <rect key="frame" x="0.0" y="0.0" width="350" height="253"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FNk-f7-1ho">
+ <rect key="frame" x="129" y="60" width="92" height="43"/>
+ <constraints>
+ <constraint firstAttribute="height" constant="32" id="xCk-Gq-MrX"/>
+ </constraints>
+ <buttonCell key="cell" type="push" title="Vulkan" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Nsa-CK-D42">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="systemSemibold" size="16"/>
+ </buttonCell>
+ <connections>
+ <action selector="goVulkan:" target="lYj-9Z-eqp" id="bnQ-Bu-l9T"/>
+ </connections>
+ </button>
+ <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zva-9q-Xj2">
+ <rect key="frame" x="124" y="143" width="102" height="32"/>
+ <buttonCell key="cell" type="push" title="OpenGL" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="xhq-D1-XDx">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="systemSemibold" size="16"/>
+ </buttonCell>
+ <connections>
+ <action selector="goOpenGL:" target="lYj-9Z-eqp" id="eDU-k4-Qyl"/>
+ </connections>
+ </button>
+ </subviews>
+ <constraints>
+ <constraint firstItem="zva-9q-Xj2" firstAttribute="centerX" secondItem="SPq-vc-rSb" secondAttribute="centerX" id="6Je-LA-wKz"/>
+ <constraint firstItem="zva-9q-Xj2" firstAttribute="top" secondItem="SPq-vc-rSb" secondAttribute="top" constant="82" id="RKY-jP-kug"/>
+ <constraint firstItem="zva-9q-Xj2" firstAttribute="centerX" secondItem="FNk-f7-1ho" secondAttribute="centerX" id="bGn-rh-tGz"/>
+ <constraint firstItem="FNk-f7-1ho" firstAttribute="top" secondItem="zva-9q-Xj2" secondAttribute="bottom" constant="51" id="sTn-Gq-zp6"/>
+ </constraints>
+ </view>
+ </viewController>
+ <customObject id="IGK-9x-tXY" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="220" y="828.5"/>
+ </scene>
</scenes>
</document>
diff --git a/Common/NativeApp/Apple/Source/Classes/OSX/AppDelegate.m b/Common/NativeApp/Apple/Source/Classes/OSX/AppDelegate.m
index 4e8e0f9..fd52cc4 100644
--- a/Common/NativeApp/Apple/Source/Classes/OSX/AppDelegate.m
+++ b/Common/NativeApp/Apple/Source/Classes/OSX/AppDelegate.m
@@ -7,8 +7,6 @@
*/
#import "AppDelegate.h"
-#import "GLViewController.h"
-#import "MetalViewController.h"
@interface AppDelegate ()
@@ -18,25 +16,7 @@
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSWindow* mainWindow = [[NSApplication sharedApplication]mainWindow];
-
- NSString* error = [[mainWindow contentViewController] getError];
- if(error != nil)
- {
- NSAlert *alert = [[NSAlert alloc] init];
- [alert addButtonWithTitle:@"OK"];
- [alert setMessageText:@"Failed to start the application"];
- [alert setInformativeText:error];
- [alert setAlertStyle:NSAlertStyleCritical];
- [alert runModal];
- [NSApp terminate:self];
- }
-
[mainWindow setAcceptsMouseMovedEvents:YES];
- NSString *name = [[mainWindow contentViewController] getAppName];
- if(name != nil)
- {
- [mainWindow setTitle:name];
- }
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
diff --git a/Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.h b/Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.h
new file mode 100644
index 0000000..3c84ecb
--- /dev/null
+++ b/Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.h
@@ -0,0 +1,30 @@
+/* Copyright 2015-2018 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+
+#import <AppKit/AppKit.h>
+
+@interface ModeSelectionViewController : NSViewController
+{
+}
+@end
diff --git a/Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.mm b/Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.mm
new file mode 100644
index 0000000..eed6ca5
--- /dev/null
+++ b/Common/NativeApp/Apple/Source/Classes/OSX/ModeSelectionViewController.mm
@@ -0,0 +1,78 @@
+/* Copyright 2015-2018 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#import "ModeSelectionViewController.h"
+#import "GLViewController.h"
+#import "MetalViewController.h"
+
+@implementation ModeSelectionViewController
+{
+}
+
+- (void) setWindowTitle:(NSString*) title
+{
+ NSWindow* mainWindow = [[NSApplication sharedApplication]mainWindow];
+ [mainWindow setTitle:title];
+}
+
+- (void) terminateApp:(NSString*) error
+{
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:@"OK"];
+ [alert setMessageText:@"Failed to start the application"];
+ [alert setInformativeText:error];
+ [alert setAlertStyle:NSAlertStyleCritical];
+ [alert runModal];
+ [NSApp terminate:self];
+}
+
+- (IBAction)goOpenGL:(id)sender
+{
+ GLViewController* glViewController = [self.storyboard instantiateControllerWithIdentifier:@"GLViewControllerID"];
+ NSString* error = [glViewController getError];
+ if(error != nil)
+ {
+ [self terminateApp:error];
+ }
+
+ self.view.window.contentViewController = glViewController;
+
+ NSString* name = [glViewController getAppName];
+ [self setWindowTitle:name];
+}
+
+- (IBAction)goVulkan:(id)sender
+{
+ MetalViewController* metalViewController = [self.storyboard instantiateControllerWithIdentifier:@"MetalViewControllerID"];
+ NSString* error = [metalViewController getError];
+ if(error != nil)
+ {
+ [self terminateApp:error];
+ }
+
+ self.view.window.contentViewController = metalViewController;
+ NSString* name = [metalViewController getAppName];
+ [self setWindowTitle:name];
+}
+
+@end
diff --git a/Common/NativeApp/CMakeLists.txt b/Common/NativeApp/CMakeLists.txt
index d475f2e..a1101ed 100644
--- a/Common/NativeApp/CMakeLists.txt
+++ b/Common/NativeApp/CMakeLists.txt
@@ -121,7 +121,7 @@ elseif(PLATFORM_LINUX)
add_linux_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
-
+
elseif(PLATFORM_MACOS)
set(SOURCE
@@ -145,6 +145,7 @@ elseif(PLATFORM_MACOS)
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/GLViewController.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/MTKRenderer.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ViewControllerBase.mm
+ ${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ModeSelectionViewController.mm
)
set_source_files_properties(${APPLE_SOURCE} PROPERTIES
COMPILE_FLAGS "-x objective-c++"
@@ -160,6 +161,7 @@ elseif(PLATFORM_MACOS)
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/GLViewController.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/MTKRenderer.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ViewControllerBase.h
+ ${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ModeSelectionViewController.h
)
set(APPLE_RESOURCES