Advertisement
Viraax

Untitled

Apr 4th, 2023
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. int ForwardRenderer::read_buffer_id(const glm::vec2& coord)
  2. {
  3.     glBindFramebuffer(GL_FRAMEBUFFER, picking_buffer);
  4.     glFlush();
  5.     glFinish();
  6.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  7.     unsigned char data[4];
  8.     glReadBuffer(GL_COLOR_ATTACHMENT0);
  9.     glReadPixels(coord.x, coord.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &data);
  10.     glBindFramebuffer(GL_FRAMEBUFFER, 0);
  11.     return data[0] + data[1] * 256 + data[2] * 256 * 256;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement