Implementing render-to-vertex-array, glReadPixels fails (invalid operation)
I'm trying to copy vertex data from a texture to a vertex buffer, and then draw the vertex buffer. As far as I know the best way to do this is to bind the texture to a fbo, and use glReadPixels to copy it to a vbo. However, I can't seem to get this working: glReadPixels fails with the error "invalid operation". Corrections, examples and alternate methods welcome. :) Here's the relevant code: glEnable(GL_TEXTURE_2D) w, h = 32, 32 vbo = glGenBuffers(1) glBindBuffer(GL_ARRAY_BUFFER, vbo) glBufferData(GL_ARRAY_BUFFER, sizeof(c_float)*w*h*4, None, GL_STREAM_COPY) glBindBuffer(GL_ARRAY_BUFFER, 0)