在swift中正确使用glMapBufferRange

时间:2018-04-25 22:19:15

标签: swift xcode opengl-es

如何正确使用我从swift中glMapBufferRange返回的指针中获取的数据(通过使用我的意思是读取,写入数组中的索引)?

我目前的代码(相关部分):

initialisation method...
{
    glGenVertexArrays(1, &vao)
    glBindVertexArray(vao)

    glGenBuffers(1, &positionsVBO)
    glBindBuffer(GLenum(GL_ARRAY_BUFFER), positionsVBO)
    glBufferData(GLenum(GL_ARRAY_BUFFER), VectorPath.dynamicBufferSize, nil, GLenum(GL_STREAM_DRAW))

    glEnableVertexAttribArray(0)
    glBindBuffer(GLenum(GL_ARRAY_BUFFER), positionsVBO)
    glVertexAttribPointer(0, 3, GLenum(GL_FLOAT), 0, 0, nil)
}


draw method...
{
    // Not sure how to deal with the vertexPointer variable returned by glMapBufferRange   
    vertexPointer = glMapBufferRange(GLenum(GL_ARRAY_BUFFER), 0, VectorPath.dynamicBufferSize, GLenum(GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT))
    glBindVertexArray(vao)
    glDrawArrays(GLenum(GL_TRIANGLE_STRIP), 0, GLsizei(vertices.count))
    glUnmapBuffer(GLenum(GL_ARRAY_BUFFER))
}

0 个答案:

没有答案