/** * If supported, queries the natively supported shader binary formats using {@link * GL2ES2#GL_NUM_SHADER_BINARY_FORMATS} and {@link GL2ES2#GL_SHADER_BINARY_FORMATS} via {@link * GL2ES2#glGetIntegerv(int, int[], int)}. */ public static Set<Integer> getShaderBinaryFormats(final GL _gl) { final GL2ES2 gl = _gl.getGL2ES2(); final ProfileInformation info = getProfileInformation(gl); if (null == info.shaderBinaryFormats) { info.shaderBinaryFormats = new HashSet<Integer>(); if (gl.isGLES2Compatible()) { try { final int[] param = new int[1]; gl.glGetIntegerv(GL2ES2.GL_NUM_SHADER_BINARY_FORMATS, param, 0); final int err = gl.glGetError(); final int numFormats = GL.GL_NO_ERROR == err ? param[0] : 0; if (numFormats > 0) { final int[] formats = new int[numFormats]; gl.glGetIntegerv(GL2ES2.GL_SHADER_BINARY_FORMATS, formats, 0); for (int i = 0; i < numFormats; i++) { info.shaderBinaryFormats.add(Integer.valueOf(formats[i])); } } } catch (final GLException gle) { System.err.println("Caught exception on thread " + Thread.currentThread().getName()); gle.printStackTrace(); } } } return info.shaderBinaryFormats; }
private int checkSelection(GL2ES2 gl, int x, int y, int width, int height) { gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, 4); gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, 4); gl.glClearColor(sceneClearColor[0], sceneClearColor[1], sceneClearColor[2], sceneClearColor[3]); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); render(gl, width, height, 0, null, true); ByteBuffer pixel = Buffers.newDirectByteBuffer(4); pixel.order(ByteOrder.nativeOrder()); IntBuffer viewport = IntBuffer.allocate(4); gl.glGetIntegerv(GL2ES2.GL_VIEWPORT, viewport); gl.glReadPixels(x, viewport.get(3) - y, 1, 1, GL2ES2.GL_RGBA, GL2ES2.GL_UNSIGNED_BYTE, pixel); int qp = pixel.get(0) & 0xFF; int index = Math.round(((qp / 255.0f) * (count + 2)) - 1); if (index < 0 || index >= count) return -1; return index; }