@Generates private IntBuffer generateIntBuffer() { return IntBuffer.allocate(generateInt()); }
@Override public long glGetQueryObjectui64(int query, int pname) { IntBuffer buff = IntBuffer.allocate(1); //FIXME This is wrong IMO should be glGetQueryObjectui64v with a LongBuffer but it seems the API doesn't provide it. GLES30.glGetQueryObjectuiv(query, pname, buff); return buff.get(0); }
@Override public int glGetQueryObjectiv(int query, int pname) { IntBuffer buff = IntBuffer.allocate(1); GLES30.glGetQueryiv(query, pname, buff); return buff.get(0); }
public void onPreviewFrame(final byte[] data, final int width, final int height) { if (glRgbBuffer == null) { glRgbBuffer = IntBuffer.allocate(width * height); } if (runOnDraw.isEmpty()) { runOnDraw(new Runnable() { @Override public void run() { GPUImageNativeLibrary.YUVtoRBGA(data, width, height, glRgbBuffer.array()); glTextureId = OpenGlUtils.loadTexture(glRgbBuffer, width, height, glTextureId); if (imageWidth != width) { imageWidth = width; imageHeight = height; adjustImageScaling(); } } }); } }
@Override public int glGetQueryObjectiv(int query, int pname) { IntBuffer buff = IntBuffer.allocate(1); GLContext.getCurrentGL().getGL2ES2().glGetQueryObjectiv(query, pname, buff); return buff.get(0); }
IntBuffer intBuffer = IntBuffer.allocate(imageWidth*imageHeight);
Bitmap blend = layer.copy(Config.ARGB_8888, false); IntBuffer buffBase = IntBuffer.allocate(base.getWidth() * base.getHeight()); base.copyPixelsToBuffer(buffBase); buffBase.rewind(); IntBuffer buffBlend = IntBuffer.allocate(blend.getWidth() * blend.getHeight()); blend.copyPixelsToBuffer(buffBlend); buffBlend.rewind(); IntBuffer buffOut = IntBuffer.allocate(base.getWidth() * base.getHeight()); buffOut.rewind();
directBufferAllocations.add(new Pair<>(conversionDirectBuffer, allocationSize)); } else { conversions[i] = IntBuffer.allocate(indexed.size()); mergeBufferTotalSize += indexed.size();
@Test(expected = RuntimeException.class) public void throwsExceptionCopyPixelsToIntBuffer() { Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); IntBuffer buffer = IntBuffer.allocate(bitmapOriginal.getByteCount()); bitmapOriginal.copyPixelsToBuffer(buffer); }
@Test(expected = RuntimeException.class) public void throwsExceptionCopyPixelsFromIntBuffer() { Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); IntBuffer buffer = IntBuffer.allocate(bitmapOriginal.getByteCount()); bitmapOriginal.copyPixelsFromBuffer(buffer); }
protected int determineMaxSamples(int requestedSamples) { GL gl = GLContext.getCurrentGL(); if (gl.hasFullFBOSupport()) { return gl.getMaxRenderbufferSamples(); } else { if (gl.isExtensionAvailable("GL_ARB_framebuffer_object") || gl.isExtensionAvailable("GL_EXT_framebuffer_multisample")) { IntBuffer intBuf1 = IntBuffer.allocate(1); gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, intBuf1); return intBuf1.get(0); } else { return Integer.MAX_VALUE; } } }
/** * Creates a new IntBuffer with the same contents as the given IntBuffer. * The new IntBuffer is separate from the old one and changes are not * reflected across. If you want to reflect changes, consider using * Buffer.duplicate(). * * @param buf * the IntBuffer to copy * @return the copy */ public static IntBuffer clone(IntBuffer buf) { if (buf == null) { return null; } buf.rewind(); IntBuffer copy; if (isDirect(buf)) { copy = createIntBuffer(buf.limit()); } else { copy = IntBuffer.allocate(buf.limit()); } copy.put(buf); return copy; }
private static boolean initializeJOpenVR() { hmdErrorStore = IntBuffer.allocate(1); vrSystem = null; JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene); if (hmdErrorStore.get(0) == 0) { // ok, try and get the vrSystem pointer.. vrSystem = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore)); } if (vrSystem == null || hmdErrorStore.get(0) != 0) { String errorString = jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0)).getString(0); logger.info("vrSystem initialization failed:" + errorString); return false; } else { vrSystem.setAutoSynch(false); vrSystem.read(); logger.info("OpenVR initialized & VR connected."); hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference(); hmdTrackedDevicePoses = (TrackedDevicePose_t[]) hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount); // disable all this stuff which kills performance hmdTrackedDevicePoseReference.setAutoRead(false); hmdTrackedDevicePoseReference.setAutoWrite(false); hmdTrackedDevicePoseReference.setAutoSynch(false); for (int i = 0; i < JOpenVRLibrary.k_unMaxTrackedDeviceCount; i++) { hmdTrackedDevicePoses[i].setAutoRead(false); hmdTrackedDevicePoses[i].setAutoWrite(false); hmdTrackedDevicePoses[i].setAutoSynch(false); } } return true; }
_tframeCount = new LongByReference(); hmdDisplayFrequency = IntBuffer.allocate(1); hmdDisplayFrequency.put( (int) JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float); hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference();
private void charToIntBuffer(int toAppend) { charBuffer.flip(); // IntBuffers hold two times as much per unit as ByteBuffers, so start with one half the capacity. IntBuffer newBuffer = IntBuffer.allocate(Math.max(charBuffer.remaining() + toAppend, charBuffer.capacity() / 2)); while (charBuffer.hasRemaining()) { newBuffer.put(charBuffer.get() & 0xFFFF); } type = Type.INT; charBuffer = null; intBuffer = newBuffer; } }
private void byteToIntBuffer(int toAppend) { byteBuffer.flip(); // IntBuffers hold four times as much per unit as ByteBuffers, so start with one quarter the capacity. IntBuffer newBuffer = IntBuffer.allocate(Math.max(byteBuffer.remaining() + toAppend, byteBuffer.capacity() / 4)); while (byteBuffer.hasRemaining()) { newBuffer.put(byteBuffer.get() & 0xFF); } type = Type.INT; byteBuffer = null; intBuffer = newBuffer; }
protected Decoder(int ssrc) { this.ssrc = ssrc; this.lastSeq = (char) -1; this.lastTimestamp = -1; IntBuffer error = IntBuffer.allocate(1); opusDecoder = Opus.INSTANCE.opus_decoder_create(AudioConnection.OPUS_SAMPLE_RATE, AudioConnection.OPUS_CHANNEL_COUNT, error); if (error.get() != Opus.OPUS_OK && opusDecoder == null) throw new IllegalStateException("Received error code from opus_decoder_create(...): " + error.get()); }
private byte[] encodeAudio(byte[] rawAudio) { if (opusEncoder == null) { if (!AudioNatives.ensureOpus()) { if (!printedError) LOG.error("Unable to process PCM audio without opus binaries!"); printedError = true; return null; } IntBuffer error = IntBuffer.allocate(1); opusEncoder = Opus.INSTANCE.opus_encoder_create(OPUS_SAMPLE_RATE, OPUS_CHANNEL_COUNT, Opus.OPUS_APPLICATION_AUDIO, error); if (error.get() != Opus.OPUS_OK && opusEncoder == null) { LOG.error("Received error status from opus_encoder_create(...): {}", error.get()); return null; } } return encodeToOpus(rawAudio); }
private Bitmap convertToBitmap() { int[] iat = new int[mWidth * mHeight]; IntBuffer ib = IntBuffer.allocate(mWidth * mHeight); mEGLHelper.mGL.glReadPixels(0, 0, mWidth, mHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib); int[] ia = ib.array(); // Convert upside down mirror-reversed image to right-side up normal // image. for (int i = 0; i < mHeight; i++) { System.arraycopy(ia, i * mWidth, iat, (mHeight - i - 1) * mWidth, mWidth); } Bitmap bitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888); bitmap.copyPixelsFromBuffer(IntBuffer.wrap(iat)); return bitmap; }
if (intBuffer.remaining() < remainingNeeded) { int newCapacity = roundUpToNextPowerOfTwo(intBuffer.capacity() + remainingNeeded); IntBuffer newBuffer = IntBuffer.allocate(newCapacity); intBuffer.flip(); newBuffer.put(intBuffer);