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


Java MemoryUtil.memFree方法代码示例

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


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

示例1: delete

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
 * Deletes this instanced mesh and deletes the vertex array object and the
    * vertex buffer object.
 */
@Override
public void delete() {
	super.delete();
	
	if (this.instancedDataBuffer != null) {
		MemoryUtil.memFree(this.instancedDataBuffer);
		this.instancedDataBuffer = null;
	}
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:14,代码来源:InstancedMesh.java

示例2: cleanup

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public void cleanup() {
    nvgDelete(vg);
    if (posx != null) {
        MemoryUtil.memFree(posx);
    }
    if (posy != null) {
        MemoryUtil.memFree(posy);
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:10,代码来源:Hud.java

示例3: cleanUp

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
@Override
public void cleanUp() {
    super.cleanUp();
    if (this.instanceDataBuffer != null) {
        MemoryUtil.memFree(this.instanceDataBuffer);
        this.instanceDataBuffer = null;
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:9,代码来源:InstancedMesh.java

示例4: setSize

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
 * Set the size of the buffer
 * @param newCapacity The new capacity
 */
public void setSize(int newCapacity) {
	if (data == null) {
		data = MemoryUtil.memAlloc(newCapacity);
	} else {
		ByteBuffer newData = MemoryUtil.memRealloc(data, newCapacity);
		if (data != null && MemoryUtil.memAddress(newData) != MemoryUtil.memAddress(data)) {
			MemoryUtil.memFree(data);
			data = newData;
		}
	}
	if (capacity > newCapacity)
		bufferSize = 0;
	capacity = newCapacity;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:19,代码来源:GraphicsBuffer.java

示例5: delete

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
 * Delete this buffer
 * @return <code>false</code>
 */
@Override
public boolean delete() {
	if (id != 0)
		GL15.glDeleteBuffers(id);
	if (data != null)
		MemoryUtil.memFree(data);
	return false;
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:13,代码来源:GraphicsBuffer.java

示例6: Mesh

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public Mesh(float[] positions, int[] indices) {
    FloatBuffer posBuffer = null;
    IntBuffer indicesBuffer = null;
    try {
        vertexCount = indices.length;

        vaoId = glGenVertexArrays();
        glBindVertexArray(vaoId);

        // Position VBO
        posVboId = glGenBuffers();
        posBuffer = MemoryUtil.memAllocFloat(positions.length);
        posBuffer.put(positions).flip();
        glBindBuffer(GL_ARRAY_BUFFER, posVboId);
        glBufferData(GL_ARRAY_BUFFER, posBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);

        // Index VBO
        idxVboId = glGenBuffers();
        indicesBuffer = MemoryUtil.memAllocInt(indices.length);
        indicesBuffer.put(indices).flip();
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idxVboId);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_STATIC_DRAW);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindVertexArray(0);
    } finally {
        if (posBuffer != null) {
            MemoryUtil.memFree(posBuffer);
        }
        if (indicesBuffer != null) {
            MemoryUtil.memFree(indicesBuffer);
        }
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:36,代码来源:Mesh.java

示例7: bufferData

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
@Override
public void bufferData(int buffer, Format format, byte[] data, int freq) {
	if(!isBuffer(buffer))
		throw new ALError("alBufferData", "Argument passed as buffer is not a buffer");
	if(data == null || data.length == 0)
		throw new ALError("alBufferData", "Data cannot be null or empty");

       ByteBuffer sbuff = MemoryUtil.memAlloc(data.length);
       sbuff.put(data);
       alBufferData(buffer, format.e, sbuff, freq);
       MemoryUtil.memFree(sbuff);
}
 
开发者ID:melchor629,项目名称:Java-GLEngine,代码行数:13,代码来源:LWJGLAudio.java

示例8: dispose

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
 * Dispose renderer and clean up its used data.
 */
public void dispose() {
    MemoryUtil.memFree(vertices);

    if (vao != null) {
        vao.delete();
    }
    vbo.delete();
    program.delete();

    font.dispose();
    debugFont.dispose();
}
 
开发者ID:SilverTiger,项目名称:lwjgl3-tutorial,代码行数:16,代码来源:Renderer.java

示例9: frame

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public static void frame(Context ctx) {
    if (!ctx.firstFrameSeen) {
        /* Do not count the first frame end, since we have no idea when the frame actually started. */
        ctx.firstFrameSeen = true;
        return;
    }
    ctx.frame++;
    if ((ctx.frameEndTime - lastSent) / 1E6 < sendIntervalMs) {
        return;
    }
    lastSent = ctx.frameEndTime;
    ByteBuffer buf = MemoryUtil.memAlloc(1024).order(ByteOrder.BIG_ENDIAN);
    long addr = MemoryUtil.memAddress0(buf);
    float frameTimeCpu = (float) (ctx.frameEndTime - ctx.frameStartTime) / 1E6f;
    float drawCallTimeGpu = ctx.drawCallTimeMs;
    buf.putInt(ctx.counter);
    buf.putInt(ctx.frame);
    buf.putFloat(frameTimeCpu);
    buf.putFloat(drawCallTimeGpu);
    buf.putInt(ctx.glCallCount);
    buf.putInt(ctx.verticesCount);
    long boMemory = 0L;
    for (BufferObject bo : ctx.bufferObjects.values()) {
        boMemory += bo.size;
    }
    buf.putDouble(boMemory / 1024);
    long toMemory = 0L;
    for (TextureObject to : ctx.textureObjects.values()) {
        if (to.layers != null) {
            for (TextureLayer layer : to.layers) {
                if (layer.levels != null) {
                    for (TextureLevel level : layer.levels) {
                        toMemory += level.size;
                    }
                }
            }
        }
    }
    buf.putDouble(toMemory / 1024L);

    /* Write code section timings */
    buf.putShort((short) ctx.codeSectionTimes.size());
    for (TimedCodeSection section : ctx.codeSectionTimes) {
        String name = section.name;
        byte[] nameBytes = name.getBytes();
        buf.putShort((short) nameBytes.length);
        for (int i = 0; i < nameBytes.length; i++) {
            buf.put(nameBytes[i]);
        }
        float totalTime = 0.0f; // <- ms
        for (TimingQuery q : section.queries) {
            totalTime += (q.time1 - q.time0) / 1E6f;
        }
        buf.putFloat(totalTime);
    }

    synchronized (ProfilingConnection.connections) {
        for (ProfilingConnection c : ProfilingConnection.connections) {
            c.send(addr, buf.position());
        }
    }

    MemoryUtil.memFree(buf);
}
 
开发者ID:LWJGLX,项目名称:debug,代码行数:65,代码来源:Profiling.java

示例10: cleanup

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public void cleanup() {
    alDeleteBuffers(this.bufferId);
    if (pcm != null) {
        MemoryUtil.memFree(pcm);
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:7,代码来源:SoundBuffer.java

示例11: ModelMesh

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public ModelMesh(float[] positions, float[] textCoords, float[] normals, int[] indices) {
  FloatBuffer posBuffer = null;
  FloatBuffer textCoordsBuffer = null;
  FloatBuffer vecNormalsBuffer = null;
  IntBuffer indicesBuffer = null;
  try {
    colour = DEFAULT_COLOUR;
    vertexCount = indices.length;
    vboIdList = new ArrayList<>();

    vaoId = glGenVertexArrays();
    glBindVertexArray(vaoId);

    // Position VBO
    int vboId = glGenBuffers();
    vboIdList.add(vboId);
    posBuffer = MemoryUtil.memAllocFloat(positions.length);
    posBuffer.put(positions).flip();
    glBindBuffer(GL_ARRAY_BUFFER, vboId);
    glBufferData(GL_ARRAY_BUFFER, posBuffer, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);

    // Texture coordinates VBO
    vboId = glGenBuffers();
    vboIdList.add(vboId);
    textCoordsBuffer = MemoryUtil.memAllocFloat(textCoords.length);
    textCoordsBuffer.put(textCoords).flip();
    glBindBuffer(GL_ARRAY_BUFFER, vboId);
    glBufferData(GL_ARRAY_BUFFER, textCoordsBuffer, GL_STATIC_DRAW);
    glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);

    // Vertex normals VBO
    vboId = glGenBuffers();
    vboIdList.add(vboId);
    vecNormalsBuffer = MemoryUtil.memAllocFloat(normals.length);
    vecNormalsBuffer.put(normals).flip();
    glBindBuffer(GL_ARRAY_BUFFER, vboId);
    glBufferData(GL_ARRAY_BUFFER, vecNormalsBuffer, GL_STATIC_DRAW);
    glVertexAttribPointer(2, 3, GL_FLOAT, false, 0, 0);

    // Index VBO
    vboId = glGenBuffers();
    vboIdList.add(vboId);
    indicesBuffer = MemoryUtil.memAllocInt(indices.length);
    indicesBuffer.put(indices).flip();
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
  } finally {
    if (posBuffer != null) {
      MemoryUtil.memFree(posBuffer);
    }
    if (textCoordsBuffer != null) {
      MemoryUtil.memFree(textCoordsBuffer);
    }
    if (vecNormalsBuffer != null) {
      MemoryUtil.memFree(vecNormalsBuffer);
    }
    if (indicesBuffer != null) {
      MemoryUtil.memFree(indicesBuffer);
    }
  }
}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:66,代码来源:ModelMesh.java

示例12: nFree

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void nFree(Array<?> view) {
    MemoryUtil.memFree(view.<ByteBuffer>data());
}
 
开发者ID:Wolftein,项目名称:Quark-Engine,代码行数:8,代码来源:DesktopArrayFactory.java

示例13: Mesh

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public Mesh(float[] positions, float[] textCoords, float[] normals, int[] indices) {
    FloatBuffer posBuffer = null;
    FloatBuffer textCoordsBuffer = null;
    FloatBuffer vecNormalsBuffer = null;
    IntBuffer indicesBuffer = null;
    try {
        vertexCount = indices.length;
        vboIdList = new ArrayList();

        vaoId = glGenVertexArrays();
        glBindVertexArray(vaoId);

        // Position VBO
        int vboId = glGenBuffers();
        vboIdList.add(vboId);
        posBuffer = MemoryUtil.memAllocFloat(positions.length);
        posBuffer.put(positions).flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboId);
        glBufferData(GL_ARRAY_BUFFER, posBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);

        // Texture coordinates VBO
        vboId = glGenBuffers();
        vboIdList.add(vboId);
        textCoordsBuffer = MemoryUtil.memAllocFloat(textCoords.length);
        textCoordsBuffer.put(textCoords).flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboId);
        glBufferData(GL_ARRAY_BUFFER, textCoordsBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);

        // Vertex normals VBO
        vboId = glGenBuffers();
        vboIdList.add(vboId);
        vecNormalsBuffer = MemoryUtil.memAllocFloat(normals.length);
        vecNormalsBuffer.put(normals).flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboId);
        glBufferData(GL_ARRAY_BUFFER, vecNormalsBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(2, 3, GL_FLOAT, false, 0, 0);

        // Index VBO
        vboId = glGenBuffers();
        vboIdList.add(vboId);
        indicesBuffer = MemoryUtil.memAllocInt(indices.length);
        indicesBuffer.put(indices).flip();
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_STATIC_DRAW);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindVertexArray(0);
    } finally {
        if (posBuffer != null) {
            MemoryUtil.memFree(posBuffer);
        }
        if (textCoordsBuffer != null) {
            MemoryUtil.memFree(textCoordsBuffer);
        }
        if (vecNormalsBuffer != null) {
            MemoryUtil.memFree(vecNormalsBuffer);
        }
        if (indicesBuffer != null) {
            MemoryUtil.memFree(indicesBuffer);
        }
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:65,代码来源:Mesh.java

示例14: Mesh

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public Mesh(float[] positions, float[] textCoords, float[] normals, int[] indices) {
    FloatBuffer posBuffer = null;
    FloatBuffer textCoordsBuffer = null;
    FloatBuffer vecNormalsBuffer = null;
    IntBuffer indicesBuffer = null;
    try {
        colour = DEFAULT_COLOUR;
        vertexCount = indices.length;
        vboIdList = new ArrayList();

        vaoId = glGenVertexArrays();
        glBindVertexArray(vaoId);

        // Position VBO
        int vboId = glGenBuffers();
        vboIdList.add(vboId);
        posBuffer = MemoryUtil.memAllocFloat(positions.length);
        posBuffer.put(positions).flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboId);
        glBufferData(GL_ARRAY_BUFFER, posBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);

        // Texture coordinates VBO
        vboId = glGenBuffers();
        vboIdList.add(vboId);
        textCoordsBuffer = MemoryUtil.memAllocFloat(textCoords.length);
        textCoordsBuffer.put(textCoords).flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboId);
        glBufferData(GL_ARRAY_BUFFER, textCoordsBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);

        // Vertex normals VBO
        vboId = glGenBuffers();
        vboIdList.add(vboId);
        vecNormalsBuffer = MemoryUtil.memAllocFloat(normals.length);
        vecNormalsBuffer.put(normals).flip();
        glBindBuffer(GL_ARRAY_BUFFER, vboId);
        glBufferData(GL_ARRAY_BUFFER, vecNormalsBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(2, 3, GL_FLOAT, false, 0, 0);

        // Index VBO
        vboId = glGenBuffers();
        vboIdList.add(vboId);
        indicesBuffer = MemoryUtil.memAllocInt(indices.length);
        indicesBuffer.put(indices).flip();
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_STATIC_DRAW);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindVertexArray(0);
    } finally {
        if (posBuffer != null) {
            MemoryUtil.memFree(posBuffer);
        }
        if (textCoordsBuffer != null) {
            MemoryUtil.memFree(textCoordsBuffer);
        }
        if (vecNormalsBuffer != null) {
            MemoryUtil.memFree(vecNormalsBuffer);
        }
        if (indicesBuffer != null) {
            MemoryUtil.memFree(indicesBuffer);
        }
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:66,代码来源:Mesh.java

示例15: free

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public void free()
{
    MemoryUtil.memFree(nativeBuffer);
}
 
开发者ID:sriharshachilakapati,项目名称:SilenceEngine,代码行数:5,代码来源:LwjglDirectBuffer.java


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