本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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();
}
示例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);
}
示例10: cleanup
import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public void cleanup() {
alDeleteBuffers(this.bufferId);
if (pcm != null) {
MemoryUtil.memFree(pcm);
}
}
示例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);
}
}
}
示例12: nFree
import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void nFree(Array<?> view) {
MemoryUtil.memFree(view.<ByteBuffer>data());
}
示例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);
}
}
}
示例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);
}
}
}
示例15: free
import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public void free()
{
MemoryUtil.memFree(nativeBuffer);
}