Java Code Examples for com.jme3.util.BufferUtils#destroyDirectBuffer()

The following examples show how to use com.jme3.util.BufferUtils#destroyDirectBuffer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaintTerrainToolControl.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Start making changes.
 */
@JmeThread
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);
}
 
Example 2
Source File: TestUseAfterFree.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    if (time < 0) {
        if (deletedTex != null) {
            deletedTex.getImage().resetObject();
        }
        return;
    }
    
    time += tpf;
    if (time > 5) {
        System.out.println("Assigning texture to deleted object!");
        
        deletedTex = assetManager.loadTexture("Interface/Logo/Monkey.png");
        BufferUtils.destroyDirectBuffer(deletedTex.getImage().getData(0));
        mat.setTexture("ColorMap", deletedTex);
        
        time = -1;
    }
}
 
Example 3
Source File: AWTComponentRenderer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Dispose this renderer. The underlying frame buffer is also disposed.
 */
public void dispose() {
  while (!frameState.compareAndSet(WAITING_STATE, DISPOSING_STATE)) ;
  while (!imageState.compareAndSet(WAITING_STATE, DISPOSING_STATE)) ;
  frameBuffer.dispose();
  BufferUtils.destroyDirectBuffer(frameByteBuffer);
  frameState.compareAndSet(DISPOSING_STATE, DISPOSED_STATE);
  imageState.compareAndSet(DISPOSING_STATE, DISPOSED_STATE);
}
 
Example 4
Source File: TestReleaseDirectMemory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    ByteBuffer buf = BufferUtils.createByteBuffer(500000);
    BufferUtils.destroyDirectBuffer(buf);
    
    FloatBuffer buf2 = BufferUtils.createFloatBuffer(500000);
    BufferUtils.destroyDirectBuffer(buf2);
}
 
Example 5
Source File: BufferObject.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void deleteNativeBuffers() {
    super.deleteNativeBuffers();
    if (previousData != null) {
        BufferUtils.destroyDirectBuffer(previousData);
        previousData = null;
    }
}
 
Example 6
Source File: Image.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
protected void deleteNativeBuffers() {
    for (ByteBuffer buf : data) {
        BufferUtils.destroyDirectBuffer(buf);
    }
}
 
Example 7
Source File: Uniform.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void deleteNativeBuffers() {
    if (value instanceof Buffer) {
        BufferUtils.destroyDirectBuffer((Buffer)value);
        value = null; // ????
    }
}
 
Example 8
Source File: VertexBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void deleteNativeBuffers() {
    if (data != null) {
        BufferUtils.destroyDirectBuffer(data);
    }
}
 
Example 9
Source File: Image.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void deleteNativeBuffers() {
    for (ByteBuffer buf : data) {
        BufferUtils.destroyDirectBuffer(buf);
    }
}
 
Example 10
Source File: AudioBuffer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void deleteNativeBuffers() {
    if (audioData != null) {
        BufferUtils.destroyDirectBuffer(audioData);
    }
}