Java 8 ShortBuffer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ShortBuffer class.

This code example shows how to use the following methods:clear, flip, put
	// A: indices - array of indices (shorts) to set 
	//    offset - offset to first index in array 
	//    length - number of indices in array (from offset) 
	// R: [none] 
	public void setIndices(short[] indices, int offset, int length) {
		this.indices.clear();                        // Clear Existing Indices
		this.indices.put(indices, offset, length);    // Set New Indices
		this.indices.flip();                            // Flip Index Buffer
		this.numIndices = length;                    // Save Number of Indices
	} 
 
	//--Bind--// 
	// D: perform all required binding/state changes before rendering batches. 
	//    USAGE: call once before calling draw() multiple times for this buffer. 
	// A: [none] 
	// R: [none] 
	public void bind() { 
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); // Enable Position in Vertices
		vertices.position(0);                        // Set Vertex Buffer to Position
		gl.glVertexPointer(positionCnt, GL10.GL_FLOAT, vertexSize, vertices);  // Set Vertex Pointer
7
CodeRank
This code example shows how to use the following methods:position, put
         
        ByteBuffer ibb =
            ByteBuffer.allocateDirect(indices.length * SHORT_BYTES);
        ibb.order(ByteOrder.nativeOrder());
        ShortBuffer shortIndexBuffer = ibb.asShortBuffer();
        shortIndexBuffer.put(indices);
        shortIndexBuffer.position(0);
        this.mIndexBuffer = shortIndexBuffer;
    } 
     
    /** 
     * Copies the given data into the instance 
     * variables mVertexBuffer, mTexcoordBuffer, mNormalBuffer, mColorBuffer, 
     * and mIndexBuffer. 
     *  
     * @param vertices an array of fixed-point vertex coordinates 
     * @param texcoords an array of fixed-point texture coordinates 
     * @param normals an array of fixed-point normal vector coordinates 
     * @param colors an array of fixed-point color channel values 
     * @param indices an array of int indices 
7
CodeRank
This code example shows how to use the following methods:get, put
This code example shows how to use the following methods:clear, flip, put
	 *  
	 * @param indices the vertex data 
	 * @param offset the offset to start copying the data from 
	 * @param count the number of shorts to copy */ 
	public void setIndices (short[] indices, int offset, int count) {
		buffer.clear();
		buffer.put(indices, offset, count);
		buffer.flip();
		byteBuffer.position(0);
		byteBuffer.limit(count << 1);
	} 
 
	/** <p> 
	 * Returns the underlying ShortBuffer. If you modify the buffer contents they wil be uploaded on the call to {@link #bind()}. 
	 * If you need immediate uploading use {@link #setIndices(short[], int, int)}. 
	 * </p> 
	 *  
	 * @return the underlying short buffer. */ 
	public ShortBuffer getBuffer () {
		return buffer;
7
CodeRank
This code example shows how to use the following methods:position, put
 
	private static ShortBuffer buildBuffer(short[] b) {
		ByteBuffer bb = ByteBuffer.allocateDirect(b.length << 1);
		bb.order(ByteOrder.nativeOrder());
		ShortBuffer sb = bb.asShortBuffer();
		sb.put(b);
		sb.position(0);
		return sb;
	} 
 
	private static ByteBuffer buildBuffer(byte[] b) {
		ByteBuffer bb = ByteBuffer.allocateDirect(b.length << 1);
		bb.order(ByteOrder.nativeOrder());
		bb.put(b);
		bb.position(0);
		return bb;
	} 
 
	public void update(@Nonnull GL11 gl, @Nonnull PlotFunction fpd, @Nonnull Graph2dDimensions dimensions) {
		final XyFunction function = fpd.getXyFunction();
6
CodeRank
This code example shows how to use the following methods:position, put
		return mTextureBuffer;
	} 
	public static ShortBuffer getBoxIndexBuffer(){
		if(mIndexBuffer==null){
			mIndexBuffer=OpenGLUtils.allocateShortBuffer(6*2);
        mIndexBuffer.put((short)0);
        mIndexBuffer.put((short)1);
        mIndexBuffer.put((short)2);
        mIndexBuffer.put((short)2);
        mIndexBuffer.put((short)3);
        mIndexBuffer.put((short)1);
        mIndexBuffer.position(0);
		} 
		return mIndexBuffer;
	} 
	public static FloatBuffer getBoxVertexBuffer(){
		if(mFVertexBuffer==null){
			mFVertexBuffer=OpenGLUtils.allocateFloatBuffer(4*4*3);
		    OpenGLUtils.addVertex3f(mFVertexBuffer, -1,-1f,0);
	        OpenGLUtils.addVertex3f(mFVertexBuffer, -1,1f,0);
6
CodeRank
This code example shows how to use the following methods:position, remaining
	    zeroBuffer0(b, b.position(), b.remaining());
	} 
 
	/** Fill buffer with zeros from position to remaining */ 
	public static void zeroBuffer(ShortBuffer b) {
	    zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
	} 
 
	/** Fill buffer with zeros from position to remaining */ 
	public static void zeroBuffer(CharBuffer b) {
	    zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
	} 
 
	/** Fill buffer with zeros from position to remaining */ 
	public static void zeroBuffer(IntBuffer b) {
	    zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
	} 
 
	/** Fill buffer with zeros from position to remaining */ 
	public static void zeroBuffer(FloatBuffer b) {
6
CodeRank
This code example shows how to use the following methods:get, put
        byteBuffer.order(ByteOrder.nativeOrder());
        ShortBuffer shortBuffer = byteBuffer.asShortBuffer();
 
        short[] source = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 
        shortBuffer.put(source, 2, 2);
        shortBuffer.put(source, 4, 2);
        assertEquals(4, shortBuffer.get(0));
        assertEquals(5, shortBuffer.get(1));
        assertEquals(6, shortBuffer.get(2));
        assertEquals(7, shortBuffer.get(3));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:position, put
         
        ByteBuffer ibb =
            ByteBuffer.allocateDirect(indices.length * SHORT_BYTES);
        ibb.order(ByteOrder.nativeOrder());
        ShortBuffer shortIndexBuffer = ibb.asShortBuffer();
        shortIndexBuffer.put(indices);
        shortIndexBuffer.position(0);
        this.mIndexBuffer = shortIndexBuffer;
    } 
     
    /** 
     * Copies the given data into the instance 
     * variables mVertexBuffer, mTexcoordBuffer, mNormalBuffer, mColorBuffer, 
     * and mIndexBuffer. 
     *  
     * @param vertices an array of fixed-point vertex coordinates 
     * @param texcoords an array of fixed-point texture coordinates 
     * @param normals an array of fixed-point normal vector coordinates 
     * @param colors an array of fixed-point color channel values 
     * @param indices an array of int indices 
6
CodeRank
This code example shows how to use the following methods:limit, position, remaining, isDirect, order
			return doNoCopyWrap(buffer);
		return buffer;
	} 
 
	public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) {
		if (!buffer.isDirect())
			return doNoCopyWrap(buffer);
		return buffer;
	} 
 
	public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) {
		if (!buffer.isDirect())
			return doNoCopyWrap(buffer);
		return buffer;
	} 
 
	public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) {
		if (!buffer.isDirect())
			return doNoCopyWrap(buffer);
		return buffer;

6
CodeRank

Related Java 8 ShortBuffer Questions & Answers:

See Code Examples for Java 8 ShortBuffer Methods: