- glReadPixels(screenPos.x, screenPos.y, 1, 1, GL_RGBA, GL_FLOAT,
- value_ptr(pixel));
+ glReadPixels(screenPos.x, screenPos.y, 1, 1, GL_RGBA, GL_FLOAT, &pixel);
+#else
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, pboBufs[pboIdx]);
+ glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
+ NULL);
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, pboBufs[(pboIdx + 1) % numPbos]);
+ GLuint offset = screenPos.x * 4 + screenPos.y * (int)width * 4;
+ ivec4 *src = (ivec4 *)glMapBufferRange(GL_PIXEL_PACK_BUFFER, offset, 4, GL_MAP_READ_BIT);
+ checkError();
+ if (src) {
+ ivec4 t = src[(int)screenPos.x + (int)screenPos.y * (int)width];
+ pixel = vec4(t) / vec4(255.f);
+ }
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
+
+ pboIdx = (pboIdx + 1) % numPbos;
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+#endif