diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5d8dece --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,158 @@ +{ + "version": "2.0.0", + "problemMatcher": { + "owner": "swift", + "fileLocation": "autoDetect", + "pattern": { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + }, + "tasks": [ + { + "label": "Build (Debug DWARF)", + "type": "shell", + "command": "swift", + "args": [ + "build", + "-c", "debug", + "-Xlinker", "-debug:dwarf", + ], + "group": { + "kind": "build", + "isDefault": true + }, + "windows": { + "options": { + "shell": { + "executable": "C:\\WINDOWS\\System32\\cmd.exe", + "args": [ + "/d", + "/c", + ] + } + } + } + }, + { + "label": "Build (Debug PDB)", + "type": "shell", + "command": "swift", + "args": [ + "build", + "-c", "debug", + "-Xswiftc", "-g", + "-Xswiftc", "-debug-info-format=codeview", + "-Xlinker", "-debug", + ], + "group": "build", + "windows": { + "options": { + "shell": { + "executable": "C:\\WINDOWS\\System32\\cmd.exe", + "args": [ + "/d", + "/c", + ] + } + } + } + }, + { + "label": "Build (Release)", + "type": "shell", + "command": "swift", + "args": [ + "build", + "-c", "release", + ], + "group": "build", + "windows": { + "options": { + "shell": { + "executable": "C:\\WINDOWS\\System32\\cmd.exe", + "args": [ + "/d", + "/c", + ] + } + } + } + }, + { + "label": "Test (Debug)", + "type": "shell", + "command": "swift", + "args": [ + "test", + "-c", "debug", + "-Xswiftc", "-DENABLE_TESTING", + ], + "group": { + "kind": "test", + "isDefault": true + }, + "windows": { + "options": { + "shell": { + "executable": "C:\\WINDOWS\\System32\\cmd.exe", + "args": [ + "/d", + "/c", + ] + } + } + }, + }, + { + "label": "Test (Coverage)", + "command": "swift", + "type": "shell", + "args": [ + "test", + "-c", "debug", + "-Xswiftc", "-DENABLE_TESTING", + "--enable-code-coverage", + ], + "group": "test", + "windows": { + "options": { + "shell": { + "executable": "C:\\WINDOWS\\System32\\cmd.exe", + "args": [ + "/d", + "/c", + ] + } + } + } + }, + { + "label": "Test (Release)", + "command": "swift", + "type": "shell", + "args": [ + "test", + "-c", "release", + "-Xswiftc", "-DENABLE_TESTING", + ], + "group": "test", + "windows": { + "options": { + "shell": { + "executable": "C:\\WINDOWS\\System32\\cmd.exe", + "args": [ + "/d", + "/c", + ] + } + } + } + } + ] + } + \ No newline at end of file diff --git a/Sources/app/App.swift b/Sources/app/App.swift index d6b5bdf..db85b61 100644 --- a/Sources/app/App.swift +++ b/Sources/app/App.swift @@ -15,12 +15,15 @@ #elseif os(Android) import Glibc import ndk.GLES3 +#elseif os(Windows) + import SwiftWin32 + import Win.GL #endif import SwiftMath import GLApplication -class App: Application { +class App: GLApplication.Application { // Scene variable, getter and setter. var scene:Scene { @@ -32,7 +35,7 @@ class App: Application { } } - var lastMousePoint:Point = Point() + var lastMousePoint = SwiftMath.Point() var pitch:Float = 0.0 var yaw:Float = 0.0 @@ -57,16 +60,16 @@ class App: Application { } - override func windowDidResize(_ size:Size) { + override func windowDidResize(_ size:SwiftMath.Size) { scene.size = size } // mouse events - override func mouseDown(_ point:Point, button:Int) { + override func mouseDown(_ point:SwiftMath.Point, button:Int) { lastMousePoint = point } - override func mouseMove(_ point:Point) { + override func mouseMove(_ point:SwiftMath.Point) { @@ -85,7 +88,7 @@ class App: Application { needsDisplay() } - override func mouseUp(_ point:Point) { + override func mouseUp(_ point:SwiftMath.Point) { } } diff --git a/Sources/app/Cube.swift b/Sources/app/Cube.swift index 44049ab..1607d3b 100644 --- a/Sources/app/Cube.swift +++ b/Sources/app/Cube.swift @@ -17,6 +17,8 @@ #elseif os(Android) import Glibc import ndk.GLES3 +#elseif os(Windows) + import Win.GL #endif diff --git a/Sources/app/Geometry.swift b/Sources/app/Geometry.swift index b6e6c5a..116616d 100644 --- a/Sources/app/Geometry.swift +++ b/Sources/app/Geometry.swift @@ -18,6 +18,8 @@ import OpenGLES #elseif os(Android) import Glibc import ndk.GLES3 +#elseif os(Windows) +import Win.GL #endif func BUFFER_OFFSET(_ i: Int) -> UnsafeRawPointer? { diff --git a/Sources/app/Scene.swift b/Sources/app/Scene.swift index 51926b0..43cd7e2 100644 --- a/Sources/app/Scene.swift +++ b/Sources/app/Scene.swift @@ -19,6 +19,8 @@ #elseif os(Android) import Glibc import ndk.GLES3 +#elseif os(Windows) + import Win.GL #endif import GLApplication diff --git a/Sources/app/Shader.swift b/Sources/app/Shader.swift index 0b17309..8a065ce 100644 --- a/Sources/app/Shader.swift +++ b/Sources/app/Shader.swift @@ -18,6 +18,8 @@ #elseif os(Android) import Glibc import ndk.GLES3 +#elseif os(Windows) + import Win.GL #endif public func isGLOn() -> Bool { diff --git a/Sources/app/main.swift b/Sources/app/main.swift index 0c8e85b..2701b25 100644 --- a/Sources/app/main.swift +++ b/Sources/app/main.swift @@ -25,6 +25,14 @@ func main() { } main() +#elseif os(Windows) + +import SwiftWin32 +ApplicationMain(CommandLine.argc, + CommandLine.unsafeArgv, + nil, + String(describing: String(reflecting: App.self))) + #elseif os(iOS) import UIKit UIApplicationMain( CommandLine.argc,