public int getTopColor(DrawContext dc, java.awt.Point pickPoint) { GL gl = dc.getGL(); java.nio.ByteBuffer pixel = BufferUtil.newByteBuffer(3); int yInGLCoords = dc.getView().getViewport().height - pickPoint.y - 1; gl.glReadPixels( pickPoint.x, yInGLCoords, 1, 1, javax.media.opengl.GL.GL_RGB, GL.GL_UNSIGNED_BYTE, pixel); java.awt.Color topColor = null; try { topColor = new java.awt.Color(pixel.get(0) & 0xff, pixel.get(1) & 0xff, pixel.get(2) & 0xff, 0); } catch (Exception e) { Logging.logger().severe("layers.InvalidPickColorRead"); } return topColor != null ? topColor.getRGB() : 0; }