Browse Source

Initial commit

Hongtae Kim 6 years ago
commit
c8a9dd6061

+ 63
- 0
.gitattributes View File

@@ -0,0 +1,63 @@
1
+###############################################################################
2
+# Set default behavior to automatically normalize line endings.
3
+###############################################################################
4
+* text=auto
5
+
6
+###############################################################################
7
+# Set default behavior for command prompt diff.
8
+#
9
+# This is need for earlier builds of msysgit that does not have it on by
10
+# default for csharp files.
11
+# Note: This is only used by command line
12
+###############################################################################
13
+#*.cs     diff=csharp
14
+
15
+###############################################################################
16
+# Set the merge driver for project and solution files
17
+#
18
+# Merging from the command prompt will add diff markers to the files if there
19
+# are conflicts (Merging from VS is not affected by the settings below, in VS
20
+# the diff markers are never inserted). Diff markers may cause the following 
21
+# file extensions to fail to load in VS. An alternative would be to treat
22
+# these files as binary and thus will always conflict and require user
23
+# intervention with every merge. To do so, just uncomment the entries below
24
+###############################################################################
25
+#*.sln       merge=binary
26
+#*.csproj    merge=binary
27
+#*.vbproj    merge=binary
28
+#*.vcxproj   merge=binary
29
+#*.vcproj    merge=binary
30
+#*.dbproj    merge=binary
31
+#*.fsproj    merge=binary
32
+#*.lsproj    merge=binary
33
+#*.wixproj   merge=binary
34
+#*.modelproj merge=binary
35
+#*.sqlproj   merge=binary
36
+#*.wwaproj   merge=binary
37
+
38
+###############################################################################
39
+# behavior for image files
40
+#
41
+# image files are treated as binary by default.
42
+###############################################################################
43
+#*.jpg   binary
44
+#*.png   binary
45
+#*.gif   binary
46
+
47
+###############################################################################
48
+# diff behavior for common document formats
49
+# 
50
+# Convert binary document formats to text before diffing them. This feature
51
+# is only available from the command line. Turn it on by uncommenting the 
52
+# entries below.
53
+###############################################################################
54
+#*.doc   diff=astextplain
55
+#*.DOC   diff=astextplain
56
+#*.docx  diff=astextplain
57
+#*.DOCX  diff=astextplain
58
+#*.dot   diff=astextplain
59
+#*.DOT   diff=astextplain
60
+#*.pdf   diff=astextplain
61
+#*.PDF   diff=astextplain
62
+#*.rtf   diff=astextplain
63
+#*.RTF   diff=astextplain

+ 73
- 0
.gitignore View File

