I did not use Swift, but based on the code in OpenGL EXC_BAD_ACCESS when calling glDrawElements in Swift, but not in Objective-C , your glVertexPointer()
call should look like this: this:
let bufferOffset: CConstVoidPointer = COpaquePointer(UnsafePointer<Int>(0)) glVertexPointer(2, GLbitfield(GL_FLOAT), 0, bufferOffset);
It also looks like you are not creating a shader program:
var programHandle: GLuint = glCreateProgram() glLinkProgram(programHandle)
There are tons of things you need to go through between you if you use simple OpenGL. You need to create shader objects, give them code written in GLSL, make calls to compile shaders, etc. I believe that GLKit has functionality for using pre-baked shaders.
As for why OpenGL is so βcrazy" that it goes beyond the scope of this site. And very subjective. IMHO, the main thing to keep in mind is that OpenGL is not intended to be used as a convenient API for programmers. It is designed to provide a relatively fine general abstraction for access to graphics hardware. And the trend towards comparable APIs is to make the abstraction layer even thinner to reduce overhead (see, for example, DirectX 12).
Nothing prevents anyone from implementing more convenient higher-level APIs on top of OpenGL. These interfaces exist, and people use them.
source share