Right now I’m working on porting the flocking example from the 5th edition superbible to iOS7. I’m trying to convert the texture buffers to pixel buffers (ios7 doesn’t support GL_TEXTURE_BUFFER), and I’m getting the error “The specified operation is invalid for the current OpenGL state”
if (frame_index & 1) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, position_tbo[0]);
glTexSubImage2D(GL_TEXTURE_2D, 0, GL_RGB, flock_size, 1, 0, GL_RGB, GL_FLOAT, &flock_position[0]);//!The specified operation is invalid for the current OpenGL state
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, velocity_tbo[0]);
glTexSubImage2D(GL_TEXTURE_2D, 0, GL_RGB, flock_size, 1, 0, GL_RGB, GL_FLOAT, &flock_velocity[0]);//!The specified operation is invalid for the current OpenGL state
glBindVertexArray(render_vao[1]);
} else {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, position_tbo[1]);
glTexSubImage2D(GL_TEXTURE_2D, 0, GL_RGB, flock_size, 1, 0, GL_RGB, GL_FLOAT, &flock_position[1]);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, velocity_tbo[1]);
glTexSubImage2D(GL_TEXTURE_2D, 0, GL_RGB, flock_size, 1, 0, GL_RGB, GL_FLOAT, &flock_velocity[1]);
glBindVertexArray(render_vao[0]);
}
The reason the height is 1 is in order to imitate GL_TEXTURE_1D which iOS doesn’t support. As far as I know, I don’t need to call glEnable(GL_TEXTURE_2D) for with ES 3.0, what might I be missing?
Cheers,
Steve