Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Drawing a triangle GLKit
-
So I am trying to draw my first triangle using GLKit, but it’s not showing
def Vertex(x = c_float, y = c_float, z = c_float, r = c_float, g = c_float, b = c_float, a = c_float): restype = None argtypes = [x, y, z, r, g, b, a] cfunc = c.glRotatef cfunc.restype = restype #cfunc.argtypes = argtypes return argtypes Vertices = [ Vertex(x= 1, y= -1, z= 0, r= 1, g= 0, b= 0, a= 1), Vertex(x= 1, y= 1, z= 0, r= 0, g= 1, b= 0, a= 1), Vertex(x= -1, y= 1, z= 0, r= 0, g= 0, b= 1, a= 1), Vertex(x= -1, y= -1, z= 0, r= 0, g= 0, b= 0, a= 1), ] vf = [ -1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 0.0, 1.0, 0.0, ] intvf = [ -1, -1, 0, 1, -1, 0, 0, 1, 0, ] vertdata = (ctypes.c_float * len(vf))(*vf) #print(dir(c)) def glkView_drawInRect_(_self, _cmd, view, rect): r, g, b = colorsys.hsv_to_rgb((time.time() * 0.1) % 1.0, 1, 1) glClearColor(r, g, b, 1.0) vertexBuffer = GLES1.GLuint() GLES2.glGenBuffers(1, ctypes.byref(vertexBuffer), GLES1.GLsizei, ctypes.POINTER(GLES1.GLuint)) GLES2.glBindBuffer(GLES2.GL_ARRAY_BUFFER, vertexBuffer) v = vertdata lv = len(v) va = (GLES2.GLfloat * len(v)) GLES2.glBufferData( GLES2.GL_ARRAY_BUFFER, lv, v, GLES2.GL_STATIC_DRAW, voiddata_t=va) #self.vertexBuffer = vertexBuffer #_loaded_vbos[self.file] = {frame_id: vertexBuffer} GLES2.glBindBuffer(GLES2.GL_ARRAY_BUFFER, 0) GLES2.glEnableVertexAttribArray(0); GLES2.glDrawArrays(GLES2.GL_TRIANGLES, 0, 3); glClear(GL_COLOR_BUFFER_BIT)