com.jogamp.common.nio.Buffers.newDirectByteBuffer()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中com.jogamp.common.nio.Buffers.newDirectByteBuffer()方法的一些代码示例,展示了Buffers.newDirectByteBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffers.newDirectByteBuffer()方法的具体详情如下:
包路径:com.jogamp.common.nio.Buffers
类名称:Buffers
方法名:newDirectByteBuffer

Buffers.newDirectByteBuffer介绍

[英]Allocates a new direct ByteBuffer with the specified number of elements. The returned buffer will have its byte order set to the host platform's native byte order.
[中]使用指定的元素数分配新的direct ByteBuffer。返回的缓冲区将其字节顺序设置为主机平台的本机字节顺序。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private String Log(long device) {
  Utils.pointers[0].rewind();
  int ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_LOG, 0, null, Utils.pointers[0]);
  Utils.checkError(ret, "clGetProgramBuildInfo");
  int count = (int) Utils.pointers[0].get(0);
  final ByteBuffer buffer = newDirectByteBuffer(count);
  ret = cl.clGetProgramBuildInfo(program, device, CL.CL_PROGRAM_BUILD_LOG, buffer.capacity(), buffer, null);
  Utils.checkError(ret, "clGetProgramBuildInfo");
  return CLUtil.clString2JavaString(buffer, count);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

