-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into scroll-indicators-update
- Loading branch information
Showing
65 changed files
with
1,081 additions
and
563 deletions.
There are no files selected for viewing
Submodule SDL
updated
8 files
+3 −0 | .gitignore | |
+1 −1 | .gitmodules | |
+2 −2 | SDL2/src/custom/core/SDL_android.c | |
+0 −2 | external/SDL2/Xcode/SDL/SDL.xcodeproj/project.pbxproj | |
+1 −1 | external/sdl-gpu | |
+2 −0 | sdl-gpu/include/module.modulemap | |
+1 −0 | sdl-gpu/include/stb_image.h | |
+1 −0 | sdl-gpu/include/stb_image_write.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Data+fromRelativePathCrossPlatform.swift | ||
// UIKit | ||
// | ||
// Created by Geordie Jay on 01.11.18. | ||
// Copyright © 2018 flowkey. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Data { | ||
static func fromPathCrossPlatform(_ path: String) -> Data? { | ||
#if !os(Android) | ||
// At time of writing the SDL code below worked on all supported SDL platforms. | ||
// But, because of some crashes in `Data` we're doing an unneccessary copy there | ||
// which makes that version less efficient than Foundation's, so use it here instead: | ||
return try? Data(contentsOf: URL(fileURLWithPath: path)) | ||
#else | ||
guard let fileReader = SDL_RWFromFile(path, "r") else { | ||
return nil | ||
} | ||
|
||
defer { _ = fileReader.pointee.close(fileReader) } | ||
|
||
let fileSize = Int(fileReader.pointee.size(fileReader)) | ||
|
||
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: fileSize) | ||
defer { buffer.deallocate() } | ||
|
||
let bytesRead = fileReader.pointee.read(fileReader, buffer, 1, fileSize) | ||
if bytesRead == fileSize { | ||
return Data(bytes: buffer, count: fileSize) | ||
} else { | ||
return nil | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.