当前位置: 首页>>代码示例>>Java>>正文


Java ShortBuffer.position方法代码示例

本文整理汇总了Java中java.nio.ShortBuffer.position方法的典型用法代码示例。如果您正苦于以下问题:Java ShortBuffer.position方法的具体用法?Java ShortBuffer.position怎么用?Java ShortBuffer.position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ShortBuffer的用法示例。


在下文中一共展示了ShortBuffer.position方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: IndexBuffer

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public IndexBuffer(short[] vertexData) {
    final int buffers[] = new int[1];
    glGenBuffers(buffers.length, buffers, 0);
    if (buffers[0] == 0) {
        throw new RuntimeException("Could not create a new buffer");
    }
    bufferId = buffers[0];

    //bind to the buffer
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[0]);

    //transfer data to native memory
    ShortBuffer vertexArray = ByteBuffer.allocateDirect(vertexData.length * BYTE_PER_SHORT)
            .order(ByteOrder.nativeOrder())
            .asShortBuffer()
            .put(vertexData);
    vertexArray.position(0);

    //transfer data from native memory to the GPU buffer
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, vertexArray.capacity() * BYTE_PER_SHORT, vertexArray, GL_STATIC_DRAW);

    //Unbind from the buffer when we're done with it
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
 
开发者ID:yjp123456,项目名称:3D_Wallpaper,代码行数:25,代码来源:IndexBuffer.java

示例2: ensureLargeEnough

import java.nio.ShortBuffer; //导入方法依赖的package包/类
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;
}
 
开发者ID:asiermarzo,项目名称:Ultraino,代码行数:17,代码来源:BufferUtils.java

示例3: setData

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public void setData(short[] in) {
    validate(); 
    ShortBuffer buffer = ShortBuffer.wrap(in); 
    buffer.position(in.length - 1); 
    buffer.flip(); 
    oal.alBufferData(id[0], OalConvert.getFormat(stereo, sixteenBit), buffer, in.length * 2 - 4, frequency);
}
 
开发者ID:HuskyGameDev,项目名称:2017-TeamEngine,代码行数:8,代码来源:OalAudioClip.java

示例4: createShortBuffer

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer createShortBuffer(short[] coords) {
    ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * SIZEOF_SHORT);
    bb.order(ByteOrder.nativeOrder());
    ShortBuffer ib = bb.asShortBuffer();
    ib.put(coords);
    ib.position(0);
    return ib;
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:9,代码来源:OpenGlUtils.java

示例5: createIbo

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static int createIbo(ShortBuffer data) {
  int[] ibos = new int[1];
  data.position(0);
  GLES20.glGenBuffers(1, ibos, 0);
  GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, ibos[0]);
  GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, data.capacity() * MyGLUtils.SHORT_SIZE,
      data, GLES20.GL_STATIC_DRAW);
  GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
  return ibos[0];
}
 
开发者ID:googlevr,项目名称:poly-sample-android,代码行数:11,代码来源:MyGLUtils.java