Utils.checkError(ret, "clGetProgramInfo: CL_PROGRAM_BINARY_SIZES");
final ByteBuffer binaries = Buffers.newDirectByteBuffer((int) sizes.get(index));
final PointerBuffer addresses = PointerBuffer.allocateDirect(numDevices);
for (int i=0; i<numDevices; ++i) {

代码示例来源:origin: winder/Universal-G-Code-Sender

/**
 * Initialize or update open gl color array in native buffer objects.
 */
private void updateGLColorArray(GLAutoDrawable drawable) {
  GL2 gl = drawable.getGL().getGL2();
  
  // Reset buffer and set to null of new colors don't fit.
  if (lineColorBuffer != null) {
    lineColorBuffer.clear();
    if (lineColorBuffer.remaining() < lineColorData.length) {
      lineColorBuffer = null;
    }
  }
  
  if (lineColorBuffer == null) {
    lineColorBuffer = Buffers.newDirectByteBuffer(this.lineColorData.length);
  }
  
  lineColorBuffer.put(lineColorData);
  lineColorBuffer.flip();
  gl.glColorPointer( 3, GL.GL_UNSIGNED_BYTE, 0, lineColorBuffer );
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

@Override
public final ColorSpace allocate(final int width, final int height, final ColorSpace sourceCM, final int sourceComponents) throws RuntimeException {
  this.width = width;
  this.height = height;
  this.sourceComponents = sourceComponents;
  this.sourceCS = sourceCM;
  this.data = Buffers.newDirectByteBuffer(width * height * storageComponents);
  return storageCS;
}

代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt

@Override
public final ColorSpace allocate(final int width, final int height, final ColorSpace sourceCM, final int sourceComponents) throws RuntimeException {
  this.width = width;
  this.height = height;
  this.sourceComponents = sourceComponents;
  this.sourceCS = sourceCM;
  this.data = Buffers.newDirectByteBuffer(width * height * storageComponents);
  return storageCS;
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

private CachedBufferFactory(final int initialSize, final int allocationSize) {
  currentBuffer = Buffers.newDirectByteBuffer(initialSize);
  ALLOCATION_SIZE = allocationSize;
}

代码示例来源:origin: org.jogamp.jocl/jocl

@Override
protected ByteBuffer initialValue() {
  return Buffers.newDirectByteBuffer(BB_SIZE);
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/**
 * Allocates a new direct LongBuffer with the specified number of
 * elements. The returned buffer will have its byte order set to
 * the host platform's native byte order.
 */
public static LongBuffer newDirectLongBuffer(final int numElements) {
  return newDirectByteBuffer(numElements * SIZEOF_LONG).asLongBuffer();
}

代码示例来源:origin: nifty-gui/nifty-gui

@Nonnull
@Override
public ByteBuffer createNativeOrderedByteBuffer(final int numBytes) {
 return Buffers.newDirectByteBuffer(numBytes);
}

代码示例来源:origin: org.jogamp.jocl/jocl

protected ByteBuffer getBB(final int minCapacity) {
  if(minCapacity > BB_SIZE) {
    return Buffers.newDirectByteBuffer(minCapacity);
  }else{
    return localBB.get();
  }
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/**
 * Allocates a new direct FloatBuffer with the specified number of
 * elements. The returned buffer will have its byte order set to
 * the host platform's native byte order.
 */
public static FloatBuffer newDirectFloatBuffer(final int numElements) {
  return newDirectByteBuffer(numElements * SIZEOF_FLOAT).asFloatBuffer();
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/**
 * Allocates a new direct IntBuffer with the specified number of
 * elements. The returned buffer will have its byte order set to
 * the host platform's native byte order.
 */
public static IntBuffer newDirectIntBuffer(final int numElements) {
  return newDirectByteBuffer(numElements * SIZEOF_INT).asIntBuffer();
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/**
 * Allocates a new direct DoubleBuffer with the specified number of
 * elements. The returned buffer will have its byte order set to
 * the host platform's native byte order.
 */
public static DoubleBuffer newDirectDoubleBuffer(final int numElements) {
  return newDirectByteBuffer(numElements * SIZEOF_DOUBLE).asDoubleBuffer();
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/**
 * Allocates a new direct ShortBuffer with the specified number of
 * elements. The returned buffer will have its byte order set to
 * the host platform's native byte order.
 */
public static ShortBuffer newDirectShortBuffer(final int numElements) {
  return newDirectByteBuffer(numElements * SIZEOF_SHORT).asShortBuffer();
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

private static final boolean queryIsLittleEndianImpl() {
  final ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order
  final IntBuffer tst_i = tst_b.asIntBuffer();
  final ShortBuffer tst_s = tst_b.asShortBuffer();
  tst_i.put(0, 0x0A0B0C0D);
  return 0x0C0D == tst_s.get(0);
}

代码示例来源:origin: org.jogamp.jocl/jocl

/**
 * Creates a CLBuffer with the specified flags and buffer size in bytes.
 */
public final CLBuffer<ByteBuffer> createByteBuffer(final int size, final int flags) {
  return createBuffer(Buffers.newDirectByteBuffer(size), flags);
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/**
 * Allocates a new direct CharBuffer with the specified number of
 * elements. The returned buffer will have its byte order set to
 * the host platform's native byte order.
 */
public static CharBuffer newDirectCharBuffer(final int numElements) {
  return newDirectByteBuffer(numElements * SIZEOF_SHORT).asCharBuffer();
}

代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub

/** Returns a direct PointerBuffer in native order, w/o backup array */
public static PointerBuffer allocateDirect(final int size) {
  return create(Buffers.newDirectByteBuffer(ELEMENT_SIZE * size));
}

代码示例来源:origin: org.jogamp.jocl/jocl

private int getBuildInfoInt(final CLDevice device, final int flag) {
  final ByteBuffer buffer = newDirectByteBuffer(4);
  final int ret = binding.clGetProgramBuildInfo(ID, device.ID, flag, buffer.capacity(), buffer, null);
  checkForError(ret, "error on clGetProgramBuildInfo");
  return buffer.getInt();
}

代码示例来源:origin: org.jogamp.jocl/jocl

private String getProgramInfoString(final int flag) {
  if(released) {
    return "";
  }
  final PointerBuffer size = PointerBuffer.allocateDirect(1);
  int ret = binding.clGetProgramInfo(ID, flag, 0, null, size);
  checkForError(ret, "on clGetProgramInfo");
  final ByteBuffer buffer = newDirectByteBuffer((int)size.get(0));
  ret = binding.clGetProgramInfo(ID, flag, buffer.capacity(), buffer, null);
  checkForError(ret, "on clGetProgramInfo");
  return CLUtil.clString2JavaString(buffer, (int)size.get(0));
}

相关文章