Refine search
public Int16Array copy (ShortBuffer buffer) { if (GWT.isProdMode()) { return ((Int16Array)((HasArrayBufferView)buffer).getTypedArray()).subarray(buffer.position(), buffer.remaining()); } else { ensureCapacity(buffer); for (int i = buffer.position(), j = 0; i < buffer.limit(); i++, j++) { shortBuffer.set(j, buffer.get(i)); } return shortBuffer.subarray(0, buffer.remaining()); } }
public static ShortBuffer ensureLargeEnough(ShortBuffer buffer, int required) { if (buffer != null) { buffer.limit(buffer.capacity()); } if (buffer == null || (buffer.remaining() < required)) { int position = (buffer != null ? buffer.position() : 0); ShortBuffer newVerts = createShortBuffer(position + required); if (buffer != null) { buffer.flip(); newVerts.put(buffer); newVerts.position(position); } buffer = newVerts; } return buffer; }
/** Compare the remaining shorts of this buffer to another short buffer's remaining shorts. * * @param otherBuffer another short buffer. * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value * if this is greater than {@code otherBuffer}. * @exception ClassCastException if {@code otherBuffer} is not a short buffer. * @since Android 1.0 */ public int compareTo (ShortBuffer otherBuffer) { int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); int thisPos = position; int otherPos = otherBuffer.position; short thisByte, otherByte; while (compareRemaining > 0) { thisByte = get(thisPos); otherByte = otherBuffer.get(otherPos); if (thisByte != otherByte) { return thisByte < otherByte ? -1 : 1; } thisPos++; otherPos++; compareRemaining--; } return remaining() - otherBuffer.remaining(); }
private void increaseCapacity() { int newCapacity = (valueslength.capacity() == 0) ? DEFAULT_INIT_SIZE : valueslength.capacity() < 64 ? valueslength.capacity() * 2 : valueslength.capacity() < 1024 ? valueslength.capacity() * 3 / 2 : valueslength.capacity() * 5 / 4; final ShortBuffer nv = ShortBuffer.allocate(newCapacity); valueslength.rewind(); nv.put(valueslength); valueslength = nv; }
case Short: case UnsignedShort: short s = ((ShortBuffer) buf2).get(index); ((ShortBuffer) buf1).put(s); break; int i = ((IntBuffer) buf2).get(index); ((IntBuffer) buf1).put(i); break; case Float: float f = ((FloatBuffer) buf2).get(index); ((FloatBuffer) buf1).put(f); break; case Double: double d = ((DoubleBuffer) buf2).get(index); ((DoubleBuffer) buf1).put(d); break; default:
FloatBuffer normals = geometry.getMesh().getFloatBuffer(Type.Normal); if (normals != null) { for (int i = 0; i < normals.limit(); i += 3) { if (scale.x < 0) { normals.put(i, -normals.get(i)); LOGGER.finer("Flipping index order in triangle mesh."); Buffer indexBuffer = geometry.getMesh().getBuffer(Type.Index).getData(); for (int i = 0; i < indexBuffer.limit(); i += 3) { if (indexBuffer instanceof ShortBuffer) { short index = ((ShortBuffer) indexBuffer).get(i + 1); ((ShortBuffer) indexBuffer).put(i + 1, ((ShortBuffer) indexBuffer).get(i + 2)); ((ShortBuffer) indexBuffer).put(i + 2, index); } else { int index = ((IntBuffer) indexBuffer).get(i + 1); ((IntBuffer) indexBuffer).put(i + 1, ((IntBuffer) indexBuffer).get(i + 2)); ((IntBuffer) indexBuffer).put(i + 2, index);
private static void bulkPut(VertexBuffer.Format format, Buffer buf1, Buffer buf2) { switch (format) { case Byte: case Half: case UnsignedByte: ((ByteBuffer) buf1).put((ByteBuffer) buf2); break; case Short: case UnsignedShort: ((ShortBuffer) buf1).put((ShortBuffer) buf2); break; case Int: case UnsignedInt: ((IntBuffer) buf1).put((IntBuffer) buf2); break; case Float: ((FloatBuffer) buf1).put((FloatBuffer) buf2); break; case Double: ((DoubleBuffer) buf1).put((DoubleBuffer) buf2); break; default: throw new UnsupportedOperationException("Unrecoginized buffer format: " + format); } }
private static void copyBuffer(Buffer buffer, long handle, long flags, int d1) { if (d1 != buffer.capacity()) { Class<?> cls = null; if (buffer instanceof ByteBuffer) { cls.getName() + " of capacity " + d1 + ". Got " + cls.getName() + " of capacity " + buffer.capacity()); int offset = 0; int shift = VM.getInt(VM.getObjectAddress(buffer) + _ELEMENT_SIZE_SHIFT_OFFSET); if (buffer.isDirect()) { src = VM.getLong(VM.getObjectAddress(buffer) + EFFECTIVE_DIRECT_ADDRESS_OFFSET); } else { } else if (buffer instanceof ShortBuffer) { array = new short[d1]; ((ShortBuffer) buffer).get((short[]) array); } else if (buffer instanceof CharBuffer) { array = new char[d1]; buffer.position(pos);
outVb.data.clear(); ByteBuffer bin = (ByteBuffer) srcData; ByteBuffer bout = (ByteBuffer) outVb.data; bin.position(inPos).limit(inPos + elementSz * len); bout.position(outPos).limit(outPos + elementSz * len); bout.put(bin); break; ShortBuffer sin = (ShortBuffer) srcData; ShortBuffer sout = (ShortBuffer) outVb.data; sin.position(inPos).limit(inPos + elementSz * len); sout.position(outPos).limit(outPos + elementSz * len); sout.put(sin); break; case Int:
Number get(DataType dataType, int index) { if (dataType == DataType.BYTE) return bb.get(index); if (dataType == DataType.SHORT) return bb.asShortBuffer().get(index); if (dataType == DataType.INT) return bb.asIntBuffer().get(index); if (dataType == DataType.LONG) return bb.asLongBuffer().get(index); if (dataType == DataType.FLOAT) return bb.asFloatBuffer().get(index); if (dataType == DataType.DOUBLE) return bb.asDoubleBuffer().get(index); return Double.NaN; }
checkInt(cb.get(), 8); sb.position(4); BufferUtils.copy(new short[] {1, 2, 3, 4}, 0, sb, 4); checkInt(sb.get(), 1); checkInt(sb.get(), 2); checkInt(sb.get(), 3); checkInt(sb.get(), 4); sb.position(0); BufferUtils.copy(new short[] {5, 6, 7, 8}, 1, sb, 3); checkInt(sb.get(), 6); checkInt(sb.get(), 7); checkInt(sb.get(), 8); ib.position(4); BufferUtils.copy(new int[] {1, 2, 3, 4}, 0, ib, 4); checkInt(ib.get(), 1); checkInt(ib.get(), 2); lb.position(4); BufferUtils.copy(new long[] {1, 2, 3, 4}, 0, lb, 4); checkInt(lb.get(), 1); checkInt(lb.get(), 2); fb.position(4); BufferUtils.copy(new float[] {1, 2, 3, 4}, 0, fb, 4); checkFloat(fb.get(), 1); checkFloat(fb.get(), 2);
data.clear(); case UnsignedShort: ShortBuffer sin = (ShortBuffer) data; sin.put(inPos + elementPos, (Short)val); break; case Int: case UnsignedInt: IntBuffer iin = (IntBuffer) data; iin.put(inPos + elementPos, (Integer)val); break; case Float: FloatBuffer fin = (FloatBuffer) data; fin.put(inPos + elementPos, (Float)val); break; default:
data.clear(); switch (format){ case Byte: case UnsignedShort: ShortBuffer sbuf = (ShortBuffer) data; sbuf.limit(total); ShortBuffer snewBuf = BufferUtils.createShortBuffer(total); snewBuf.put(sbuf); data = snewBuf; break; throw new UnsupportedOperationException("Unrecognized buffer format: "+format); data.clear(); setUpdateNeeded(); dataSizeChanged = true;
if (vertexBuffer.getData() instanceof FloatBuffer) { FloatBuffer b = (FloatBuffer) vertexBuffer.getData(); float[] arr = new float[b.capacity()]; b.rewind(); b.get(arr); b.rewind(); for (float v : arr) { short[] arr = new short[b.capacity()]; b.rewind(); b.get(arr); b.rewind(); for (short v : arr) { System.err.print(v + ","); int[] arr = new int[b.capacity()]; b.rewind(); b.get(arr); b.rewind(); for (int v : arr) {
lodSize[i] += g.getMesh().getLodLevel(i).getData().limit(); if(isShortBuffer){ ShortBuffer buffer = (ShortBuffer) g.getMesh().getLodLevel(i).getDataReadOnly(); for (int j = 0; j < buffer.limit(); j++) { lodData[i][bufferPos[i]] = (buffer.get()& 0xffff) + indexPos[i]; bufferPos[i]++; for (int j = 0; j < buffer.limit(); j++) { lodData[i][bufferPos[i]] = buffer.get() + indexPos[i]; bufferPos[i]++;
vb.getData().clear(); // reset position & limit (used later) FloatBuffer fb = (FloatBuffer) vb.getData(); for (int comp = 0; comp < vb.components; comp++){ dataBuf.putFloat(fb.get()); ShortBuffer sb = (ShortBuffer) vb.getData(); for (int comp = 0; comp < vb.components; comp++){ dataBuf.putShort(sb.get()); IntBuffer ib = (IntBuffer) vb.getData(); for (int comp = 0; comp < vb.components; comp++){ dataBuf.putInt(ib.get()); DoubleBuffer db = (DoubleBuffer) vb.getData(); for (int comp = 0; comp < vb.components; comp++){ dataBuf.putDouble(db.get());
public static int[] getIntArrayFromBuffer(Buffer buffer) { int[] array = new int[0]; if (buffer != null) { if (buffer.hasArray()) { array = (int[]) buffer.array(); } else { buffer.rewind(); array = new int[buffer.capacity()]; if (buffer instanceof IntBuffer) { ((IntBuffer) buffer).get(array); } else if (buffer instanceof ShortBuffer) { int count = 0; while (buffer.hasRemaining()) { array[count] = (int) (((ShortBuffer) buffer).get()); ++count; } } } } return array; }
if (!indices.getData().hasArray()) { if (indices.getFormat() == Format.UnsignedByte) { ByteBuffer originalIndex = (ByteBuffer) indices.getData(); ShortBuffer arrayIndex = ShortBuffer.allocate(originalIndex.capacity()); originalIndex.clear(); arrayIndex.put(originalIndex); indices.updateData(arrayIndex); if (!weights.getData().hasArray()) { FloatBuffer originalWeight = (FloatBuffer) weights.getData(); FloatBuffer arrayWeight = FloatBuffer.allocate(originalWeight.capacity()); originalWeight.clear(); arrayWeight.put(originalWeight); weights.updateData(arrayWeight); ShortBuffer directIndex = BufferUtils.createShortBuffer(originalIndex.capacity()); originalIndex.clear(); directIndex.put(originalIndex); result = directIndex;