@@ -0,0 +1,73 @@
1
+
2
+## Ignore Visual Studio temporary files, build results, and
3
+## files generated by popular Visual Studio add-ons.
4
+
5
+# User-specific files
6
+*.suo
7
+*.user
8
+*.sln.docstates
9
+
10
+# Visual C++ cache files
11
+ipch/
12
+*.aps
13
+*.ncb
14
+*.opensdf
15
+*.sdf
16
+*.cachefile
17
+
18
+# Visual Studio profiler
19
+*.psess
20
+*.vsp
21
+*.vspx
22
+
23
+# Backup & report files from converting an old project file to a newer
24
+# Visual Studio version. Backup files are not needed, because we have git ;-)
25
+_UpgradeReport_Files/
26
+Backup*/
27
+UpgradeLog*.XML
28
+UpgradeLog*.htm
29
+
30
+# Windows image file caches
31
+Thumbs.db
32
+ehthumbs.db
33
+
34
+# Folder config file
35
+Desktop.ini
36
+
37
+# Recycle Bin used on file shares
38
+$RECYCLE.BIN/
39
+
40
+
41
+# Mac desktop service store files
42
+.DS_Store
43
+
44
+# Xcode
45
+xcuserdata
46
+*.xccheckout
47
+*.moved-aside
48
+*.xcuserstate
49
+*.xcscmblueprint
50
+
51
+# Python
52
+__pycache__/
53
+
54
+# PyCharm files
55
+.idea/workspace.xml
56
+.idea/dictionaries/
57
+
58
+# Sphinx documentation
59
+docs/_build/
60
+
61
+# project settings
62
+Build/
63
+
64
+# Visual Studio 2015 and later
65
+*.VC.db
66
+*.VC.opendb
67
+**/.vs/
68
+
69
+# separated workspace file inside xcodeproj
70
+**/*.xcodeproj/project.xcworkspace
71
+
72
+# DKGL symbolic link
73
+DK

+ 17
- 0
Samples.props View File

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <ImportGroup Label="PropertySheets" />
4
+  <PropertyGroup Label="UserMacros" />
5
+  <PropertyGroup>
6
+    <OutDir>$(SolutionDir)Build\$(Platform)_$(Configuration)\</OutDir>
7
+    <IntDir>$(SolutionDir)Build\Intermediates\$(ProjectName)_$(Platform)_$(Configuration)\</IntDir>
8
+  </PropertyGroup>
9
+  <ItemDefinitionGroup>
10
+    <ClCompile>
11
+      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
12
+      <AdditionalIncludeDirectories>../../DK;../Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
13
+      <PreprocessorDefinitions>DKGL_STATIC=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
14
+    </ClCompile>
15
+  </ItemDefinitionGroup>
16
+  <ItemGroup />
17
+</Project>

+ 41
- 0
Samples.sln View File

@@ -0,0 +1,41 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio 15
4
+VisualStudioVersion = 15.0.28307.168
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Triangle", "Samples\Triangle\Triangle.vcxproj", "{35653A85-73BD-4392-A323-FB5C6DAE6F43}"
7
+EndProject
8
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DK_static", "..\DKGL2\DK\DK_static.vcxproj", "{C7312831-A3F6-4E7D-962B-6786972F0A6A}"
9
+EndProject
10
+Global
11
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
12
+		Debug|x64 = Debug|x64
13
+		Debug|x86 = Debug|x86
14
+		Release|x64 = Release|x64
15
+		Release|x86 = Release|x86
16
+	EndGlobalSection
17
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
18
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Debug|x64.ActiveCfg = Debug|x64
19
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Debug|x64.Build.0 = Debug|x64
20
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Debug|x86.ActiveCfg = Debug|Win32
21
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Debug|x86.Build.0 = Debug|Win32
22
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Release|x64.ActiveCfg = Release|x64
23
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Release|x64.Build.0 = Release|x64
24
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Release|x86.ActiveCfg = Release|Win32
25
+		{35653A85-73BD-4392-A323-FB5C6DAE6F43}.Release|x86.Build.0 = Release|Win32
26
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Debug|x64.ActiveCfg = Debug|x64
27
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Debug|x64.Build.0 = Debug|x64
28
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Debug|x86.ActiveCfg = Debug|Win32
29
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Debug|x86.Build.0 = Debug|Win32
30
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Release|x64.ActiveCfg = Release|x64
31
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Release|x64.Build.0 = Release|x64
32
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Release|x86.ActiveCfg = Release|Win32
33
+		{C7312831-A3F6-4E7D-962B-6786972F0A6A}.Release|x86.Build.0 = Release|Win32
34
+	EndGlobalSection
35
+	GlobalSection(SolutionProperties) = preSolution
36
+		HideSolutionNode = FALSE
37
+	EndGlobalSection
38
+	GlobalSection(ExtensibilityGlobals) = postSolution
39
+		SolutionGuid = {8A534515-F937-47D3-AB3E-9DF15A37214A}
40
+	EndGlobalSection
41
+EndGlobal

+ 30
- 0
Samples/Common/Win32/Resource.h View File

@@ -0,0 +1,30 @@
1
+//{{NO_DEPENDENCIES}}
2
+// Microsoft Visual C++ generated include file.
3
+// Used by SampleApp.rc
4
+
5
+#define IDS_APP_TITLE			103
6
+
7
+#define IDR_MAINFRAME			128
8
+#define IDD_SAMPLEAPP_DIALOG	102
9
+#define IDD_ABOUTBOX			103
10
+#define IDM_ABOUT				104
11
+#define IDM_EXIT				105
12
+#define IDI_SAMPLEAPP			107
13
+#define IDI_SMALL				108
14
+#define IDC_SAMPLEAPP			109
15
+#define IDC_MYICON				2
16
+#ifndef IDC_STATIC
17
+#define IDC_STATIC				-1
18
+#endif
19
+// Next default values for new objects
20
+//
21
+#ifdef APSTUDIO_INVOKED
22
+#ifndef APSTUDIO_READONLY_SYMBOLS
23
+
24
+#define _APS_NO_MFC					130
25
+#define _APS_NEXT_RESOURCE_VALUE	129
26
+#define _APS_NEXT_COMMAND_VALUE		32771
27
+#define _APS_NEXT_CONTROL_VALUE		1000
28
+#define _APS_NEXT_SYMED_VALUE		110
29
+#endif
30
+#endif

BIN
Samples/Common/Win32/SampleApp.ico View File


BIN
Samples/Common/Win32/SampleApp.rc View File


BIN
Samples/Common/Win32/small.ico View File


+ 21
- 0
Samples/Common/Win32/stdafx.h View File

@@ -0,0 +1,21 @@
1
+// stdafx.h : include file for standard system include files,
2
+// or project specific include files that are used frequently, but
3
+// are changed infrequently
4
+//
5
+
6
+#pragma once
7
+
8
+#include "targetver.h"
9
+
10
+#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
11
+// Windows Header Files
12
+#include <windows.h>
13
+
14
+// C RunTime Header Files
15
+#include <stdlib.h>
16
+#include <malloc.h>
17
+#include <memory.h>
18
+#include <tchar.h>
19
+
20
+
21
+// reference additional headers your program requires here

+ 8
- 0
Samples/Common/Win32/targetver.h View File

@@ -0,0 +1,8 @@
1
+#pragma once
2
+
3
+// Including SDKDDKVer.h defines the highest available Windows platform.
4
+
5
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7
+
8
+#include <SDKDDKVer.h>

+ 11
- 0
Samples/Common/app.cpp View File

@@ -0,0 +1,11 @@
1
+#include "app.h"
2
+
3
+SampleApp::SampleApp()
4
+{
5
+
6
+}
7
+
8
+SampleApp::~SampleApp()
9
+{
10
+
11
+}

+ 12
- 0
Samples/Common/app.h View File

@@ -0,0 +1,12 @@
1
+#ifdef _WIN32
2
+#include "Win32/stdafx.h"
3
+#endif
4
+#include <DK.h>
5
+
6
+
7
+class SampleApp : public DKApplication
8
+{
9
+public:
10
+	SampleApp();
11
+	~SampleApp();
12
+};

+ 59
- 0
Samples/Common/dkgl_new.cpp View File

@@ -0,0 +1,59 @@
1
+#include <DK.h>
2
+
3
+void* operator new (std::size_t size)
4
+{
5
+	if (size == 0)
6
+		size = 1;
7
+	void* p = nullptr;
8
+	while ((p = DKFoundation::DKMalloc(size)) == nullptr)
9
+	{
10
+		std::new_handler handler = std::get_new_handler();
11
+		if (handler)
12
+			handler();
13
+		else
14
+			throw std::bad_alloc();
15
+	}
16
+	return p;
17
+}
18
+
19
+void* operator new(size_t size, const std::nothrow_t&) noexcept
20
+{
21
+	void* p = nullptr;
22
+	try
23
+	{
24
+		p = ::operator new(size);
25
+	}
26
+	catch (...) {}
27
+	return p;
28
+}
29
+
30
+void* operator new[](std::size_t size)
31
+{
32
+	return ::operator new(size);
33
+}
34
+
35
+void* operator new[](size_t size, const std::nothrow_t& tag) noexcept
36
+{
37
+	return ::operator new(size, tag);
38
+}
39
+
40
+void operator delete (void* ptr) noexcept
41
+{
42
+	if (ptr)
43
+		DKFoundation::DKFree(ptr);
44
+}
45
+
46
+void operator delete (void* ptr, const std::nothrow_t&) noexcept
47
+{
48
+	::operator delete(ptr);
49
+}
50
+
51
+void operator delete[](void* ptr) noexcept
52
+{
53
+	::operator delete(ptr);
54
+}
55
+
56
+void operator delete[](void* ptr, const std::nothrow_t&) noexcept
57
+{
58
+	::operator delete(ptr);
59
+}

+ 17
- 0
Samples/Common/iOS/AppDelegate.h View File

@@ -0,0 +1,17 @@
1
+//
2
+//  AppDelegate.h
3
+//  iOS_Test
4
+//
5
+//  Created by tiff on 11/17/16.
6
+//  Copyright © 2016 icondb. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+
11
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
12
+
13
+@property (strong, nonatomic) UIWindow *window;
14
+
15
+
16
+@end
17
+

+ 73
- 0
Samples/Common/iOS/AppDelegate.m View File

@@ -0,0 +1,73 @@
1
+//
2
+//  AppDelegate.m
3
+//  iOS_Test
4
+//
5
+//  Created by tiff on 11/17/16.
6
+//  Copyright © 2016 icondb. All rights reserved.
7
+//
8
+
9
+#import "AppDelegate.h"
10
+
11
+@interface AppDelegate ()
12
+
13
+@end
14
+
15
+@implementation AppDelegate
16
+
17
+
18
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19
+	// Override point for customization after application launch.
20
+	NSLog(@"%s", __PRETTY_FUNCTION__);
21
+	return YES;
22
+}
23
+
24
+
25
+- (void)applicationWillResignActive:(UIApplication *)application {
26
+	// 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.
27
+	// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
28
+	NSLog(@"%s", __PRETTY_FUNCTION__);
29
+}
30
+
31
+
32
+- (void)applicationDidEnterBackground:(UIApplication *)application {
33
+	// 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.
34
+	// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
35
+	NSLog(@"%s", __PRETTY_FUNCTION__);
36
+}
37
+
38
+
39
+- (void)applicationWillEnterForeground:(UIApplication *)application {
40
+	// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
41
+	NSLog(@"%s", __PRETTY_FUNCTION__);
42
+}
43
+
44
+
45
+- (void)applicationDidBecomeActive:(UIApplication *)application {
46
+	// 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.
47
+	NSLog(@"%s", __PRETTY_FUNCTION__);
48
+}
49
+
50
+
51
+- (void)applicationWillTerminate:(UIApplication *)application {
52
+	// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
53
+	NSLog(@"%s", __PRETTY_FUNCTION__);
54
+}
55
+
56
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
57
+{
58
+	NSLog(@"%s", __PRETTY_FUNCTION__);
59
+}
60
+
61
+- (instancetype)init
62
+{
63
+	NSLog(@"%s", __PRETTY_FUNCTION__);
64
+	self = [super init];
65
+	return self;
66
+}
67
+
68
+- (void)dealloc
69
+{
70
+	NSLog(@"%s", __PRETTY_FUNCTION__);
71
+}
72
+
73
+@end

+ 93
- 0
Samples/Common/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json View File

@@ -0,0 +1,93 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "idiom" : "iphone",
5
+      "size" : "20x20",
6
+      "scale" : "2x"
7
+    },
8
+    {
9
+      "idiom" : "iphone",
10
+      "size" : "20x20",
11
+      "scale" : "3x"
12
+    },
13
+    {
14
+      "idiom" : "iphone",
15
+      "size" : "29x29",
16
+      "scale" : "2x"
17
+    },
18
+    {
19
+      "idiom" : "iphone",
20
+      "size" : "29x29",
21
+      "scale" : "3x"
22
+    },
23
+    {
24
+      "idiom" : "iphone",
25
+      "size" : "40x40",
26
+      "scale" : "2x"
27
+    },
28
+    {
29
+      "idiom" : "iphone",
30
+      "size" : "40x40",
31
+      "scale" : "3x"
32
+    },
33
+    {
34
+      "idiom" : "iphone",
35
+      "size" : "60x60",
36
+      "scale" : "2x"
37
+    },
38
+    {
39
+      "idiom" : "iphone",
40
+      "size" : "60x60",
41
+      "scale" : "3x"
42
+    },
43
+    {
44
+      "idiom" : "ipad",
45
+      "size" : "20x20",
46
+      "scale" : "1x"
47
+    },
48
+    {
49
+      "idiom" : "ipad",
50
+      "size" : "20x20",
51
+      "scale" : "2x"
52
+    },
53
+    {
54
+      "idiom" : "ipad",
55
+      "size" : "29x29",
56
+      "scale" : "1x"
57
+    },
58
+    {
59
+      "idiom" : "ipad",
60
+      "size" : "29x29",
61
+      "scale" : "2x"
62
+    },
63
+    {
64
+      "idiom" : "ipad",
65
+      "size" : "40x40",
66
+      "scale" : "1x"
67
+    },
68
+    {
69
+      "idiom" : "ipad",
70
+      "size" : "40x40",
71
+      "scale" : "2x"
72
+    },
73
+    {
74
+      "idiom" : "ipad",
75
+      "size" : "76x76",
76
+      "scale" : "1x"
77
+    },
78
+    {
79
+      "idiom" : "ipad",
80
+      "size" : "76x76",
81
+      "scale" : "2x"
82
+    },
83
+    {
84
+      "idiom" : "ipad",
85
+      "size" : "83.5x83.5",
86
+      "scale" : "2x"
87
+    }
88
+  ],
89
+  "info" : {
90
+    "version" : 1,
91
+    "author" : "xcode"
92
+  }
93
+}

+ 43
- 0
Samples/Common/iOS/Info.plist View File

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>CFBundleDevelopmentRegion</key>
6
+	<string>en</string>
7
+	<key>CFBundleExecutable</key>
8
+	<string>$(EXECUTABLE_NAME)</string>
9
+	<key>CFBundleIdentifier</key>
10
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+	<key>CFBundleInfoDictionaryVersion</key>
12
+	<string>6.0</string>
13
+	<key>CFBundleName</key>
14
+	<string>$(PRODUCT_NAME)</string>
15
+	<key>CFBundlePackageType</key>
16
+	<string>APPL</string>
17
+	<key>CFBundleShortVersionString</key>
18
+	<string>1.0</string>
19
+	<key>CFBundleVersion</key>
20
+	<string>1</string>
21
+	<key>LSRequiresIPhoneOS</key>
22
+	<true/>
23
+	<key>UILaunchStoryboardName</key>
24
+	<string>LaunchScreen</string>
25
+	<key>UIRequiredDeviceCapabilities</key>
26
+	<array>
27
+		<string>armv7</string>
28
+	</array>
29
+	<key>UISupportedInterfaceOrientations</key>
30
+	<array>
31
+		<string>UIInterfaceOrientationPortrait</string>
32
+		<string>UIInterfaceOrientationLandscapeLeft</string>
33
+		<string>UIInterfaceOrientationLandscapeRight</string>
34
+	</array>
35
+	<key>UISupportedInterfaceOrientations~ipad</key>
36
+	<array>
37
+		<string>UIInterfaceOrientationPortrait</string>
38
+		<string>UIInterfaceOrientationPortraitUpsideDown</string>
39
+		<string>UIInterfaceOrientationLandscapeLeft</string>
40
+		<string>UIInterfaceOrientationLandscapeRight</string>
41
+	</array>
42
+</dict>
43
+</plist>

+ 27
- 0
Samples/Common/iOS/LaunchScreen.storyboard View File

@@ -0,0 +1,27 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3
+    <dependencies>
4
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
5
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6
+    </dependencies>
7
+    <scenes>
8
+        <!--View Controller-->
9
+        <scene sceneID="EHf-IW-A2E">
10
+            <objects>
11
+                <viewController id="01J-lp-oVM" sceneMemberID="viewController">
12
+                    <layoutGuides>
13
+                        <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
14
+                        <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
15
+                    </layoutGuides>
16
+                    <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
17
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
18
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19
+                        <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
20
+                    </view>
21
+                </viewController>
22
+                <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
23
+            </objects>
24
+            <point key="canvasLocation" x="53" y="375"/>
25
+        </scene>
26
+    </scenes>
27
+</document>

+ 15
- 0
Samples/Common/macOS/AppDelegate.h View File

@@ -0,0 +1,15 @@
1
+//
2
+//  AppDelegate.h
3
+//  CocoaTest
4
+//
5
+//  Created by tiff on 11/17/16.
6
+//  Copyright © 2016 icondb. All rights reserved.
7
+//
8
+
9
+#import <Cocoa/Cocoa.h>
10
+
11
+@interface AppDelegate : NSObject <NSApplicationDelegate>
12
+
13
+
14
+@end
15
+

+ 41
- 0
Samples/Common/macOS/AppDelegate.m View File

@@ -0,0 +1,41 @@
1
+//
2
+//  AppDelegate.m
3
+//  CocoaTest
4
+//
5
+//  Created by tiff on 11/17/16.
6
+//  Copyright © 2016 icondb. All rights reserved.
7
+//
8
+
9
+#import "AppDelegate.h"
10
+
11
+@interface AppDelegate ()
12
+
13
+@property (weak) IBOutlet NSWindow *window;
14
+@end
15
+
16
+@implementation AppDelegate
17
+
18
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
19
+	// Insert code here to initialize your application
20
+	NSLog(@"%s", __PRETTY_FUNCTION__);
21
+}
22
+
23
+
24
+- (void)applicationWillTerminate:(NSNotification *)aNotification {
25
+	// Insert code here to tear down your application
26
+	NSLog(@"%s", __PRETTY_FUNCTION__);
27
+}
28
+
29
+- (instancetype)init
30
+{
31
+	NSLog(@"%s", __PRETTY_FUNCTION__);
32
+	self = [super init];
33
+	return self;
34
+}
35
+
36
+- (void)dealloc
37
+{
38
+	NSLog(@"%s", __PRETTY_FUNCTION__);
39
+}
40
+
41
+@end

+ 58
- 0
Samples/Common/macOS/Assets.xcassets/AppIcon.appiconset/Contents.json View File

@@ -0,0 +1,58 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "idiom" : "mac",
5
+      "size" : "16x16",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "mac",
10
+      "size" : "16x16",
11
+      "scale" : "2x"
12
+    },
13
+    {
14
+      "idiom" : "mac",
15
+      "size" : "32x32",
16
+      "scale" : "1x"
17
+    },
18
+    {
19
+      "idiom" : "mac",
20
+      "size" : "32x32",
21
+      "scale" : "2x"
22
+    },
23
+    {
24
+      "idiom" : "mac",
25
+      "size" : "128x128",
26
+      "scale" : "1x"
27
+    },
28
+    {
29
+      "idiom" : "mac",
30
+      "size" : "128x128",
31
+      "scale" : "2x"
32
+    },
33
+    {
34
+      "idiom" : "mac",
35
+      "size" : "256x256",
36
+      "scale" : "1x"
37
+    },
38
+    {
39
+      "idiom" : "mac",
40
+      "size" : "256x256",
41
+      "scale" : "2x"
42
+    },
43
+    {
44
+      "idiom" : "mac",
45
+      "size" : "512x512",
46
+      "scale" : "1x"
47
+    },
48
+    {
49
+      "idiom" : "mac",
50
+      "size" : "512x512",
51
+      "scale" : "2x"
52
+    }
53
+  ],
54
+  "info" : {
55
+    "version" : 1,
56
+    "author" : "xcode"
57
+  }
58
+}

+ 30
- 0
Samples/Common/macOS/Info.plist View File

@@ -0,0 +1,30 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>CFBundleDevelopmentRegion</key>
6
+	<string>en</string>
7
+	<key>CFBundleExecutable</key>
8
+	<string>$(EXECUTABLE_NAME)</string>
9
+	<key>CFBundleIconFile</key>
10
+	<string></string>
11
+	<key>CFBundleIdentifier</key>
12
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13
+	<key>CFBundleInfoDictionaryVersion</key>
14
+	<string>6.0</string>
15
+	<key>CFBundleName</key>
16
+	<string>$(PRODUCT_NAME)</string>
17
+	<key>CFBundlePackageType</key>
18
+	<string>APPL</string>
19
+	<key>CFBundleShortVersionString</key>
20
+	<string>1.0</string>
21
+	<key>CFBundleVersion</key>
22
+	<string>1</string>
23
+	<key>LSMinimumSystemVersion</key>
24
+	<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
25
+	<key>NSHumanReadableCopyright</key>
26
+	<string>Copyright © 2016 icondb. All rights reserved.</string>
27
+	<key>NSPrincipalClass</key>
28
+	<string>NSApplication</string>
29
+</dict>
30
+</plist>

+ 462
- 0
Samples/Triangle/Triangle.cpp View File

@@ -0,0 +1,462 @@
1
+
2
+#include "app.h"
3
+
4
+DKString ShaderStageNames(uint32_t s)
5
+{
6
+    DKArray<const char*> stages;
7
+    if (s & (uint32_t)DKShaderStage::Vertex)
8
+        stages.Add("Vertex");
9
+    if (s & (uint32_t)DKShaderStage::TessellationControl)
10
+        stages.Add("TessCtrl");
11
+    if (s & (uint32_t)DKShaderStage::TessellationEvaluation)
12
+        stages.Add("TessEval");
13
+    if (s & (uint32_t)DKShaderStage::Geometry)
14
+        stages.Add("Geometry");
15
+    if (s & (uint32_t)DKShaderStage::Fragment)
16
+        stages.Add("Fragment");
17
+    if (s & (uint32_t)DKShaderStage::Compute)
18
+        stages.Add("Compute");
19
+
20
+    if (stages.IsEmpty())
21
+        return "";
22
+
23
+    DKString str = stages.Value(0);
24
+    for (int i = 1; i < stages.Count(); ++i)
25
+        str += DKString::Format(", %ls", stages.Value(i));
26
+    return str;
27
+}
28
+
29
+const char* ShaderDataTypeStr(DKShaderDataType t)
30
+{
31
+    switch (t) {
32
+    case DKShaderDataType::Unknown:				return "Unknown";
33
+    case DKShaderDataType::None:				return "None";
34
+
35
+    case DKShaderDataType::Struct:				return "Struct";
36
+    case DKShaderDataType::Texture:				return "Texture";
37
+    case DKShaderDataType::Sampler:				return "Sampler";
38
+
39
+    case DKShaderDataType::Float:				return "Float";
40
+    case DKShaderDataType::Float2:				return "Float2";
41
+    case DKShaderDataType::Float3:				return "Float3";
42
+    case DKShaderDataType::Float4:				return "Float4";
43
+
44
+    case DKShaderDataType::Float2x2:			return "Float2x2";
45
+    case DKShaderDataType::Float2x3:			return "Float2x3";
46
+    case DKShaderDataType::Float2x4:			return "Float2x4";
47
+
48
+    case DKShaderDataType::Float3x2:			return "Float3x2";
49
+    case DKShaderDataType::Float3x3:			return "Float3x3";
50
+    case DKShaderDataType::Float3x4:			return "Float3x4";
51
+
52
+    case DKShaderDataType::Float4x2:			return "Float4x2";
53
+    case DKShaderDataType::Float4x3:			return "Float4x3";
54
+    case DKShaderDataType::Float4x4:			return "Float4x4";
55
+
56
+    case DKShaderDataType::Half:				return "Half";
57
+    case DKShaderDataType::Half2:				return "Half2";
58
+    case DKShaderDataType::Half3:				return "Half3";
59
+    case DKShaderDataType::Half4:				return "Half4";
60
+
61
+    case DKShaderDataType::Half2x2:				return "Half2x2";
62
+    case DKShaderDataType::Half2x3:				return "Half2x3";
63
+    case DKShaderDataType::Half2x4:				return "Half2x4";
64
+
65
+    case DKShaderDataType::Half3x2:				return "Half3x2";
66
+    case DKShaderDataType::Half3x3:				return "Half3x3";
67
+    case DKShaderDataType::Half3x4:				return "Half3x4";
68
+
69
+    case DKShaderDataType::Half4x2:				return "Half4x2";
70
+    case DKShaderDataType::Half4x3:				return "Half4x3";
71
+    case DKShaderDataType::Half4x4:				return "Half4x4";
72
+
73
+    case DKShaderDataType::Int:					return "Int";
74
+    case DKShaderDataType::Int2:				return "Int2";
75
+    case DKShaderDataType::Int3:				return "Int3";
76
+    case DKShaderDataType::Int4:				return "Int4";
77
+
78
+    case DKShaderDataType::UInt:				return "UInt";
79
+    case DKShaderDataType::UInt2:				return "UInt2";
80
+    case DKShaderDataType::UInt3:				return "UInt3";
81
+    case DKShaderDataType::UInt4:				return "UInt4";
82
+
83
+    case DKShaderDataType::Short:				return "Short";
84
+    case DKShaderDataType::Short2:				return "Short2";
85
+    case DKShaderDataType::Short3:				return "Short3";
86
+    case DKShaderDataType::Short4:				return "Short4";
87
+
88
+    case DKShaderDataType::UShort:				return "UShort";
89
+    case DKShaderDataType::UShort2:				return "UShort2";
90
+    case DKShaderDataType::UShort3:				return "UShort3";
91
+    case DKShaderDataType::UShort4:				return "UShort4";
92
+
93
+    case DKShaderDataType::Char:				return "Char";
94
+    case DKShaderDataType::Char2:				return "Char2";
95
+    case DKShaderDataType::Char3:				return "Char3";
96
+    case DKShaderDataType::Char4:				return "Char4";
97
+
98
+    case DKShaderDataType::UChar:				return "UChar";
99
+    case DKShaderDataType::UChar2:				return "UChar2";
100
+    case DKShaderDataType::UChar3:				return "UChar3";
101
+    case DKShaderDataType::UChar4:				return "UChar4";
102
+
103
+    case DKShaderDataType::Bool:				return "Bool";
104
+    case DKShaderDataType::Bool2:				return "Bool2";
105
+    case DKShaderDataType::Bool3:				return "Bool3";
106
+    case DKShaderDataType::Bool4:				return "Bool4";
107
+    }
108
+    return "Error";
109
+}
110
+
111
+void PrintShaderResource(const DKShaderResource& res, DKLogCategory c = DKLogCategory::Info)
112
+{
113
+    struct MemberPrinter
114
+    {
115
+        const DKShaderResource& res;
116
+        int indent;
117
+        DKLogCategory c;
118
+        void operator()(const DKShaderResourceStruct& str) const
119
+        {
120
+            DKString indentStr = "";
121
+            for (int i = 0; i < indent; ++i)
122
+            {
123
+                indentStr += "    ";
124
+            }
125
+            for (const DKShaderResourceStructMember& mem : str.members)
126
+            {
127
+                if (mem.count > 1)
128
+                {
129
+                    DKLog(c, " %ls+ %ls[%d] (%s, Offset: %d, Stride: %d)",
130
+                        (const wchar_t*)indentStr,
131
+                          (const wchar_t*)mem.name,
132
+                          mem.count,
133
+                          ShaderDataTypeStr(mem.dataType),
134
+                          mem.offset, mem.stride);
135
+
136
+                }
137
+                else
138
+                {
139
+                    DKLog(c, " %ls+ %ls (%s, Offset: %d)",
140
+                        (const wchar_t*)indentStr,
141
+                          (const wchar_t*)mem.name,
142
+                          ShaderDataTypeStr(mem.dataType),
143
+                          mem.offset);
144
+                }
145
+
146
+                auto* p = res.structTypeMemberMap.Find(mem.typeInfoKey);
147
+                if (p)
148
+                {
149
+                    DKLog(c, " %ls  Struct \"%ls\"",
150
+                        (const wchar_t*)indentStr,
151
+                          (const wchar_t*)mem.typeInfoKey);
152
+                    MemberPrinter{ res, indent + 1, c}.operator()(p->value);
153
+                }
154
+            }
155
+        }
156
+    };
157
+
158
+
159
+    if (res.count > 1)
160
+        DKLog(c, "ShaderResource: %ls[%d] (set=%d, binding=%d, stages=%ls)",
161
+        (const wchar_t*)res.name, res.count, res.set, res.binding,
162
+              (const wchar_t*)ShaderStageNames(res.stages));
163
+    else
164
+        DKLog(c, "ShaderResource: %ls (set=%d, binding=%d, stages=%ls)",
165
+        (const wchar_t*)res.name, res.set, res.binding,
166
+              (const wchar_t*)ShaderStageNames(res.stages));
167
+
168
+    const char* type = "Unknown (ERROR)";
169
+    switch (res.type)
170
+    {
171
+    case DKShaderResource::TypeBuffer: type = "Buffer"; break;
172
+    case DKShaderResource::TypeTexture:	type = "Texture"; break;
173
+    case DKShaderResource::TypeSampler:	type = "Sampler"; break;
174
+    case DKShaderResource::TypeTextureSampler: type = "SampledTexture"; break;
175
+    }
176
+    const char* access = "Unknown (ERROR)";
177
+    switch (res.access)
178
+    {
179
+    case DKShaderResource::AccessReadOnly:	access = "ReadOnly"; break;
180
+    case DKShaderResource::AccessWriteOnly:	access = "WriteOnly"; break;
181
+    case DKShaderResource::AccessReadWrite:	access = "ReadWrite"; break;
182
+    }
183
+
184
+    if (res.type == DKShaderResource::TypeBuffer)
185
+    {
186
+        DKLog(c, " Type:%s, Access:%s, Enabled:%d, Size:%d",
187
+              type,
188
+              access,
189
+              int(res.enabled),
190
+              res.typeInfo.buffer.size);
191
+    }
192
+    else
193
+    {
194
+        DKLog(c, " Type:%s, Access:%s, Enabled:%d",
195
+              type,
196
+              access,
197
+              int(res.enabled));
198
+    }
199
+    if (res.typeInfoKey.Length() > 0)
200
+        DKLog(c, " Struct \"%ls\"", (const wchar_t*)res.typeInfoKey);
201
+    if (res.type == DKShaderResource::TypeBuffer)
202
+    {
203
+        auto p = res.structTypeMemberMap.Find(res.typeInfoKey);
204
+        if (p)
205
+            MemberPrinter{ res, 1 , c}.operator()(p->value);
206
+    }
207
+}
208
+
209
+void PrintPipelineReflection(const DKPipelineReflection* reflection, DKLogCategory c = DKLogCategory::Error)
210
+{
211
+    DKLog(c, "=========================================================");
212
+    DKLog(c, "PipelineReflection.InputAttributes: %d", reflection->inputAttributes.Count());
213
+    for (int i = 0; i < reflection->inputAttributes.Count(); ++i)
214
+    {
215
+        const DKShaderAttribute& attr = reflection->inputAttributes.Value(i);
216
+        DKLog(c, "  [in] ShaderAttribute[%d]: \"%ls\" (location:%u)",
217
+              i, (const wchar_t*)attr.name, attr.location);
218
+    }
219
+    DKLog(c, "---------------------------------------------------------");
220
+    DKLog(c, "PipelineReflection.Resources: %d", reflection->resources.Count());
221
+    for (auto& arg : reflection->resources)
222
+        PrintShaderResource(arg, c);
223
+    for (int i = 0; i < reflection->pushConstantLayouts.Count(); ++i)
224
+    {
225
+        const DKShaderPushConstantLayout& layout = reflection->pushConstantLayouts.Value(i);
226
+        DKLog(c, " PushConstant:%d \"%ls\" (offset:%u, size:%u, stages:%ls)",
227
+              i, (const wchar_t*)layout.name, layout.offset, layout.size,
228
+              (const wchar_t*)ShaderStageNames(layout.stages));
229
+    }
230
+    DKLog(c, "=========================================================");
231
+}
232
+
233
+
234
+class TestApp1 : public DKApplication
235
+{
236
+	DKObject<DKWindow> window;
237
+	DKObject<DKThread> renderThread;
238
+	DKResourcePool resourcePool;
239
+
240
+	DKAtomicNumber32 runningRenderThread;
241
+public:
242
+	void RenderThread(void)
243
+	{
244
+		DKObject<DKData> vertData = resourcePool.LoadResourceData("triangle.vert.spv");
245
+		DKObject<DKData> fragData = resourcePool.LoadResourceData("triangle.frag.spv");
246
+		DKShader vertShader(vertData);
247
+		DKShader fragShader(fragData);
248
+
249
+		DKObject<DKGraphicsDevice> device = DKGraphicsDevice::SharedInstance();
250
+		DKObject<DKShaderModule> vertShaderModule = device->CreateShaderModule(&vertShader);
251
+		DKObject<DKShaderModule> fragShaderModule = device->CreateShaderModule(&fragShader);
252
+
253
+		DKObject<DKShaderFunction> vertShaderFunction = vertShaderModule->CreateFunction(vertShaderModule->FunctionNames().Value(0));
254
+		DKObject<DKShaderFunction> fragShaderFunction = fragShaderModule->CreateFunction(fragShaderModule->FunctionNames().Value(0));
255
+
256
+		DKObject<DKCommandQueue> queue = device->CreateCommandQueue(DKCommandQueue::Graphics);
257
+		DKObject<DKSwapChain> swapChain = queue->CreateSwapChain(window);
258
+
259
+		DKLog("VertexFunction.VertexAttributes: %d", vertShaderFunction->StageInputAttributes().Count());
260
+		for (int i = 0; i < vertShaderFunction->StageInputAttributes().Count(); ++i)
261
+		{
262
+			const DKShaderAttribute& attr = vertShaderFunction->StageInputAttributes().Value(i);
263
+			DKLog("  --> VertexAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
264
+		}
265
+
266
+		struct Vertex
267
+		{
268
+			DKVector3 position;
269
+			DKVector3 color;
270
+		};
271
+		DKArray<Vertex> vertexData =
272
+		{
273
+			{ {  0.0f, -0.5f, 0.0f },{ 1.0f, 1.0f, 1.0f } },
274
+			{ {  0.5f,  0.5f, 0.0f },{ 0.0f, 1.0f, 0.0f } },
275
+			{ { -0.5f,  0.5f, 0.0f },{ 0.0f, 0.0f, 1.0f } }
276
+		};
277
+		uint32_t vertexBufferSize = static_cast<uint32_t>(vertexData.Count()) * sizeof(Vertex);
278
+		DKArray<uint32_t> indexData = { 0, 1, 2 };
279
+		uint32_t indexBufferSize = indexData.Count() * sizeof(uint32_t);
280
+
281
+		DKObject<DKGpuBuffer> vertexBuffer = device->CreateBuffer(vertexBufferSize, DKGpuBuffer::StorageModeShared, DKCpuCacheModeDefault);
282
+		memcpy(vertexBuffer->Lock(), vertexData, vertexBufferSize);
283
+		vertexBuffer->Unlock();
284
+
285
+		DKObject<DKGpuBuffer> indexBuffer = device->CreateBuffer(indexBufferSize, DKGpuBuffer::StorageModeShared, DKCpuCacheModeDefault);
286
+		memcpy(indexBuffer->Lock(), indexData, indexBufferSize);
287
+		indexBuffer->Unlock();
288
+
289
+		DKRenderPipelineDescriptor pipelineDescriptor;
290
+		pipelineDescriptor.vertexFunction = vertShaderFunction;
291
+		pipelineDescriptor.fragmentFunction = fragShaderFunction;
292
+		pipelineDescriptor.colorAttachments.Resize(1);
293
+		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
294
+		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
295
+		pipelineDescriptor.vertexDescriptor.attributes = {
296
+			{ DKVertexFormat::Float3, 0, 0, 0 },
297
+			{ DKVertexFormat::Float3, sizeof(DKVector3), 0, 1 },
298
+		};
299
+		pipelineDescriptor.vertexDescriptor.layouts = {
300
+			{ DKVertexStepRate::Vertex, sizeof(Vertex), 0 },
301
+		};
302
+		pipelineDescriptor.primitiveTopology = DKPrimitiveType::Triangle;
303
+		pipelineDescriptor.frontFace = DKFrontFace::CCW;
304
+		pipelineDescriptor.triangleFillMode = DKTriangleFillMode::Fill;
305
+		pipelineDescriptor.depthClipMode = DKDepthClipMode::Clip;
306
+		pipelineDescriptor.cullMode = DKCullMode::None;
307
+		pipelineDescriptor.rasterizationEnabled = true;
308
+
309
+		DKPipelineReflection reflection;
310
+		DKObject<DKRenderPipelineState> pipelineState = device->CreateRenderPipeline(pipelineDescriptor, &reflection);
311
+		if (pipelineState)
312
+		{
313
+            PrintPipelineReflection(&reflection, DKLogCategory::Verbose);
314
+		}
315
+
316
+        DKShaderBindingSetLayout layout;
317
+        if (1)
318
+        {
319
+            DKShaderBinding binding = {
320
+                0,
321
+                DKShader::DescriptorTypeUniformBuffer,
322
+                1,
323
+                nullptr
324
+            };
325
+            layout.bindings.Add(binding);
326
+        }
327
+        DKObject<DKShaderBindingSet> bindSet = device->CreateShaderBindingSet(layout);
328
+        if (bindSet)
329
+        {
330
+            struct
331
+            {
332
+                DKMatrix4 projectionMatrix;
333
+                DKMatrix4 modelMatrix;
334
+                DKMatrix4 viewMatrix;
335
+            } ubo;
336
+
337
+            DKObject<DKGpuBuffer> uboBuffer = device->CreateBuffer(sizeof(ubo), DKGpuBuffer::StorageModeShared, DKCpuCacheModeDefault);
338
+            if (uboBuffer)
339
+            {
340
+                ubo.projectionMatrix = DKMatrix4::identity;
341
+                ubo.modelMatrix = DKMatrix4::identity;
342
+                ubo.viewMatrix = DKMatrix4::identity;
343
+
344
+                void* p = uboBuffer->Lock(0);
345
+                if (p)
346
+                {
347
+                    memcpy(p, &ubo, sizeof(ubo));
348
+                    uboBuffer->Unlock();
349
+
350
+                    bindSet->SetBuffer(0, uboBuffer, 0, sizeof(ubo));
351
+                }
352
+                else
353
+                {
354
+                    DKLogE("GpuBuffer Lock failed!");
355
+                }
356
+            }
357
+        }
358
+
359
+		DKTimer timer;
360
+		timer.Reset();
361
+
362
+		DKLog("Render thread begin");
363
+		while (!runningRenderThread.CompareAndSet(0, 0))
364
+		{
365
+			DKRenderPassDescriptor rpd = swapChain->CurrentRenderPassDescriptor();
366
+			double t = timer.Elapsed();
367
+			t = (cos(t) + 1.0) * 0.5;
368
+			rpd.colorAttachments.Value(0).clearColor = DKColor(t, 0.0, 0.0, 0.0);
369
+
370
+			DKObject<DKCommandBuffer> buffer = queue->CreateCommandBuffer();
371
+			DKObject<DKRenderCommandEncoder> encoder = buffer->CreateRenderCommandEncoder(rpd);
372
+			if (encoder)
373
+			{
374
+				encoder->SetRenderPipelineState(pipelineState);
375
+				encoder->SetVertexBuffer(vertexBuffer, 0, 0);
376
+				encoder->SetIndexBuffer(indexBuffer, 0, DKIndexType::UInt32);
377
+                encoder->SetResources(0, bindSet);
378
+				// draw scene!
379
+				encoder->DrawIndexed(indexData.Count(), 1, 0, 0, 1);
380
+				encoder->EndEncoding();
381
+				buffer->Commit();
382
+				swapChain->Present();
383
+			}
384
+			else
385
+			{
386
+			}
387
+			DKThread::Sleep(0.01);
388
+		}
389
+		DKLog("RenderThread terminating...");
390
+	}
391
+
392
+	void OnInitialize(void) override
393
+	{
394
+		DKLogD("%s", DKGL_FUNCTION_NAME);
395
+
396
+		DKString resPath = DefaultPath(SystemPath::AppResource);
397
+		resPath = resPath.FilePathStringByAppendingPath("Data");
398
+		DKLog("resPath: %ls", (const wchar_t*)resPath);
399
+		resourcePool.AddLocatorForPath(resPath);
400
+
401
+		window = DKWindow::Create("DefaultWindow");
402
+		window->SetOrigin({ 0, 0 });
403
+		window->Resize({ 320, 240 });
404
+		window->Activate();
405
+
406
+		window->AddEventHandler(this, DKFunction([this](const DKWindow::WindowEvent& e)
407
+		{
408
+			if (e.type == DKWindow::WindowEvent::WindowClosed)
409
+				DKApplication::Instance()->Terminate(0);
410
+		}), NULL, NULL);
411
+
412
+		runningRenderThread = 1;
413
+		renderThread = DKThread::Create(DKFunction(this, &TestApp1::RenderThread)->Invocation());
414
+	}
415
+	void OnTerminate(void) override
416
+	{
417
+		DKLogD("%s", DKGL_FUNCTION_NAME);
418
+
419
+		runningRenderThread = 0;
420
+		renderThread->WaitTerminate();
421
+		renderThread = NULL;
422
+		window = NULL;
423
+
424
+		DKLogI("Memory Pool Statistics");
425
+		size_t numBuckets = DKMemoryPoolNumberOfBuckets();
426
+		DKMemoryPoolBucketStatus* buckets = new DKMemoryPoolBucketStatus[numBuckets];
427
+		DKMemoryPoolQueryAllocationStatus(buckets, numBuckets);
428
+		size_t usedBytes = 0;
429
+		for (int i = 0; i < numBuckets; ++i)
430
+		{
431
+			if (buckets[i].totalChunks > 0)
432
+			{
433
+				DKLogI("--> %5lu:  %5lu/%5lu, usage: %.1f%%, used: %.1fKB, total: %.1fKB",
434
+					   buckets[i].chunkSize,
435
+					   buckets[i].usedChunks, buckets[i].totalChunks,
436
+					   double(buckets[i].usedChunks) / double(buckets[i].totalChunks) * 100.0,
437
+					   double(buckets[i].chunkSize * buckets[i].usedChunks) / 1024.0,
438
+					   double(buckets[i].chunkSize * buckets[i].totalChunks) / 1024.0
439
+				);
440
+				usedBytes += buckets[i].chunkSize * buckets[i].usedChunks;
441
+			}
442
+		}
443
+		DKLogI("MemoryPool Usage: %.1fMB / %.1fMB", double(usedBytes) / (1024 * 1024), double(DKMemoryPoolSize()) / (1024 * 1024));
444
+		delete[] buckets;
445
+	}
446
+};
447
+
448
+
449
+#ifdef _WIN32
450
+int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
451
+					  _In_opt_ HINSTANCE hPrevInstance,
452
+					  _In_ LPWSTR    lpCmdLine,
453
+					  _In_ int       nCmdShow)
454
+#else
455
+int main(int argc, const char * argv[])
456
+#endif
457
+{
458
+	TestApp1 app;
459
+	DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate");
460
+	DKPropertySet::SystemConfig().SetValue("GraphicsAPI", "Vulkan");
461
+	return app.Run();
462
+}

+ 175
- 0
Samples/Triangle/Triangle.vcxproj View File

@@ -0,0 +1,175 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <ItemGroup Label="ProjectConfigurations">
4
+    <ProjectConfiguration Include="Debug|Win32">
5
+      <Configuration>Debug</Configuration>
6
+      <Platform>Win32</Platform>
7
+    </ProjectConfiguration>
8
+    <ProjectConfiguration Include="Release|Win32">
9
+      <Configuration>Release</Configuration>
10
+      <Platform>Win32</Platform>
11
+    </ProjectConfiguration>
12
+    <ProjectConfiguration Include="Debug|x64">
13
+      <Configuration>Debug</Configuration>
14
+      <Platform>x64</Platform>
15
+    </ProjectConfiguration>
16
+    <ProjectConfiguration Include="Release|x64">
17
+      <Configuration>Release</Configuration>
18
+      <Platform>x64</Platform>
19
+    </ProjectConfiguration>
20
+  </ItemGroup>
21
+  <ItemGroup>
22
+    <ClInclude Include="..\Common\app.h" />
23
+    <ClInclude Include="..\Common\Win32\Resource.h" />
24
+    <ClInclude Include="..\Common\Win32\stdafx.h" />
25
+    <ClInclude Include="..\Common\Win32\targetver.h" />
26
+  </ItemGroup>
27
+  <ItemGroup>
28
+    <Image Include="..\Common\Win32\SampleApp.ico" />
29
+    <Image Include="..\Common\Win32\small.ico" />
30
+  </ItemGroup>
31
+  <ItemGroup>
32
+    <ResourceCompile Include="..\Common\Win32\SampleApp.rc" />
33
+  </ItemGroup>
34
+  <ItemGroup>
35
+    <ClCompile Include="..\Common\app.cpp" />
36
+    <ClCompile Include="..\Common\dkgl_new.cpp" />
37
+    <ClCompile Include="Triangle.cpp" />
38
+  </ItemGroup>
39
+  <ItemGroup>
40
+    <ProjectReference Include="..\..\..\DKGL2\DK\DK_static.vcxproj">
41
+      <Project>{c7312831-a3f6-4e7d-962b-6786972f0a6a}</Project>
42
+    </ProjectReference>
43
+  </ItemGroup>
44
+  <PropertyGroup Label="Globals">
45
+    <VCProjectVersion>15.0</VCProjectVersion>
46
+    <ProjectGuid>{35653A85-73BD-4392-A323-FB5C6DAE6F43}</ProjectGuid>
47
+    <Keyword>Win32Proj</Keyword>
48
+    <RootNamespace>Triangle</RootNamespace>
49
+    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
50
+  </PropertyGroup>
51
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
52
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
53
+    <ConfigurationType>Application</ConfigurationType>
54
+    <UseDebugLibraries>true</UseDebugLibraries>
55
+    <PlatformToolset>v141</PlatformToolset>
56
+    <CharacterSet>Unicode</CharacterSet>
57
+  </PropertyGroup>
58
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
59
+    <ConfigurationType>Application</ConfigurationType>
60
+    <UseDebugLibraries>false</UseDebugLibraries>
61
+    <PlatformToolset>v141</PlatformToolset>
62
+    <WholeProgramOptimization>true</WholeProgramOptimization>
63
+    <CharacterSet>Unicode</CharacterSet>
64
+  </PropertyGroup>
65
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
66
+    <ConfigurationType>Application</ConfigurationType>
67
+    <UseDebugLibraries>true</UseDebugLibraries>
68
+    <PlatformToolset>v141</PlatformToolset>
69
+    <CharacterSet>Unicode</CharacterSet>
70
+  </PropertyGroup>
71
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
72
+    <ConfigurationType>Application</ConfigurationType>
73
+    <UseDebugLibraries>false</UseDebugLibraries>
74
+    <PlatformToolset>v141</PlatformToolset>
75
+    <WholeProgramOptimization>true</WholeProgramOptimization>
76
+    <CharacterSet>Unicode</CharacterSet>
77
+  </PropertyGroup>
78
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
79
+  <ImportGroup Label="ExtensionSettings">
80
+  </ImportGroup>
81
+  <ImportGroup Label="Shared">
82
+  </ImportGroup>
83
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
84
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
85
+    <Import Project="..\..\Samples.props" />
86
+  </ImportGroup>
87
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
88
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
89
+    <Import Project="..\..\Samples.props" />
90
+  </ImportGroup>
91
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
92
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
93
+    <Import Project="..\..\Samples.props" />
94
+  </ImportGroup>
95
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
96
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
97
+    <Import Project="..\..\Samples.props" />
98
+  </ImportGroup>
99
+  <PropertyGroup Label="UserMacros" />
100
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
101
+    <LinkIncremental>true</LinkIncremental>
102
+  </PropertyGroup>
103
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
104
+    <LinkIncremental>true</LinkIncremental>
105
+  </PropertyGroup>
106
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
107
+    <LinkIncremental>false</LinkIncremental>
108
+  </PropertyGroup>
109
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
110
+    <LinkIncremental>false</LinkIncremental>
111
+  </PropertyGroup>
112
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
113
+    <ClCompile>
114
+      <WarningLevel>Level3</WarningLevel>
115
+      <Optimization>Disabled</Optimization>
116
+      <SDLCheck>true</SDLCheck>
117
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118
+      <ConformanceMode>true</ConformanceMode>
119
+    </ClCompile>
120
+    <Link>
121
+      <SubSystem>Windows</SubSystem>
122
+      <GenerateDebugInformation>true</GenerateDebugInformation>
123
+    </Link>
124
+  </ItemDefinitionGroup>
125
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
126
+    <ClCompile>
127
+      <WarningLevel>Level3</WarningLevel>
128
+      <Optimization>Disabled</Optimization>
129
+      <SDLCheck>true</SDLCheck>
130
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
131
+      <ConformanceMode>true</ConformanceMode>
132
+    </ClCompile>
133
+    <Link>
134
+      <SubSystem>Windows</SubSystem>
135
+      <GenerateDebugInformation>true</GenerateDebugInformation>
136
+    </Link>
137
+  </ItemDefinitionGroup>
138
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
139
+    <ClCompile>
140
+      <WarningLevel>Level3</WarningLevel>
141
+      <Optimization>MaxSpeed</Optimization>
142
+      <FunctionLevelLinking>true</FunctionLevelLinking>
143
+      <IntrinsicFunctions>true</IntrinsicFunctions>
144
+      <SDLCheck>true</SDLCheck>
145
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
146
+      <ConformanceMode>true</ConformanceMode>
147
+    </ClCompile>
148
+    <Link>
149
+      <SubSystem>Windows</SubSystem>
150
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
151
+      <OptimizeReferences>true</OptimizeReferences>
152
+      <GenerateDebugInformation>true</GenerateDebugInformation>
153
+    </Link>
154
+  </ItemDefinitionGroup>
155
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
156
+    <ClCompile>
157
+      <WarningLevel>Level3</WarningLevel>
158
+      <Optimization>MaxSpeed</Optimization>
159
+      <FunctionLevelLinking>true</FunctionLevelLinking>
160
+      <IntrinsicFunctions>true</IntrinsicFunctions>
161
+      <SDLCheck>true</SDLCheck>
162
+      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
163
+      <ConformanceMode>true</ConformanceMode>
164
+    </ClCompile>
165
+    <Link>
166
+      <SubSystem>Windows</SubSystem>
167
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
168
+      <OptimizeReferences>true</OptimizeReferences>
169
+      <GenerateDebugInformation>true</GenerateDebugInformation>
170
+    </Link>
171
+  </ItemDefinitionGroup>
172
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
173
+  <ImportGroup Label="ExtensionTargets">
174
+  </ImportGroup>
175
+</Project>

+ 52
- 0
Samples/Triangle/Triangle.vcxproj.filters View File

@@ -0,0 +1,52 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <ItemGroup>
4
+    <Filter Include="Source Files">
5
+      <UniqueIdentifier>{b5dc83ca-43a3-419d-ad59-977da7f4e408}</UniqueIdentifier>
6
+    </Filter>
7
+    <Filter Include="Common">
8
+      <UniqueIdentifier>{e5e3c3a7-54d9-4bd7-bb17-507ba17c21ff}</UniqueIdentifier>
9
+    </Filter>
10
+    <Filter Include="Common\Win32">
11
+      <UniqueIdentifier>{1e5cf7df-b5b9-4e2b-b747-f1a2d7810117}</UniqueIdentifier>
12
+    </Filter>
13
+  </ItemGroup>
14
+  <ItemGroup>
15
+    <ClInclude Include="..\Common\Win32\Resource.h">
16
+      <Filter>Common\Win32</Filter>
17
+    </ClInclude>
18
+    <ClInclude Include="..\Common\Win32\stdafx.h">
19
+      <Filter>Common\Win32</Filter>
20
+    </ClInclude>
21
+    <ClInclude Include="..\Common\Win32\targetver.h">
22
+      <Filter>Common\Win32</Filter>
23
+    </ClInclude>
24
+    <ClInclude Include="..\Common\app.h">
25
+      <Filter>Common</Filter>
26
+    </ClInclude>
27
+  </ItemGroup>
28
+  <ItemGroup>
29
+    <Image Include="..\Common\Win32\SampleApp.ico">
30
+      <Filter>Common\Win32</Filter>
31
+    </Image>
32
+    <Image Include="..\Common\Win32\small.ico">
33
+      <Filter>Common\Win32</Filter>
34
+    </Image>
35
+  </ItemGroup>
36
+  <ItemGroup>
37
+    <ResourceCompile Include="..\Common\Win32\SampleApp.rc">
38
+      <Filter>Common\Win32</Filter>
39
+    </ResourceCompile>
40
+  </ItemGroup>
41
+  <ItemGroup>
42
+    <ClCompile Include="Triangle.cpp">
43
+      <Filter>Source Files</Filter>
44
+    </ClCompile>
45
+    <ClCompile Include="..\Common\dkgl_new.cpp">
46
+      <Filter>Common</Filter>
47
+    </ClCompile>
48
+    <ClCompile Include="..\Common\app.cpp">
49
+      <Filter>Common</Filter>
50
+    </ClCompile>
51
+  </ItemGroup>
52
+</Project>