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

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

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

Buffers.copyByteBuffer介绍

[英]Copies the remaining elements (as defined by limit() - position()) in the passed ByteBuffer into a newly-allocated direct ByteBuffer. The returned buffer will have its byte order set to the host platform's native byte order. The position of the newly-allocated buffer will be zero, and the position of the passed buffer is unchanged.
[中]将传递的ByteBuffer中的剩余元素(由limit() - position()定义)复制到新分配的直接ByteBuffer中。返回的缓冲区将其字节顺序设置为主机平台的本机字节顺序。新分配的缓冲区的位置将为零,传递的缓冲区的位置不变。

代码示例

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

private final ByteBuffer copyToByteBuffer(Buffer buf) {
 if (buf instanceof ByteBuffer) {
  if (buf.position() == 0) {
   return (ByteBuffer) buf;
  }
  return Buffers.copyByteBuffer((ByteBuffer) buf);
 } else if (buf instanceof ShortBuffer) {
  return Buffers.copyShortBufferAsByteBuffer((ShortBuffer) buf);
 } else if (buf instanceof IntBuffer) {
  return Buffers.copyIntBufferAsByteBuffer((IntBuffer) buf);
 } else if (buf instanceof FloatBuffer) {
  return Buffers.copyFloatBufferAsByteBuffer((FloatBuffer) buf);
 } else {
  throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)");
 }
}

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

private final ByteBuffer copyToByteBuffer(Buffer buf) {
 if (buf instanceof ByteBuffer) {
  if (buf.position() == 0) {
   return (ByteBuffer) buf;
  }
  return Buffers.copyByteBuffer((ByteBuffer) buf);
 } else if (buf instanceof ShortBuffer) {
  return Buffers.copyShortBufferAsByteBuffer((ShortBuffer) buf);
 } else if (buf instanceof IntBuffer) {
  return Buffers.copyIntBufferAsByteBuffer((IntBuffer) buf);
 } else if (buf instanceof FloatBuffer) {
  return Buffers.copyFloatBufferAsByteBuffer((FloatBuffer) buf);
 } else {
  throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)");
 }
}

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

private final java.nio.ByteBuffer copyToByteBuffer(java.nio.Buffer buf) {
 if (buf instanceof java.nio.ByteBuffer) {
  if (buf.position() == 0) {
   return (java.nio.ByteBuffer) buf;
  }
  return Buffers.copyByteBuffer((java.nio.ByteBuffer) buf);
 } else if (buf instanceof java.nio.ShortBuffer) {
  return Buffers.copyShortBufferAsByteBuffer((java.nio.ShortBuffer) buf);
 } else if (buf instanceof java.nio.IntBuffer) {
  return Buffers.copyIntBufferAsByteBuffer((java.nio.IntBuffer) buf);
 } else if (buf instanceof java.nio.FloatBuffer) {
  return Buffers.copyFloatBufferAsByteBuffer((java.nio.FloatBuffer) buf);
 } else {
  throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)");
 }
}

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

private final java.nio.ByteBuffer copyToByteBuffer(java.nio.Buffer buf) {
 if (buf instanceof java.nio.ByteBuffer) {
  if (buf.position() == 0) {
   return (java.nio.ByteBuffer) buf;
  }
  return Buffers.copyByteBuffer((java.nio.ByteBuffer) buf);
 } else if (buf instanceof java.nio.ShortBuffer) {
  return Buffers.copyShortBufferAsByteBuffer((java.nio.ShortBuffer) buf);
 } else if (buf instanceof java.nio.IntBuffer) {
  return Buffers.copyIntBufferAsByteBuffer((java.nio.IntBuffer) buf);
 } else if (buf instanceof java.nio.FloatBuffer) {
  return Buffers.copyFloatBufferAsByteBuffer((java.nio.FloatBuffer) buf);
 } else {
  throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)");
 }
}

代码示例来源:origin: matsim-org/matsim

@Override
public void draw(OTFOGLDrawer drawer) {
  if(this.vertex == null) return;
  GL2 gl = OTFGLAbstractDrawable.getGl();
  this.vert = Buffers.copyFloatBuffer(FloatBuffer.wrap(this.vertex));
  this.cols = Buffers.copyByteBuffer(ByteBuffer.wrap(this.colors));
  rewindGLBuffers();
  prepare(gl);
  unPrepare(gl);
}

相关文章