| 24 | |
| 25 | template<typename T> |
| 26 | void copy_vector_field(const Array<T> &points, const Array<T> &directions, |
| 27 | fg_vector_field vfield) { |
| 28 | ForgeModule &_ = forgePlugin(); |
| 29 | points.eval(); |
| 30 | directions.eval(); |
| 31 | getQueue().sync(); |
| 32 | |
| 33 | CheckGL("Before CopyArrayToVBO"); |
| 34 | |
| 35 | unsigned size1 = 0, size2 = 0; |
| 36 | unsigned buff1 = 0, buff2 = 0; |
| 37 | FG_CHECK(_.fg_get_vector_field_vertex_buffer_size(&size1, vfield)); |
| 38 | FG_CHECK(_.fg_get_vector_field_direction_buffer_size(&size2, vfield)); |
| 39 | FG_CHECK(_.fg_get_vector_field_vertex_buffer(&buff1, vfield)); |
| 40 | FG_CHECK(_.fg_get_vector_field_direction_buffer(&buff2, vfield)); |
| 41 | |
| 42 | glBindBuffer(GL_ARRAY_BUFFER, buff1); |
| 43 | glBufferSubData(GL_ARRAY_BUFFER, 0, size1, points.get()); |
| 44 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 45 | |
| 46 | glBindBuffer(GL_ARRAY_BUFFER, buff2); |
| 47 | glBufferSubData(GL_ARRAY_BUFFER, 0, size2, directions.get()); |
| 48 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 49 | |
| 50 | CheckGL("In CopyArrayToVBO"); |
| 51 | } |
| 52 | |
| 53 | #define INSTANTIATE(T) \ |
| 54 | template void copy_vector_field<T>(const Array<T> &, const Array<T> &, \ |