示例6: getShortBuffer

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer getShortBuffer(final short[] array, int offset){
    ShortBuffer bb=ByteBuffer.allocateDirect(
            array.length * SHORT_SIZE_BYTES)
            .order(ByteOrder.nativeOrder())
            .asShortBuffer()
            .put(array);
    bb.position(offset);
    return bb;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:10,代码来源:BufferUtils.java

示例7: initAllNames

import java.nio.ShortBuffer; //导入方法依赖的package包/类
protected void initAllNames(int requestedID, HashSet names) {

        byte[] name = new byte[256];
        ByteBuffer buffer = getTableBuffer(nameTag);

        if (buffer != null) {
            ShortBuffer sbuffer = buffer.asShortBuffer();
            sbuffer.get(); // format - not needed.
            short numRecords = sbuffer.get();

            /* The name table uses unsigned shorts. Many of these
             * are known small values that fit in a short.
             * The values that are sizes or offsets into the table could be
             * greater than 32767, so read and store those as ints
             */
            int stringPtr = ((int) sbuffer.get()) & 0xffff;
            for (int i=0; i<numRecords; i++) {
                short platformID = sbuffer.get();
                if (platformID != MS_PLATFORM_ID) {
                    sbuffer.position(sbuffer.position()+5);
                    continue; // skip over this record.
                }
                short encodingID = sbuffer.get();
                short langID     = sbuffer.get();
                short nameID     = sbuffer.get();
                int   nameLen    = ((int) sbuffer.get()) & 0xffff;
                int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;

                if (nameID == requestedID) {
                    buffer.position(namePtr);
                    buffer.get(name, 0, nameLen);
                    names.add(makeString(name, nameLen, encodingID));
                }
            }
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:TrueTypeFont.java

示例8: ShortBufferUtil

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private ShortBuffer ShortBufferUtil(short[] arr) {
	ByteBuffer dlb = ByteBuffer.allocateDirect(arr.length * 2);
	dlb.order(ByteOrder.nativeOrder());
	ShortBuffer buffer = dlb.asShortBuffer();
	buffer.put(arr);
	buffer.position(0);

	return buffer;
}
 
开发者ID:FacePlusPlus,项目名称:MegviiFacepp-Android-SDK,代码行数:10,代码来源:CameraMatrix.java

示例9: initAllNames

import java.nio.ShortBuffer; //导入方法依赖的package包/类
protected void initAllNames(int requestedID, HashSet<String> names) {

        byte[] name = new byte[256];
        ByteBuffer buffer = getTableBuffer(nameTag);

        if (buffer != null) {
            ShortBuffer sbuffer = buffer.asShortBuffer();
            sbuffer.get(); // format - not needed.
            short numRecords = sbuffer.get();

            /* The name table uses unsigned shorts. Many of these
             * are known small values that fit in a short.
             * The values that are sizes or offsets into the table could be
             * greater than 32767, so read and store those as ints
             */
            int stringPtr = ((int) sbuffer.get()) & 0xffff;
            for (int i=0; i<numRecords; i++) {
                short platformID = sbuffer.get();
                if (platformID != MS_PLATFORM_ID) {
                    sbuffer.position(sbuffer.position()+5);
                    continue; // skip over this record.
                }
                short encodingID = sbuffer.get();
                short langID     = sbuffer.get();
                short nameID     = sbuffer.get();
                int   nameLen    = ((int) sbuffer.get()) & 0xffff;
                int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;

                if (nameID == requestedID) {
                    buffer.position(namePtr);
                    buffer.get(name, 0, nameLen);
                    names.add(makeString(name, nameLen, platformID, encodingID));
                }
            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:TrueTypeFont.java

示例10: getIndices

import java.nio.ShortBuffer; //导入方法依赖的package包/类
public static ShortBuffer getIndices( int size ) {

		ShortBuffer indices = cache.get(size);
		if (indices == null) {
			
			// TODO: Optimize it!
			
			indices = ByteBuffer.
				allocateDirect( size * SIZE * Short.SIZE / 8 ).
				order( ByteOrder.nativeOrder() ).
				asShortBuffer();
			
			short[] values = new short[size * 6];
			int pos = 0;
			int limit = size * 4;
			for (int ofs=0; ofs < limit; ofs += 4) {
				values[pos++] = (short)(ofs + 0);
				values[pos++] = (short)(ofs + 1);
				values[pos++] = (short)(ofs + 2);
				values[pos++] = (short)(ofs + 0);
				values[pos++] = (short)(ofs + 2);
				values[pos++] = (short)(ofs + 3);
			}
			
			indices.put( values );
			indices.position( 0 );

			cache.put(size, indices);
		}

		return indices;
	}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:33,代码来源:Quad.java

示例11: lookupName

import java.nio.ShortBuffer; //导入方法依赖的package包/类
protected String lookupName(short findLocaleID, int findNameID) {
    String foundName = null;
    byte[] name = new byte[1024];

    ByteBuffer buffer = getTableBuffer(nameTag);
    if (buffer != null) {
        ShortBuffer sbuffer = buffer.asShortBuffer();
        sbuffer.get(); // format - not needed.
        short numRecords = sbuffer.get();

        /* The name table uses unsigned shorts. Many of these
         * are known small values that fit in a short.
         * The values that are sizes or offsets into the table could be
         * greater than 32767, so read and store those as ints
         */
        int stringPtr = ((int) sbuffer.get()) & 0xffff;

        for (int i=0; i<numRecords; i++) {
            short platformID = sbuffer.get();
            if (platformID != MS_PLATFORM_ID) {
                sbuffer.position(sbuffer.position()+5);
                continue; // skip over this record.
            }
            short encodingID = sbuffer.get();
            short langID     = sbuffer.get();
            short nameID     = sbuffer.get();
            int   nameLen    = ((int) sbuffer.get()) & 0xffff;
            int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
            if (nameID == findNameID &&
                ((foundName == null && langID == ENGLISH_LOCALE_ID)
                 || langID == findLocaleID)) {
                buffer.position(namePtr);
                buffer.get(name, 0, nameLen);
                foundName = makeString(name, nameLen, encodingID);
                if (langID == findLocaleID) {
                    return foundName;
                }
            }
        }
    }
    return foundName;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:TrueTypeFont.java

示例12: lookupName

import java.nio.ShortBuffer; //导入方法依赖的package包/类
protected String lookupName(short findLocaleID, int findNameID) {
    String foundName = null;
    byte[] name = new byte[1024];

    ByteBuffer buffer = getTableBuffer(nameTag);
    if (buffer != null) {
        ShortBuffer sbuffer = buffer.asShortBuffer();
        sbuffer.get(); // format - not needed.
        short numRecords = sbuffer.get();

        /* The name table uses unsigned shorts. Many of these
         * are known small values that fit in a short.
         * The values that are sizes or offsets into the table could be
         * greater than 32767, so read and store those as ints
         */
        int stringPtr = ((int) sbuffer.get()) & 0xffff;

        for (int i=0; i<numRecords; i++) {
            short platformID = sbuffer.get();
            if (platformID != MS_PLATFORM_ID) {
                sbuffer.position(sbuffer.position()+5);
                continue; // skip over this record.
            }
            short encodingID = sbuffer.get();
            short langID     = sbuffer.get();
            short nameID     = sbuffer.get();
            int   nameLen    = ((int) sbuffer.get()) & 0xffff;
            int   namePtr    = (((int) sbuffer.get()) & 0xffff) + stringPtr;
            if (nameID == findNameID &&
                ((foundName == null && langID == ENGLISH_LOCALE_ID)
                 || langID == findLocaleID)) {
                buffer.position(namePtr);
                buffer.get(name, 0, nameLen);
                foundName = makeString(name, nameLen, platformID, encodingID);
                if (langID == findLocaleID) {
                    return foundName;
                }
            }
        }
    }
    return foundName;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:TrueTypeFont.java


注:本文中的java.nio.ShortBuffer.position方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。