30 lines
860 B
Swift
30 lines
860 B
Swift
import CSDL2
|
|
|
|
public class Renderer {
|
|
public var handle: OpaquePointer
|
|
|
|
public init(_ window: Window) throws {
|
|
handle = try SDL_CreateRenderer(window.handle, -1, SDL_RENDERER_ACCELERATED.rawValue).sdlThrow(type: type(of: self))
|
|
}
|
|
|
|
deinit {
|
|
SDL_DestroyRenderer(handle)
|
|
}
|
|
|
|
public func setScale(x: Float, y: Float) throws {
|
|
try SDL_RenderSetScale(handle, x, y).sdlThrow(type: type(of: self))
|
|
}
|
|
|
|
public func clear() throws {
|
|
try SDL_RenderClear(handle).sdlThrow(type: type(of: self))
|
|
}
|
|
|
|
public func copy(_ texture: Texture, srcRect: UnsafePointer<SDL_Rect>! = nil, dstRect: UnsafePointer<SDL_Rect>! = nil) throws {
|
|
try SDL_RenderCopy(handle, texture.handle, srcRect, dstRect).sdlThrow(type: type(of: self))
|
|
}
|
|
|
|
public func present() {
|
|
SDL_RenderPresent(handle)
|
|
}
|
|
}
|