Skip to content

Started work on windows #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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",
]
}
}
}
}
]
}

15 changes: 9 additions & 6 deletions Sources/app/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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) {



Expand All @@ -85,7 +88,7 @@ class App: Application {
needsDisplay()
}

override func mouseUp(_ point:Point) {
override func mouseUp(_ point:SwiftMath.Point) {

}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/app/Cube.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#elseif os(Android)
import Glibc
import ndk.GLES3
#elseif os(Windows)
import Win.GL
#endif


Expand Down
2 changes: 2 additions & 0 deletions Sources/app/Geometry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down
2 changes: 2 additions & 0 deletions Sources/app/Scene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#elseif os(Android)
import Glibc
import ndk.GLES3
#elseif os(Windows)
import Win.GL
#endif

import GLApplication
Expand Down
2 changes: 2 additions & 0 deletions Sources/app/Shader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#elseif os(Android)
import Glibc
import ndk.GLES3
#elseif os(Windows)
import Win.GL
#endif

public func isGLOn() -> Bool {
Expand Down
8 changes: 8 additions & 0 deletions Sources/app/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down