To use, include dependency in your
let package = Package( dependencies: [ .Package(url: "https://github.com/SwiftGL/OpenGL.git", majorVersion: 3) ] )
import SGLOpenGL in your swift file.
You can't use OpenGL until you can call its functions. The SwiftGL OpenGL loader imports all the functions up to OpenGL 4.5. Platform differences are abstracted away. There's nothing to initialize and no C code. 100% easy. 100% Swift.
If you've used OpenGL in Swift before you probably used commands like this.
glDepthMask(GLboolean(GL_FALSE)) glClear(GLbitfield(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_WRAP_S), GLint(GL_MIRRORED_REPEAT))
You have to cast everything. Not fun. This is a result of how Swift translates C header files. Because SwiftGL loader is specialized for Swift, all that casting is a thing of the past.
glDepthMask(false) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT)
Every OpenGL command is also available with argument labels. This may make your code easier to read. It also makes it difficult to put values in the wrong position and sometimes catches copy-and-paste mistakes.
glClear(mask: GL_COLOR_BUFFER_BIT) glTexParameteri(target: GL_TEXTURE_2D, pname: GL_TEXTURE_WRAP_S, param: GL_MIRRORED_REPEAT) glViewport(x: 0, y: 0, width: 800, height: 600)
The SwiftGL OpenGL loader provides you with direct calls to the OpenGL functions. There's no translation layer required to provide the syntactical sugar. Because Swift has first-class support for working with C, there's no performance penalty for crossing languages.
Regenerate OpenGL loading code
From the root directory of the package execute:
Help us keep the lights on
3.1.1 - Dec 5, 2017
3.1.0 - Nov 26, 2017
3.0.0 - Sep 16, 2017
2.0.1 - Jul 28, 2017
2.0.0 - Jul 28, 2017
Thanks to Christoph Wimberger (https://github.com/cwimberger) for helping with the update.