Skip to content

Commit 1f1fd94

Browse files
committed
Add CocoaPods support and fix up compiler errors from pod lib lint.
1 parent 654917c commit 1f1fd94

10 files changed

Lines changed: 915 additions & 10 deletions

File tree

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016-2017 David Turnbull
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Math.podspec

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'Math'
3+
s.version = '2.1.0'
4+
s.summary = 'SwiftGL Math Library'
5+
s.description = <<-DESC
6+
The SwiftGL math library is an implementation of every data type and operator in the GLSL 4.5 specification. It includes every operator in section 5.1 and every function in sections 8.1 to 8.7. You can even swizzle.
7+
DESC
8+
s.homepage = 'https://github.com/SwiftGL/Math'
9+
s.license = { :type => 'MIT', :file => 'LICENSE' }
10+
s.author = { 'AE9RB' => 'dturnbull@gmail.com' }
11+
s.source = { :git => 'https://github.com/SwiftGL/Math.git', :tag => s.version.to_s }
12+
s.ios.deployment_target = '9.0'
13+
s.osx.deployment_target = '10.11'
14+
s.source_files = 'Sources/SGLMath/*.swift'
15+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>CFBundleDevelopmentRegion</key>
5+
<string>en</string>
6+
<key>CFBundleExecutable</key>
7+
<string>$(EXECUTABLE_NAME)</string>
8+
<key>CFBundleIdentifier</key>
9+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
10+
<key>CFBundleInfoDictionaryVersion</key>
11+
<string>6.0</string>
12+
<key>CFBundleName</key>
13+
<string>$(PRODUCT_NAME)</string>
14+
<key>CFBundlePackageType</key>
15+
<string>BNDL</string>
16+
<key>CFBundleShortVersionString</key>
17+
<string>1.0</string>
18+
<key>CFBundleSignature</key>
19+
<string>????</string>
20+
<key>CFBundleVersion</key>
21+
<string>$(CURRENT_PROJECT_VERSION)</string>
22+
<key>NSPrincipalClass</key>
23+
<string></string>
24+
</dict>
25+
</plist>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>CFBundleDevelopmentRegion</key>
5+
<string>en</string>
6+
<key>CFBundleExecutable</key>
7+
<string>$(EXECUTABLE_NAME)</string>
8+
<key>CFBundleIdentifier</key>
9+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
10+
<key>CFBundleInfoDictionaryVersion</key>
11+
<string>6.0</string>
12+
<key>CFBundleName</key>
13+
<string>$(PRODUCT_NAME)</string>
14+
<key>CFBundlePackageType</key>
15+
<string>FMWK</string>
16+
<key>CFBundleShortVersionString</key>
17+
<string>1.0</string>
18+
<key>CFBundleSignature</key>
19+
<string>????</string>
20+
<key>CFBundleVersion</key>
21+
<string>$(CURRENT_PROJECT_VERSION)</string>
22+
<key>NSPrincipalClass</key>
23+
<string></string>
24+
</dict>
25+
</plist>

SGLMath.xcodeproj/project.pbxproj

