Swift
This plugin enables full access to Tellusim API from the Swift programming language on Apple platforms. The plugin also includes a comprehensive and user-friendly 3D math library for high-performance graphics development.
info
The plugins/binding/swift/include
directory contains ObjC-compatible headers.
The plugins/binding/swift/source
directory contains Swift sources and C++ to ObjC bindings.
The target ObjC library is libTellusimObjC
, which depends only on libTellusim
.
// create app
let app = App()
if !app.create(Platform.Any, UInt32(App.Values.Version.rawValue)) { return }
// create window
let window = Window(app.getPlatform(), app.getDevice())
if !window { return }
window.setSize(app.getWidth(), app.getHeight())
// set close callback
window.setCloseClickedCallback(Window.CloseClickedFunction({() in window.stop() }))
// set keyboard callback
window.setKeyboardPressedCallback(Window.KeyboardPressedFunction({ (key: UInt32, code: UInt32) in
if key == Window.Key.Esc.rawValue { window.stop() }
if key == Window.Key.F12.rawValue {
let image = Image()
if window.grab(image) && image.save("screenshot.png") {
Log.print(Log.Level.Message, "Screenshot\n")
}
}
}))
// create and show the window
let title = window.getPlatformName() + " Tellusim::Swift"
if !window.create(title) || !window.setHidden(false) { return }