| 75 | } |
| 76 | |
| 77 | bool compute_buffer::create_gl_buffer(const bool copy_host_data) { |
| 78 | if(has_external_gl_object) return true; |
| 79 | |
| 80 | // clean up previous gl buffer that might still exist |
| 81 | delete_gl_buffer(); |
| 82 | |
| 83 | // create and init the opengl buffer |
| 84 | glGenBuffers(1, &gl_object); |
| 85 | glBindBuffer(opengl_type, gl_object); |
| 86 | if(gl_object == 0 || !glIsBuffer(gl_object)) { |
| 87 | log_error("created opengl buffer $ is invalid!", gl_object); |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | if(copy_host_data && |
| 92 | host_data.data() != nullptr && |
| 93 | !has_flag<COMPUTE_MEMORY_FLAG::NO_INITIAL_COPY>(flags)) { |
| 94 | glBufferData(opengl_type, (GLsizeiptr)size, host_data.data(), GL_DYNAMIC_DRAW); |
| 95 | } |
| 96 | else { |
| 97 | glBufferData(opengl_type, (GLsizeiptr)size, nullptr, GL_DYNAMIC_DRAW); |
| 98 | } |
| 99 | glBindBuffer(opengl_type, 0); |
| 100 | |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | compute_buffer::opengl_buffer_info compute_buffer::get_opengl_buffer_info(const uint32_t& opengl_buffer, |
| 105 | const uint32_t& opengl_type_, |