Lines changed: 708 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "9999"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "SGLMath::SGLMath"
18+
BuildableName = "SGLMath.framework"
19+
BlueprintName = "SGLMath"
20+
ReferencedContainer = "container:SGLMath.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
<BuildActionEntry
24+
buildForTesting = "YES"
25+
buildForRunning = "YES"
26+
buildForProfiling = "YES"
27+
buildForArchiving = "YES"
28+
buildForAnalyzing = "YES">
29+
<BuildableReference
30+
BuildableIdentifier = "primary"
31+
BlueprintIdentifier = "SGLMath::Tools"
32+
BuildableName = "Tools"
33+
BlueprintName = "Tools"
34+
ReferencedContainer = "container:SGLMath.xcodeproj">
35+
</BuildableReference>
36+
</BuildActionEntry>
37+
</BuildActionEntries>
38+
</BuildAction>
39+
<TestAction
40+
buildConfiguration = "Debug"
41+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
language = ""
44+
shouldUseLaunchSchemeArgsEnv = "YES">
45+
<Testables>
46+
<TestableReference
47+
skipped = "NO">
48+
<BuildableReference
49+
BuildableIdentifier = "primary"
50+
BlueprintIdentifier = "SGLMath::SGLMathTests"
51+
BuildableName = "SGLMathTests.xctest"
52+
BlueprintName = "SGLMathTests"
53+
ReferencedContainer = "container:SGLMath.xcodeproj">
54+
</BuildableReference>
55+
</TestableReference>
56+
</Testables>
57+
<AdditionalOptions>
58+
</AdditionalOptions>
59+
</TestAction>
60+
<LaunchAction
61+
buildConfiguration = "Debug"
62+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
63+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
64+
language = ""
65+
launchStyle = "0"
66+
useCustomWorkingDirectory = "NO"
67+
ignoresPersistentStateOnLaunch = "NO"
68+
debugDocumentVersioning = "YES"
69+
debugServiceExtension = "internal"
70+
allowLocationSimulation = "YES">
71+
<MacroExpansion>
72+
<BuildableReference
73+
BuildableIdentifier = "primary"
74+
BlueprintIdentifier = "SGLMath::SGLMath"
75+
BuildableName = "SGLMath.framework"
76+
BlueprintName = "SGLMath"
77+
ReferencedContainer = "container:SGLMath.xcodeproj">
78+
</BuildableReference>
79+
</MacroExpansion>
80+
<AdditionalOptions>
81+
</AdditionalOptions>
82+
</LaunchAction>
83+
<ProfileAction
84+
buildConfiguration = "Release"
85+
shouldUseLaunchSchemeArgsEnv = "YES"
86+
savedToolIdentifier = ""
87+
useCustomWorkingDirectory = "NO"
88+
debugDocumentVersioning = "YES">
89+
</ProfileAction>
90+
<AnalyzeAction
91+
buildConfiguration = "Debug">
92+
</AnalyzeAction>
93+
<ArchiveAction
94+
buildConfiguration = "Release"
95+
revealArchiveInOrganizer = "YES">
96+
</ArchiveAction>
97+
</Scheme>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>SchemeUserState</key>
5+
<dict>
6+
<key>SGLMath-Package.xcscheme</key>
7+
<dict></dict>
8+
</dict>
9+
<key>SuppressBuildableAutocreation</key>
10+
<dict></dict>
11+
</dict>
12+
</plist>

Sources/SGLMath/Internal.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public final class SGLMath {
3636
// https://en.wikipedia.org/wiki/MurmurHash
3737
public static func hash(_ nums: Int...) -> Int
3838
{
39-
if MemoryLayout<Int>.size == 8 { // 64 bit
39+
#if !arch(i386) && !arch(arm)
40+
// 64 bit
4041
func rotl(_ x:UInt, _ r:UInt) -> UInt {
4142
return (x << r) | (x >> (64 - r))
4243
}
@@ -83,7 +84,8 @@ public final class SGLMath {
8384
h1 = h1 &+ h2
8485
h2 = h2 &+ h1
8586
return Int(bitPattern: h1)
86-
} else { // 32 bit
87+
#else
88+
// 32 bit
8789
let c1:UInt = 0xcc9e2d51
8890
let c2:UInt = 0x1b873593
8991
var h1:UInt = c1 ^ UInt(nums.count)
@@ -103,7 +105,7 @@ public final class SGLMath {
103105
h1 = h1 &* 0xc2b2ae35
104106
h1 ^= h1 >> 16
105107
return Int(bitPattern: h1)
106-
}
108+
#endif
107109
}
108110

109111
public static func SGLsin<T:FloatingPointArithmeticType>(_ angle:T) -> T {
@@ -452,4 +454,4 @@ public final class SGLMath {
452454
return sign + UInt16(exponent >> 13) + UInt16(significand >> 13)
453455
}
454456

455-
}
457+
}

Sources/SGLMath/glsl.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,11 @@ public func unpackSnorm2x16(_ p:UInt32) -> vec2 {
411411
}
412412

413413
public func unpackUnorm4x8(_ p:UInt32) -> vec4 {
414-
let r = vec4(
415-
Float(p & 0xff),
416-
Float(p >> 8 & 0xff),
417-
Float(p >> 16 & 0xff),
418-
Float(p >> 24 & 0xff)
419-
)
414+
let x = Float(p & 0xff)
415+
let y = Float(p >> 8 & 0xff)
416+
let z = Float(p >> 16 & 0xff)
417+
let w = Float(p >> 24 & 0xff)
418+
let r = vec4(x, y, z, w)
420419
return r / 0xff
421420
}
422421

0 commit comments

Comments
 (0)