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


Java MemoryUtil.memAllocInt方法代码示例

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


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

示例1: 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

示例2: bufferData

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
@Override
public void bufferData(int buffer, Format format, int[] 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");

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

示例3: 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

示例4: intBuffer

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public static IntBuffer intBuffer(int[] data) {
    IntBuffer buffer = MemoryUtil.memAllocInt(data.length);
    buffer.put(data); buffer.flip();
    return buffer;
}
 
开发者ID:mcmacker4,项目名称:OpenVoxel,代码行数:6,代码来源:BufferUtils.java

示例5: 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

示例6: Mesh

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public Mesh(float[] positions, float[] colours, int[] indices) {
    FloatBuffer posBuffer = null;
    FloatBuffer colourBuffer = 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);

        // Colour VBO
        colourVboId = glGenBuffers();
        colourBuffer = MemoryUtil.memAllocFloat(colours.length);
        colourBuffer.put(colours).flip();
        glBindBuffer(GL_ARRAY_BUFFER, colourVboId);
        glBufferData(GL_ARRAY_BUFFER, colourBuffer, GL_STATIC_DRAW);
        glVertexAttribPointer(1, 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 (colourBuffer != null) {
            MemoryUtil.memFree(colourBuffer);
        }
        if (indicesBuffer != null) {
            MemoryUtil.memFree(indicesBuffer);
        }
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:48,代码来源:Mesh.java

示例7: Mesh

import org.lwjgl.system.MemoryUtil; //导入方法依赖的package包/类
public Mesh(float[] positions, float[] textCoords, int[] indices, Texture texture) {
    FloatBuffer posBuffer = null;
    FloatBuffer textCoordsBuffer = null;
    IntBuffer indicesBuffer = null;
    try {
        this.texture = texture;
        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);

        // 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 (indicesBuffer != null) {
            MemoryUtil.memFree(indicesBuffer);
        }
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:53,代码来源:Mesh.java

示例8: 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


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