Skip to content

Commit

Permalink
Add CocoaPods support and fix up compiler errors from pod lib lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkolb committed Nov 26, 2017
1 parent 654917c commit 1f1fd94
Show file tree
Hide file tree
Showing 10 changed files with 915 additions and 10 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016-2017 David Turnbull

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions Math.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Pod::Spec.new do |s|
s.name = 'Math'
s.version = '2.1.0'
s.summary = 'SwiftGL Math Library'
s.description = <<-DESC
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.
DESC
s.homepage = 'https://github.com/SwiftGL/Math'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'AE9RB' => '[email protected]' }
s.source = { :git => 'https://github.com/SwiftGL/Math.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.source_files = 'Sources/SGLMath/*.swift'
end
25 changes: 25 additions & 0 deletions SGLMath.xcodeproj/SGLMathTests_Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
25 changes: 25 additions & 0 deletions SGLMath.xcodeproj/SGLMath_Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
708 changes: 708 additions & 0 deletions SGLMath.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions SGLMath.xcodeproj/xcshareddata/xcschemes/SGLMath-Package.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "9999"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SGLMath::SGLMath"
BuildableName = "SGLMath.framework"
BlueprintName = "SGLMath"
ReferencedContainer = "container:SGLMath.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SGLMath::Tools"
BuildableName = "Tools"
BlueprintName = "Tools"
ReferencedContainer = "container:SGLMath.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SGLMath::SGLMathTests"
BuildableName = "SGLMathTests.xctest"
BlueprintName = "SGLMathTests"
ReferencedContainer = "container:SGLMath.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SGLMath::SGLMath"
BuildableName = "SGLMath.framework"
BlueprintName = "SGLMath"
ReferencedContainer = "container:SGLMath.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
12 changes: 12 additions & 0 deletions SGLMath.xcodeproj/xcshareddata/xcschemes/xcschememanagement.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SGLMath-Package.xcscheme</key>
<dict></dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict></dict>
</dict>
</plist>
10 changes: 6 additions & 4 deletions Sources/SGLMath/Internal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public final class SGLMath {
// https://en.wikipedia.org/wiki/MurmurHash
public static func hash(_ nums: Int...) -> Int
{
if MemoryLayout<Int>.size == 8 { // 64 bit
#if !arch(i386) && !arch(arm)
// 64 bit
func rotl(_ x:UInt, _ r:UInt) -> UInt {
return (x << r) | (x >> (64 - r))
}
Expand Down Expand Up @@ -83,7 +84,8 @@ public final class SGLMath {
h1 = h1 &+ h2
h2 = h2 &+ h1
return Int(bitPattern: h1)
} else { // 32 bit
#else
// 32 bit
let c1:UInt = 0xcc9e2d51
let c2:UInt = 0x1b873593
var h1:UInt = c1 ^ UInt(nums.count)
Expand All @@ -103,7 +105,7 @@ public final class SGLMath {
h1 = h1 &* 0xc2b2ae35
h1 ^= h1 >> 16
return Int(bitPattern: h1)
}
#endif
}

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

}
}
11 changes: 5 additions & 6 deletions Sources/SGLMath/glsl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,11 @@ public func unpackSnorm2x16(_ p:UInt32) -> vec2 {
}

public func unpackUnorm4x8(_ p:UInt32) -> vec4 {
let r = vec4(
Float(p & 0xff),
Float(p >> 8 & 0xff),
Float(p >> 16 & 0xff),
Float(p >> 24 & 0xff)
)
let x = Float(p & 0xff)
let y = Float(p >> 8 & 0xff)
let z = Float(p >> 16 & 0xff)
let w = Float(p >> 24 & 0xff)
let r = vec4(x, y, z, w)
return r / 0xff
}

Expand Down

0 comments on commit 1f1fd94

Please sign in to comment.