Code example for ShortBuffer

Methods: position, put

0
 
	protected static ShortBuffer makeShortBuffer(short[] arr) {
		ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 2);
		bb.order(ByteOrder.nativeOrder());
		ShortBuffer ib = bb.asShortBuffer();
		ib.put(arr);
		ib.position(0);
		return ib;
	} 
 
	public void loadTexture(GL10 gl, Context mContext, int mTex) {
		hasTexture = true;
		gl.glGenTextures(1, mTexture, 0);
		gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture[0]);
		Bitmap bitmap;
		bitmap = BitmapFactory.decodeResource(mContext.getResources(), mTex);
		//gl.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels) 
		Log.i("SM", "bitmap width: " +  bitmap.getWidth());
		Log.i("SM", "bitmap height: " +  bitmap.getHeight());
		gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, bitmap.getWidth(), bitmap.getHeight(), 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, extract(bitmap));
		//GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);