/** * Calls {@link DoubleBuffer#duplicate()}, flips the result, and returns it. * <p> * This is a convenient way to get a flipped version of a buffer, without * modifying the original buffer's position or limit. */ public static DoubleBuffer flipped( DoubleBuffer buffer ) { DoubleBuffer flipped = buffer.duplicate( ); flipped.flip( ); return flipped; }
/** Vararg version of {@link #mallocDouble}. */ public DoubleBuffer doubles(double... values) { DoubleBuffer buffer = mallocDouble(values.length).put(values); buffer.flip(); return buffer; }
/** * Returns a new direct double buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static DoubleBuffer newDoubleBuffer(double[] a) { DoubleBuffer b = newDoubleBuffer(a.length); b.put(a); b.flip(); return b; }
@SuppressWarnings("unchecked") private static DoubleBuffer getDoubleBuffer(final Object doc, final int sizeM, final int sizeN) { if (doc == null) { return null; } if (!(doc instanceof ArrayList<?>)) { throw new Ardor3dException("Incorrect type. Expected ArrayList of size " + sizeM + ". Got: " + doc.getClass().getName() + " value: " + doc); } final List<Object> vals = (ArrayList<Object>) doc; if (vals.size() != sizeM) { throw new Ardor3dException("Incorrect size. Expected: " + sizeM + " value: " + doc); } final DoubleBuffer buff = BufferUtils.createDoubleBuffer(sizeM * sizeN); for (final Object val : vals) { buff.put(getDoubleBuffer(val, sizeN)); } buff.flip(); return buff; }
@SuppressWarnings("unchecked") private static DoubleBuffer getDoubleBuffer(final Object doc, final int size) { if (doc == null) { return null; } DoubleBuffer buff; if (size == 1) { buff = BufferUtils.createDoubleBuffer(1); buff.put(getDouble(doc)); } else { if (!(doc instanceof ArrayList<?>)) { throw new Ardor3dException("Incorrect type. Expected ArrayList of size " + size + ". Got: " + doc.getClass().getName() + " value: " + doc); } final List<Object> vals = (ArrayList<Object>) doc; if (vals.size() != size) { throw new Ardor3dException("Incorrect size. Expected: " + size + " value: " + doc); } buff = BufferUtils.createDoubleBuffer(size); for (final Object val : vals) { buff.put(getDouble(val)); } } buff.flip(); return buff; }
@Nonnull public DoubleBuffer createDoubleBuffer() { DoubleBuffer buffer = Bufferer.newDoubleBuffer(4); buffer.put(getR()); buffer.put(getG()); buffer.put(getB()); buffer.put(getA()); buffer.flip(); return buffer; }
@Nonnull public DoubleBuffer createDoubleBuffer() { DoubleBuffer buffer = Bufferer.newDoubleBuffer(4); buffer.put(getR()); buffer.put(getG()); buffer.put(getB()); buffer.put(getA()); buffer.flip(); return buffer; }
case Double1: if (value instanceof Number) { return stack.mallocDouble(1).put(((Number) value).doubleValue()).flip(); if (value instanceof Vector2) { final Vector2 vec = (Vector2) value; return stack.mallocDouble(2).put(vec.getX()).put(vec.getY()).flip(); if (value instanceof Vector3) { final Vector3 vec = (Vector3) value; return stack.mallocDouble(3).put(vec.getX()).put(vec.getY()).put(vec.getZ()).flip(); if (value instanceof Vector4) { final Vector4 vec = (Vector4) value; return stack.mallocDouble(4).put(vec.getX()).put(vec.getY()).put(vec.getZ()).put(vec.getW()).flip(); final DoubleBuffer buff = stack.mallocDouble(9); mat.toDoubleBuffer(buff, false); return buff.flip(); return buff.flip(); final DoubleBuffer buff = stack.mallocDouble(16); mat.toDoubleBuffer(buff, false); return buff.flip(); return buff.flip();
worldClip.put(1).put(0).put(0).put(-x).flip(); GL.glClipPlane(SGL.GL_CLIP_PLANE0, worldClip); GL.glEnable(SGL.GL_CLIP_PLANE1); worldClip.put(-1).put(0).put(0).put(x + width).flip(); GL.glClipPlane(SGL.GL_CLIP_PLANE1, worldClip); worldClip.put(0).put(1).put(0).put(-y).flip(); GL.glClipPlane(SGL.GL_CLIP_PLANE2, worldClip); GL.glEnable(SGL.GL_CLIP_PLANE3); worldClip.put(0).put(-1).put(0).put(y + height).flip(); GL.glClipPlane(SGL.GL_CLIP_PLANE3, worldClip); postdraw();
public void JITB$toDoubleBuffer(final DoubleBuffer value) { // // a c tx a c 0 tx // b d ty -> b d 0 ty // 0 0 1 0 0 1 0 // 0 0 0 1 value.clear(); value.put(a).put(b).put(0.0).put(0.0). put(c).put(d).put(0.0).put(0.0). put(0.0).put(0.0).put(1.0).put(0.0). put(tx).put(ty).put(0.0).put(1.0); value.flip(); }
private void setTransform (final DVector3C pos, final DMatrix3C R) { //GLdouble double[] matrix=new double[16]; matrix[0]=R.get00(); matrix[1]=R.get10(); matrix[2]=R.get20(); matrix[3]=0; matrix[4]=R.get01(); matrix[5]=R.get11(); matrix[6]=R.get21(); matrix[7]=0; matrix[8]=R.get02(); matrix[9]=R.get12(); matrix[10]=R.get22(); matrix[11]=0; matrix[12]=pos.get0(); matrix[13]=pos.get1(); matrix[14]=pos.get2(); matrix[15]=1; matrixD.put(matrix); matrixD.flip(); GL11.glPushMatrix(); GL11.glMultMatrix (matrixD); }
private void testBufferRoundTrip(INDArray a) { int len = (int) a.elementCount(); DoubleBuffer buf = DoubleBuffer.allocate(len); assertEquals(len, buf.remaining()); a.toDoubleBuffer(buf); assertEquals(0, buf.remaining()); buf.flip(); AVector vv = Vectorz.create(buf); assertEquals(a.asVector(), vv); assertEquals(a, vv.reshape(a.getShape())); }