| 1223 | } |
| 1224 | |
| 1225 | const std::uint8_t* |
| 1226 | RangeLikelihood::getColorBuffer() const |
| 1227 | { |
| 1228 | // It's only possible to read the color buffer if it |
| 1229 | // was rendered in the first place. |
| 1230 | assert(use_color_); |
| 1231 | |
| 1232 | if (color_buffer_dirty_) { |
| 1233 | std::cout << "Read color buffer" << std::endl; |
| 1234 | |
| 1235 | // Read Color |
| 1236 | GLint old_read_buffer; |
| 1237 | glGetIntegerv(GL_READ_BUFFER, &old_read_buffer); |
| 1238 | |
| 1239 | glBindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| 1240 | glReadBuffer(GL_COLOR_ATTACHMENT0); |
| 1241 | glReadPixels(0, 0, width_, height_, GL_RGB, GL_UNSIGNED_BYTE, color_buffer_); |
| 1242 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 1243 | glReadBuffer(old_read_buffer); |
| 1244 | |
| 1245 | if (gllib::getGLError() != GL_NO_ERROR) { |
| 1246 | std::cerr << "GL Error: RangeLikelihood::getColorBuffer" << std::endl; |
| 1247 | } |
| 1248 | |
| 1249 | color_buffer_dirty_ = false; |
| 1250 | } |
| 1251 | return color_buffer_; |
| 1252 | } |
| 1253 | |
| 1254 | // The scores are in score_texture_ |
| 1255 | const float* |