本文整理了Java中com.jogamp.common.nio.Buffers.sizeOfBufferElem()
方法的一些代码示例,展示了Buffers.sizeOfBufferElem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffers.sizeOfBufferElem()
方法的具体详情如下:
包路径:com.jogamp.common.nio.Buffers
类名称:Buffers
方法名:sizeOfBufferElem
[英]Returns the size of a single element of the given buffer in bytes or 0
if the given buffer is null
.
[中]
代码示例来源:origin: org.jogamp.jocl/jocl
private void initElementSize() {
this.elementSize = (buffer==null) ? 1 : Buffers.sizeOfBufferElem(buffer);
}
代码示例来源:origin: org.jogamp.jocl/jocl
/**
* Returns the offset of this sub buffer to its parent in buffer elements.
*/
public int getOffset() {
final int elemSize = buffer==null ? 1 : Buffers.sizeOfBufferElem(buffer);
return offset/elemSize;
}
代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub
protected static int estimatedMemorySize(final Buffer buffer) {
if (buffer == null) {
return 0;
}
return buffer.capacity() * Buffers.sizeOfBufferElem(buffer);
}
}
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
protected static int estimatedMemorySize(final Buffer buffer) {
if (buffer == null) {
return 0;
}
return buffer.capacity() * Buffers.sizeOfBufferElem(buffer);
}
}
代码示例来源:origin: org.jogamp.jogl/jogl
/**
* @param pixelAttributes the desired {@link GLPixelAttributes}
* @param pack {@code true} for read mode GPU -> CPU, e.g. {@link GL#glReadPixels(int, int, int, int, int, int, Buffer) glReadPixels}.
* {@code false} for write mode CPU -> GPU, e.g. {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, Buffer) glTexImage2D}.
* @param width in pixels
* @param height in pixels
* @param depth in pixels
* @param buffer the backing array
* @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}.
* @param hostPixelComp the host {@link PixelFormat.Composition}
*/
public GLPixelBuffer(final GLPixelAttributes pixelAttributes, final boolean pack, final int width, final int height, final int depth, final Buffer buffer, final boolean allowRowStride) {
this.pixelAttributes = pixelAttributes;
this.width = width;
this.height = height;
this.depth = depth;
this.pack = pack;
this.buffer = buffer;
this.byteSize = Buffers.remainingBytes(buffer);
this.bufferElemSize = Buffers.sizeOfBufferElem(buffer);
this.allowRowStride = allowRowStride;
}
代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub
/**
* @param pixelAttributes the desired {@link GLPixelAttributes}
* @param width in pixels
* @param height in pixels
* @param depth in pixels
* @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU
* @param buffer the backing array
* @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}.
*/
public GLPixelBuffer(final GLPixelAttributes pixelAttributes, final int width, final int height, final int depth, final boolean pack, final Buffer buffer, final boolean allowRowStride) {
this.pixelAttributes = pixelAttributes;
this.width = width;
this.height = height;
this.depth = depth;
this.pack = pack;
this.buffer = buffer;
this.byteSize = Buffers.remainingBytes(buffer);
this.bufferElemSize = Buffers.sizeOfBufferElem(buffer);
this.allowRowStride = allowRowStride;
}
代码示例来源:origin: org.jogamp.jogl/jogl-all-noawt
/**
* @param pixelAttributes the desired {@link GLPixelAttributes}
* @param pack {@code true} for read mode GPU -> CPU, e.g. {@link GL#glReadPixels(int, int, int, int, int, int, Buffer) glReadPixels}.
* {@code false} for write mode CPU -> GPU, e.g. {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, Buffer) glTexImage2D}.
* @param width in pixels
* @param height in pixels
* @param depth in pixels
* @param buffer the backing array
* @param allowRowStride If <code>true</code>, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}.
* @param hostPixelComp the host {@link PixelFormat.Composition}
*/
public GLPixelBuffer(final GLPixelAttributes pixelAttributes, final boolean pack, final int width, final int height, final int depth, final Buffer buffer, final boolean allowRowStride) {
this.pixelAttributes = pixelAttributes;
this.width = width;
this.height = height;
this.depth = depth;
this.pack = pack;
this.buffer = buffer;
this.byteSize = Buffers.remainingBytes(buffer);
this.bufferElemSize = Buffers.sizeOfBufferElem(buffer);
this.allowRowStride = allowRowStride;
}
代码示例来源:origin: com.ardor3d/ardor3d-jogl
final int destPos = dest.position();
final int bytesPerPixel = dataSizeInBytes / (width * height);
final int bytesPerElement = Buffers.sizeOfBufferElem(src);
final int elementsPerPixel = bytesPerPixel / bytesPerElement;
final int elementsPerLine = width * elementsPerPixel;
代码示例来源:origin: org.jogamp.jocl/jocl
static <B extends Buffer> CLBuffer<B> create(final CLContext context, final B directBuffer, final int flags) {
if(!directBuffer.isDirect())
throw new IllegalArgumentException("buffer is not direct");
B host_ptr = null;
if(isHostPointerFlag(flags)) {
host_ptr = directBuffer;
}
final CLBufferBinding binding = context.getPlatform().getBufferBinding();
final int[] result = new int[1];
final int size = Buffers.sizeOfBufferElem(directBuffer) * directBuffer.capacity();
final long id = binding.clCreateBuffer(context.ID, flags, size, host_ptr, result, 0);
CLException.checkForError(result[0], "can not create cl buffer");
return new CLBuffer<B>(context, directBuffer, size, id, flags);
}
代码示例来源:origin: org.jogamp.jocl/jocl
if(buffer != null) {
slice = Buffers.slice(buffer, offset, size);
final int elemSize = Buffers.sizeOfBufferElem(buffer);
offset *= elemSize;
size *= elemSize;
代码示例来源:origin: com.ardor3d/ardor3d-jogl
@Override
public Image load(final InputStream is, final boolean flipped) throws IOException {
final TextureData textureData = TextureIO.newTextureData(_capsUtil.getProfile(), is, true, null);
final Buffer textureDataBuffer = textureData.getBuffer();
final Image ardorImage = new Image();
final TYPE bufferDataType = getBufferDataType(textureDataBuffer);
if (bufferDataType == null) {
throw new UnsupportedOperationException("Unknown buffer type " + textureDataBuffer.getClass().getName());
} else {
final int dataSizeInBytes = textureDataBuffer.capacity() * Buffers.sizeOfBufferElem(textureDataBuffer);
final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(dataSizeInBytes) : Buffers
.newDirectByteBuffer(dataSizeInBytes);
if (flipped) {
flipImageData(textureDataBuffer, scratch, dataSizeInBytes, bufferDataType, textureData.getWidth(),
textureData.getHeight());
} else {
copyImageData(textureDataBuffer, scratch, bufferDataType);
}
ardorImage.setWidth(textureData.getWidth());
ardorImage.setHeight(textureData.getHeight());
ardorImage.setData(scratch);
ardorImage.setDataFormat(JoglTextureUtil.getImageDataFormat(textureData.getPixelFormat()));
// ardorImage.setDataType(JoglTextureUtil.getPixelDataType(textureData.getPixelType()));
ardorImage.setDataType(PixelDataType.UnsignedByte);
return ardorImage;
}
}
内容来源于网络,如有侵权,请联系作者删除!