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


Java BufferUtils.createByteBuffer方法代码示例

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


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

示例1: startChange

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Start making changes.
 */
private void startChange() {

    final Array<ColorPoint> colorPoints = getColorPoints();
    colorPoints.clear();

    final Texture alphaTexture = notNull(getAlphaTexture());
    final Image image = alphaTexture.getImage();
    final ByteBuffer data = image.getData(0);

    if (prevBuffer == null) {
        prevBuffer = BufferUtils.createByteBuffer(data.capacity());
    } else if (prevBuffer.capacity() < data.capacity()) {
        BufferUtils.destroyDirectBuffer(prevBuffer);
        prevBuffer = BufferUtils.createByteBuffer(data.capacity());
    }

    final int position = data.position();
    data.position(0);
    prevBuffer.clear();
    prevBuffer.put(data);
    prevBuffer.flip();
    data.position(position);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:27,代码来源:PaintTerrainToolControl.java

示例2: JfxRenderer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public JfxRenderer(ImageView imageView, int width, int height, boolean depthBuffer) {
    this.imageView = imageView;
    this.width = width;
    this.height = height;
    this.byteBuffer = BufferUtils.createByteBuffer(width * height * 4);
    this.scanlineStride = width * 4;
    this.renderImage = new WritableImage(width, height);
    this.imageView.setImage(renderImage);
    if (depthBuffer) {
        frameBuffer = new FrameBuffer(width, height, 1);
        frameBuffer.setDepthBuffer(Format.Depth);
        frameBuffer.setColorBuffer(Format.BGRA8);
    } else {
        frameBuffer = null;
    }
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:17,代码来源:JfxRenderer.java

示例3: ImageCapturer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public ImageCapturer(Camera cam, RenderManager renderManager, Node camNode, Node rootNode) {
        this.cam = cam;
        this.renderManager = renderManager;
        this.camNode = camNode;

//        bbuf = BufferUtils.createByteBuffer(cam.getWidth() * cam.getHeight() * 4);
        bbuf = BufferUtils.createByteBuffer(cam.getWidth() * cam.getHeight() * 4);
        image = new BufferedImage(cam.getWidth(), cam.getHeight(), IMAGE_TYPE);

        vp = renderManager.createPreView(cam.getName() + " recorder", cam);
        vp.setBackgroundColor(ColorRGBA.Black);
        vp.setClearFlags(true, true, true);
        fbuf = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
        fbuf.setDepthBuffer(Format.Depth);
        fbuf.setColorBuffer(Format.RGBA8);
        vp.setOutputFrameBuffer(fbuf);
        vp.attachScene(rootNode);                
    }
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:19,代码来源:ImageCapturer.java

示例4: createBuffer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private java.nio.Buffer createBuffer(int size) {
	switch (format) {
		case Byte:
		case UnsignedByte:
			return BufferUtils.createByteBuffer(size);
		case Double: return BufferUtils.createDoubleBuffer(size);
		case Float: return BufferUtils.createFloatBuffer(size);
		case Half:
		case Short:
		case UnsignedShort:
			return BufferUtils.createShortBuffer(size);
		case Int:
		case UnsignedInt:
			return BufferUtils.createIntBuffer(size);
		default:
			throw new IllegalArgumentException("unknown format "+format);
	}
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:19,代码来源:SharedBuffer.java

示例5: createKeysValues

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void createKeysValues(int size, int maxValue) {
	//create keys and values
	System.out.println("create keys and values");
	keyOriginal = new int[size];
	valueOriginal = new int[size];
	for (int i=0; i<size; ++i) {
		int key = rand.nextInt(maxValue);
		int value = i+1;
		keyOriginal[i] = key;
		valueOriginal[i] = value;
	}
	System.out.println("keys and values created");
	//create buffers
	System.out.println("create buffers");
	keyBuffer = clContext.createBuffer(size * 4);
	valueBuffer = clContext.createBuffer(size * 4);
	ByteBuffer bb = BufferUtils.createByteBuffer(size * 4);
	bb.asIntBuffer().put(keyOriginal);
	keyBuffer.write(clCommandQueue, bb);
	bb.asIntBuffer().put(valueOriginal);
	valueBuffer.write(clCommandQueue, bb);
	System.out.println("buffers created");
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:24,代码来源:SortingTest.java

示例6: lwjglBody

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public void lwjglBody(int gl_format, Texture tx, Texel ir, int mipmap, int slice, Map<String,String> options, DDS_HEADER header, DDS_BODY body) throws Exception {

		IntBuffer intBuf1=BufferUtils.createIntBuffer(1);
		glGenTextures(intBuf1);
		int id=intBuf1.get(0);

		glBindTexture(GL_TEXTURE_2D,id);

		Vector4f pixels[][]=ir.getPixels(PixelFormat.FLOAT_NORMALIZED_RGBA);

		FloatBuffer bbf=BufferUtils.createFloatBuffer(pixels.length*pixels[0].length*4);
		for(int y=0;y<pixels[0].length;y++){
			for(int x=0;x<pixels.length;x++){
				bbf.put(pixels[x][y].x);
				bbf.put(pixels[x][y].y);
				bbf.put(pixels[x][y].z);
				bbf.put(pixels[x][y].w);
			}
		}
		bbf.rewind();
		glTexImage2D(GL_TEXTURE_2D,0,gl_format,pixels.length,pixels[0].length,0,GL_RGBA,GL_FLOAT,bbf);

		int out_size=glGetTexLevelParameteri(GL_TEXTURE_2D,0,GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB);
		ByteBuffer out=BufferUtils.createByteBuffer(out_size);
//		glGetCompressedTexImageARB(GL_TEXTURE_2D,0,out);
		glGetCompressedTexImage(GL_TEXTURE_2D,0,out);
		byte bytes[]=new byte[out_size];
		out.rewind();
		out.get(bytes);
		body.write(bytes);
		BufferUtils.destroyDirectBuffer(out);

		BufferUtils.destroyDirectBuffer(bbf);
		glBindTexture(GL_TEXTURE_2D,0);
		glDeleteTextures(id);
	}
 
开发者ID:riccardobl,项目名称:DDSWriter,代码行数:37,代码来源:LWJGLBlockCompressionDelegate.java

示例7: convertToHalf

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
 * Converts single floating-point data to {@link Format#Half half} floating-point data.
 */
public void convertToHalf(){
    if (id != -1)
        throw new UnsupportedOperationException("Data has already been sent.");

    if (format != Format.Float)
        throw new IllegalStateException("Format must be float!");

    int numElements = data.capacity() / components;
    format = Format.Half;
    this.componentsLength = components * format.getComponentSize();
    
    ByteBuffer halfData = BufferUtils.createByteBuffer(componentsLength * numElements);
    halfData.rewind();

    FloatBuffer floatData = (FloatBuffer) data;
    floatData.rewind();

    for (int i = 0; i < floatData.capacity(); i++){
        float f = floatData.get(i);
        short half = FastMath.convertFloatToHalf(f);
        halfData.putShort(half);
    }
    this.data = halfData;
    setUpdateNeeded();
    dataSizeChanged = true;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:VertexBuffer.java

示例8: startBoneAssigns

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void startBoneAssigns() {
    if (mesh != sharedMesh && usesSharedVerts) {
        // will use bone assignments from shared mesh (?)
        return;
    }

    // current mesh will have bone assigns
    //int vertCount = mesh.getVertexCount();
    // each vertex has
    // - 4 bone weights
    // - 4 bone indices
    if (HARDWARE_SKINNING) {
        weightsFloatData = BufferUtils.createFloatBuffer(vertCount * 4);
        indicesData = BufferUtils.createByteBuffer(vertCount * 4);
    } else {
        // create array-backed buffers if software skinning for access speed
        weightsFloatData = FloatBuffer.allocate(vertCount * 4);
        indicesData = ByteBuffer.allocate(vertCount * 4);
    }
    
    VertexBuffer weights = new VertexBuffer(Type.BoneWeight);
    VertexBuffer indices = new VertexBuffer(Type.BoneIndex);

    Usage usage = HARDWARE_SKINNING ? Usage.Static : Usage.CpuOnly;
    weights.setupData(usage, 4, Format.Float, weightsFloatData);
    indices.setupData(usage, 4, Format.UnsignedByte, indicesData);

    mesh.setBuffer(weights);
    mesh.setBuffer(indices);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:MeshLoader.java

示例9: RenderDeviceJme

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public RenderDeviceJme(NiftyJmeDisplay display){
    this.display = display;

    quadColor = new VertexBuffer(Type.Color);
    quadColor.setNormalized(true);
    ByteBuffer bb = BufferUtils.createByteBuffer(4 * 4);
    quadColor.setupData(Usage.Stream, 4, Format.UnsignedByte, bb);
    quad.setBuffer(quadColor);

    quadModTC.setUsage(Usage.Stream);

    niftyMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/Nifty.j3md");
    niftyMat.getAdditionalRenderState().setDepthTest(false);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:RenderDeviceJme.java

示例10: initParticleData

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
@Override
public void initParticleData(ParticleEmitter emitter, int numParticles) {
    setMode(Mode.Points);

    this.emitter = emitter;

    // set positions
    FloatBuffer pb = BufferUtils.createVector3Buffer(numParticles);
    VertexBuffer pvb = new VertexBuffer(VertexBuffer.Type.Position);
    pvb.setupData(Usage.Stream, 3, Format.Float, pb);
    setBuffer(pvb);

    // set colors
    ByteBuffer cb = BufferUtils.createByteBuffer(numParticles * 4);
    VertexBuffer cvb = new VertexBuffer(VertexBuffer.Type.Color);
    cvb.setupData(Usage.Stream, 4, Format.UnsignedByte, cb);
    cvb.setNormalized(true);
    setBuffer(cvb);

    // set sizes
    FloatBuffer sb = BufferUtils.createFloatBuffer(numParticles);
    VertexBuffer svb = new VertexBuffer(VertexBuffer.Type.Size);
    svb.setupData(Usage.Stream, 1, Format.Float, sb);
    setBuffer(svb);

    // set UV-scale
    FloatBuffer tb = BufferUtils.createFloatBuffer(numParticles*4);
    VertexBuffer tvb = new VertexBuffer(VertexBuffer.Type.TexCoord);
    tvb.setupData(Usage.Stream, 4, Format.Float, tb);
    setBuffer(tvb);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:ParticlePointMesh.java

示例11: flipImage

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public static void flipImage(Image img, int index){
    if (img.getFormat().isCompressed())
        throw new UnsupportedOperationException("Flipping compressed " +
                                                "images is unsupported.");

    int w = img.getWidth();
    int h = img.getHeight();
    int halfH = h / 2;

    // bytes per pixel
    int bpp = img.getFormat().getBitsPerPixel() / 8;
    int scanline = w * bpp;

    ByteBuffer data = img.getData(index);
    ByteBuffer temp = BufferUtils.createByteBuffer(scanline);
    
    data.rewind();
    for (int y = 0; y < halfH; y++){
        int oppY = h - y - 1;
        // read in scanline
        data.position(y * scanline);
        data.limit(data.position() + scanline);

        temp.rewind();
        temp.put(data);

    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:ImageFlipper.java

示例12: checkSorted

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void checkSorted(int size) {
	int[] keys = new int[size];
	int[] values = new int[size];
	ByteBuffer bb = BufferUtils.createByteBuffer(size * 4);
	keyBuffer.read(clCommandQueue, bb);
	bb.asIntBuffer().get(keys);
	valueBuffer.read(clCommandQueue, bb);
	bb.asIntBuffer().get(values);
	
	checkSorted(size, keys, values);
}
 
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:12,代码来源:SortingTest.java

示例13: readToBuffer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private ByteBuffer readToBuffer() throws IOException{
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    byte[] buf = new byte[512];
    int read = 0;

    try {
        while ( (read = vorbisStream.readPcm(buf, 0, buf.length)) > 0){
            baos.write(buf, 0, read);
        }
    } catch (EndOfOggStreamException ex){
    }

   
    byte[] dataBytes = baos.toByteArray();
    swapBytes(dataBytes, 0, dataBytes.length);
    
    int bytesToCopy = getOggTotalBytes( dataBytes.length );

    ByteBuffer data = BufferUtils.createByteBuffer(bytesToCopy);
    data.put(dataBytes, 0, bytesToCopy).flip();

    vorbisStream.close();
    loStream.close();
    oggStream.close();

    return data;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:OGGLoader.java

示例14: readDataChunkForBuffer

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void readDataChunkForBuffer(int len) throws IOException {
    ByteBuffer data = BufferUtils.createByteBuffer(len);
    byte[] buf = new byte[512];
    int read = 0;
    while ( (read = in.read(buf)) > 0){
        data.put(buf, 0, Math.min(read, data.remaining()) );
    }
    data.flip();
    audioBuffer.updateData(data);
    in.close();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:WAVLoader.java

示例15: convertToUByte

import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public static VertexBuffer convertToUByte(VertexBuffer vb){
    FloatBuffer fb = (FloatBuffer) vb.getData();
    ByteBuffer bb = BufferUtils.createByteBuffer(fb.capacity());
    convertToUByte(fb, bb);

    VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
    newVb.setupData(vb.getUsage(),
                    vb.getNumComponents(),
                    Format.UnsignedByte,
                    bb);
    newVb.setNormalized(true);
    return newVb;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:FloatToFixed.java


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