Skip to content

Instantly share code, notes, and snippets.

@kritzikratzi
Created January 4, 2010 04:56
Show Gist options
  • Save kritzikratzi/268306 to your computer and use it in GitHub Desktop.
Save kritzikratzi/268306 to your computer and use it in GitHub Desktop.
IntBuffer getsetBuffer = BufferUtil.newIntBuffer(1);
// int getset[] = new int[1];
public int get(int x, int y) {
gl.glReadPixels(x, y, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getsetBuffer);
// gl.glReadPixels(x, y, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getset, 0);
int getset = getsetBuffer.get(0);
if (BIG_ENDIAN) {
return 0xff000000 | ((getset >> 8) & 0x00ffffff);
} else {
return 0xff000000 |
((getset << 16) & 0xff0000) |
(getset & 0xff00) |
((getset >> 16) & 0xff);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment