Java 类org.lwjgl.opengl.GL15 实例源码

项目:candlelight    文件:MeshBuilder2D.java   
public Mesh createQuad()
{
    Mesh mesh = new Mesh();
    mesh.bind();
    {
        VBO vbo = new VBO();
        vbo.bind();
        {
            final float[] verts = {-0.5F, 0.5F, -0.5F, -0.5F, 0.5F, -0.5F, 05.F, 05.F};
            vbo.putData(FloatBuffer.wrap(verts), false, GL15.GL_STATIC_DRAW);
        }
        vbo.unbind();
        mesh.setVertexArrayBuffer(0, 2, 0, vbo);
    }
    mesh.unbind();
    return mesh;
}
项目:candlelight    文件:MeshBuilder2D.java   
public Mesh createCircle(int segments)
{
    Mesh mesh = new Mesh();
    mesh.bind();
    {
        VBO vbo = new VBO();
        vbo.bind();
        {
            final float[] verts = new float[segments * 2];
            for (int i = 0; i < segments; ++i)
            {
                verts[i * 2] = (float) Math.cos(i * Transform.PI2 / segments);
                verts[i * 2 + 1] = (float) Math.sin(i * Transform.PI2 / segments);
            }
            vbo.putData(FloatBuffer.wrap(verts), false, GL15.GL_STATIC_DRAW);
        }
        vbo.unbind();
        mesh.setVertexArrayBuffer(0, 2, 0, vbo);
    }
    mesh.unbind();
    return mesh;
}
项目:candlelight    文件:VBO.java   
public VBO updateData(IntBuffer buffer, long offset)
{
    if (this.type != GL11.GL_UNSIGNED_INT)
    {
        throw new IllegalArgumentException("Cannot store mismatching type in buffer!");
    }

    if (offset + buffer.limit() > this.length)
    {
        int usage = GL15.glGetBufferParameteri(this.target, GL15.GL_BUFFER_USAGE);
        this.putData(buffer, this.normalized, usage);
    }

    GL15.glBindBuffer(this.target, this.handle);
    GL15.glBufferSubData(this.target, offset, buffer);

    return this;
}
项目:candlelight    文件:VBO.java   
public VBO updateData(FloatBuffer buffer, long offset)
{
    if (this.type != GL11.GL_FLOAT)
    {
        throw new IllegalArgumentException("Cannot store mismatching type in buffer!");
    }

    if (offset + buffer.limit() > this.length)
    {
        int usage = GL15.glGetBufferParameteri(this.target, GL15.GL_BUFFER_USAGE);
        this.putData(buffer, this.normalized, usage);
    }

    GL15.glBindBuffer(this.target, this.handle);
    GL15.glBufferSubData(this.target, offset, buffer);

    return this;
}
项目:CommunityEngine-Java    文件:Mesh.java   
public void add(float[] vertices, float[] texCoords, int[] indices) {
    indicesSize = indices.length;

    GL30.glBindVertexArray(vao);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, Util.flip(vertices), GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboTexture);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, Util.flip(texCoords), GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL30.glBindVertexArray(0);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboi);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Util.flip(indices), GL15.GL_STATIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
项目:MRCEngine    文件:Loader.java   
public void cleanUp() {
    for(int vao : vaos) {
        GL30.glDeleteVertexArrays(vao);
    }

    for(int vbo : vbos) {
        GL15.glDeleteBuffers(vbo);
    }

    for(int texture : textures) {
        GL11.glDeleteTextures(texture);
    }
}
项目:MRCEngine    文件:Loader.java   
private void bindIndicesBuffer(int[] indices) {
    int vboID = GL15.glGenBuffers();
    vbos.add(vboID);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboID);
    IntBuffer buffer = storeDataInIntBuffer(indices);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
}
项目:MRCEngine    文件:Loader.java   
private void storeDataInAttributeList(int attributeNumber, int coordinateSize, float[] data) {
    int vboID = GL15.glGenBuffers();
    vbos.add(vboID);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    FloatBuffer buffer = storeDataInFloatBuffer(data);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
项目:ClientAPI    文件:VBO.java   
/**
 * Compiles a FloatBuffer and binds it to OpenGL for rendering.
 *
 * @param buffer a FloatBuffer populated with VBO vertices
 * @return The original VBO
 */
public VBO compile(FloatBuffer buffer) {
    this.size = buffer.capacity();
    FEATHER.bindBuffer(this.id);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
    FEATHER.bindBuffer(0);
    return this;
}
项目:MC-Ray-Tracer    文件:WorldLoader.java   
private void initializeWorld(int renderDistance, int centerX, int centerY, int centerZ, Shader shader) {

    playerChunkX = centerX;
    playerChunkZ = centerZ;

    //initialize the world
    worldChunks = new int[(renderDistance*2-1)*16*(renderDistance*2-1)];
    worldMetadata = new int[(renderDistance*2-1)*16*(renderDistance*2-1)];
    chunkIdList = new ArrayDeque<Integer>();
    metadataIdList = new ArrayDeque<Integer>();
    for (int i = worldChunks.length; i > 0; i--) {
        chunkIdList.push(i);
    }
    for (int i = worldMetadata.length; i > 0; i--) {
        metadataIdList.push(i);
    }

    //update the buffer size
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getChunkSsbo());
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, chunkSize*worldChunks.length*2*4, GL15.GL_DYNAMIC_DRAW);

    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getMetadataSsbo());
    GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, chunkSize*worldMetadata.length*4, GL15.GL_DYNAMIC_DRAW);
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);

    //inform the shader of the new render distance
    int renderDistanceUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "renderDistance");
    GL20.glUniform1i(renderDistanceUniform, renderDistance-1);
}
项目:MC-Ray-Tracer    文件:WorldLoader.java   
private void loadChunk(int id, Shader shader, ExtendedBlockStorage storage) {
    ObjectIntIdentityMap<IBlockState> map = GameData.getBlockStateIDMap();
    int[] data = new int[chunkSize*2];
    for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
            for (int x = 0; x < 16; x++) {
                IBlockState state = storage.get(x, y, z);
                boolean fullBlock = state.isFullBlock();
                boolean cube = state.isFullCube();
                if (fullBlock != cube) {
                    Log.info(state.getBlock().getUnlocalizedName() + ": " + fullBlock);
                }
                if (fullBlock) {
                    stateSet.add(state);
                }
                int stateId = map.get(state); //TODO
                data[(y<<9) + (z<<5) + (x<<1)] = Block.getIdFromBlock(storage.get(x, y, z).getBlock());
            }
        }
    }

    for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
            for (int x = 0; x < 16; x++) {
                data[(y<<9) + (z<<5) + (x<<1) + 1] = storage.getBlocklightArray().get(x, y, z);
            }
        }
    }

    IntBuffer buffer = BufferUtils.createIntBuffer(chunkSize*2);
    buffer.put(data);
    buffer.flip();
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getChunkSsbo());
    GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, (id-1)*chunkSize*2*4, buffer);
    GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
}
项目:MC-Ray-Tracer    文件:WorldLoader.java   
/**
 * 
 * @param id
 * @param shader
 * @param storage
 * @return true if the id was used, false if there was nothing to upload
 */
private boolean loadMetadata(int id, Shader shader, ExtendedBlockStorage storage) {
    int[] data = new int[chunkSize];
    boolean containsValues = false;
    for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
            for (int x = 0; x < 16; x++) {
                int metadata = storage.get(x, y, z).getBlock().getMetaFromState(storage.get(x, y, z));
                data[(y<<8) + (z<<4) + x] = metadata;
                if (metadata != 0) {
                    containsValues = true;
                }
            }
        }
    }

    if (containsValues) {
        IntBuffer buffer = BufferUtils.createIntBuffer(chunkSize);
        buffer.put(data);
        buffer.flip();
        GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getMetadataSsbo());
        GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, (id-1)*chunkSize*4, buffer);
        GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
    }

    return containsValues;
}
项目:MC-Ray-Tracer    文件:Shader.java   
public void deleteShaderProgram() {
    GL15.glDeleteBuffers(vbo);
    vbo = 0;
    GL15.glDeleteBuffers(worldChunkSsbo);
    worldChunkSsbo = 0;
    GL15.glDeleteBuffers(chunkSsbo);
    chunkSsbo = 0;
    GL20.glDeleteProgram(shaderProgram);
    shaderProgram = 0;
}
项目:CustomWorldGen    文件:OpenGlHelper.java   
public static void glDeleteBuffers(int buffer)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glDeleteBuffersARB(buffer);
    }
    else
    {
        GL15.glDeleteBuffers(buffer);
    }
}
项目:open-world    文件:VAO.java   
/**
    * Stores the specified data into the VAO with a VBO
    * @param data
    * @param dimensions
    */
   private void store(FloatBuffer data, int[] dimensions) {
bind();

// Generate a VBO to hold the data
int vboid = GL15.glGenBuffers();
// Bind the VBO
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboid);
// Store the data in the VBO
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);

// Get the stride of the data in bytes
int stride = 0;
if(dimensions.length > 1)
    for(int i = 0; i < dimensions.length; i++) {
    stride += dimensions[i] * 4;
    }

// Determine the number of vertices assuming attribute 0 is position
vertexCount = data.capacity() / dimensions[0];

// Setup data in VBO
int offset = 0;
for(int i = 0; i < dimensions.length; i++) {
    GL20.glVertexAttribPointer(i, dimensions[i], GL11.GL_FLOAT, false, stride, offset);
    offset += dimensions[i] * 4;
}

// Add the vbo to the list of buffer objects for memory management
addBufferObject(vboid);

unbind();
   }
项目:open-world    文件:VAO.java   
/**
    * Cleans up the VRAM of this VAO
    */
   @Override
   public void finalize() {
GL30.glDeleteVertexArrays(vaoid);
for(int vbo : bufferObjects)
    GL15.glDeleteBuffers(vbo);
   }
项目:bia-engine    文件:Loader.java   
private void storeDataInAttributeList(final int attributeNumber, final int coordinateSize, final float[] data) {
    int vboId = GL15.glGenBuffers();
    vbos.add(vboId);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, storeDataInFloatBuffer(data), GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
项目:OpenGL-Animation    文件:Vao.java   
public void createAttribute(int attribute, float[] data, int attrSize){
    Vbo dataVbo = Vbo.create(GL15.GL_ARRAY_BUFFER);
    dataVbo.bind();
    dataVbo.storeData(data);
    GL20.glVertexAttribPointer(attribute, attrSize, GL11.GL_FLOAT, false, attrSize * BYTES_PER_FLOAT, 0);
    dataVbo.unbind();
    dataVbos.add(dataVbo);
}
项目:EcoSystem-Official    文件:VaoLoader.java   
/**
 * Creates the VAO for the water mesh and stores the vertex data in it. The
 * VAO has two attributes, one is for the positions and is comprised of two
 * floats (x and z position) and the other attribute is 4 bytes (the
 * indicators).
 *
 * @param meshData - All the vertex data for the water mesh.
 * @return The VAO containing the water mesh data.
 */
public static Vao createWaterVao(byte[] meshData) {
    Vao vao = Vao.create();
    vao.bind();
    ByteBuffer buffer = storeMeshDataInBuffer(meshData);
    vao.initDataFeed(buffer, GL15.GL_STATIC_DRAW, new Attribute(0, GL11.GL_FLOAT, 2),
            new Attribute(1, GL11.GL_BYTE, 4));
    vao.unbind();
    return vao;
}
项目:OpenGL-Animation    文件:Vao.java   
public void createIntAttribute(int attribute, int[] data, int attrSize){
    Vbo dataVbo = Vbo.create(GL15.GL_ARRAY_BUFFER);
    dataVbo.bind();
    dataVbo.storeData(data);
    GL30.glVertexAttribIPointer(attribute, attrSize, GL11.GL_INT, attrSize * BYTES_PER_INT, 0);
    dataVbo.unbind();
    dataVbos.add(dataVbo);
}
项目:LowPolyWater    文件:Vao.java   
public Vbo initDataFeed(FloatBuffer data, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(data.limit() * DataUtils.BYTES_IN_FLOAT);
    vbo.storeData(0, data);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:LowPolyWater    文件:Vao.java   
public Vbo initDataFeed(ByteBuffer data, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(data.limit());
    vbo.storeData(0, data);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:CustomWorldGen    文件:OpenGlHelper.java   
public static void glBufferData(int target, ByteBuffer data, int usage)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glBufferDataARB(target, data, usage);
    }
    else
    {
        GL15.glBufferData(target, data, usage);
    }
}
项目:EcoSystem-Official    文件:Vao.java   
public Vbo createDataFeed(int maxVertexCount, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(bytesPerVertex * maxVertexCount);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:lambda    文件:VertexArrayObject.java   
/**
 * Builds renderable geometry from a list of vertices and indices.
 * Each triplet of indices references three distinct vertices to form a triangle.
 * 
 * @param vertices ordered list of vertices
 * @param indices ordered list of indices references vertices used for determining render order
 */
public VertexArrayObject(Vertex[] vertices, byte[] indices){
    indicesCount = indices.length;

    // Create a new Vertex Array Object in memory and select it (bind)
    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);

    // Create a new Vertex Buffer Object in memory and select it (bind)
    vboId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bufferFromVertices(vertices), GL15.GL_STREAM_DRAW);

    // Put the position coordinates in attribute list 0
    GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, 
            false, Vertex.stride, Vertex.positionByteOffset);
    // Put the color components in attribute list 1
    GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, 
            false, Vertex.stride, Vertex.colorByteOffset);
    // Put the texture coordinates in attribute list 2
    GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, 
            false, Vertex.stride, Vertex.textureByteOffset);

    // Deselect
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL30.glBindVertexArray(0);

    // Create a new VBO for the indices and select it (bind) - INDICES
    indicesId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesId);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Buffers.createByteBuffer(indices), GL15.GL_STATIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
项目:BaseClient    文件:OpenGlHelper.java   
public static void glBindBuffer(int target, int buffer)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glBindBufferARB(target, buffer);
    }
    else
    {
        GL15.glBindBuffer(target, buffer);
    }
}
项目:BaseClient    文件:OpenGlHelper.java   
public static void glBufferData(int target, ByteBuffer data, int usage)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glBufferDataARB(target, data, usage);
    }
    else
    {
        GL15.glBufferData(target, data, usage);
    }
}
项目:BaseClient    文件:OpenGlHelper.java   
public static void glBindBuffer(int target, int buffer)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glBindBufferARB(target, buffer);
    }
    else
    {
        GL15.glBindBuffer(target, buffer);
    }
}
项目:BaseClient    文件:OpenGlHelper.java   
public static void glBufferData(int target, ByteBuffer data, int usage)
{
    if (arbVbo)
    {
        ARBVertexBufferObject.glBufferDataARB(target, data, usage);
    }
    else
    {
        GL15.glBufferData(target, data, usage);
    }
}
项目:EcoSystem-Official    文件:Vao.java   
public Vbo initDataFeed(FloatBuffer data, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(data.limit() * DataUtils.BYTES_IN_FLOAT);
    vbo.storeData(0, data);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:candlelight    文件:ModelUtil.java   
public static Mesh createDynamicMesh(MeshData data)
{
    Mesh mesh = new Mesh();
    ModelUtil.putVertexBuffer(mesh, data.getPositions(), GL15.GL_DYNAMIC_DRAW, 0, data.getPositionVertexSize(), 0);
    ModelUtil.putVertexBuffer(mesh, data.getTexcoords(), GL15.GL_DYNAMIC_DRAW, 1, data.getTexcoordVertexSize(), 0);
    ModelUtil.putVertexBuffer(mesh, data.getNormals(), GL15.GL_DYNAMIC_DRAW, 2, data.getNormalVertexSize(), 0);
    ModelUtil.putIndexBuffer(mesh, data.getIndices(), GL15.GL_DYNAMIC_DRAW);
    return mesh;
}
项目:candlelight    文件:VBO.java   
public VBO(int target)
{
    this.target = target;

    this.handle = GL15.glGenBuffers();
    this.normalized = false;
    this.length = 0;

    VBOS.add(this);
}
项目:candlelight    文件:VBO.java   
public VBO putData(IntBuffer buffer, boolean normalized, int usage)
{
    GL15.glBindBuffer(this.target, this.handle);
    GL15.glBufferData(this.target, buffer, usage);
    this.type = GL11.GL_UNSIGNED_INT;
    this.normalized = normalized;
    this.length = buffer.limit();

    return this;
}
项目:candlelight    文件:VBO.java   
public VBO putData(FloatBuffer buffer, boolean normalized, int usage)
{
    GL15.glBindBuffer(this.target, this.handle);
    GL15.glBufferData(this.target, buffer, usage);
    this.type = GL11.GL_FLOAT;
    this.normalized = normalized;
    this.length = buffer.limit();

    return this;
}
项目:candlelight    文件:Mesh.java   
public Mesh setElementArrayBuffer(VBO buffer)
{
    Poma.ASSERT(buffer.getTarget() == GL15.GL_ELEMENT_ARRAY_BUFFER);

    GL30.glBindVertexArray(this.handle);
    buffer.bind();

    if (this.indexBuffer != null)
    {
        try
        {
            this.indexBuffer.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    this.indexBuffer = buffer;
    this.vertexCount = this.indexBuffer.getLength();

    //This is to alter the render state!
    //DO NOT buffer.unbind();
    GL30.glBindVertexArray(0);

    return this;
}
项目:LowPolyTerrain    文件:Vao.java   
public Vbo createDataFeed(int maxVertexCount, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(bytesPerVertex * maxVertexCount);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:LowPolyTerrain    文件:Vao.java   
public Vbo initDataFeed(FloatBuffer data, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(data.limit() * DataUtils.BYTES_IN_FLOAT);
    vbo.storeData(0, data);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:LowPolyTerrain    文件:Vao.java   
public Vbo initDataFeed(ByteBuffer data, int usage, Attribute... newAttributes) {
    int bytesPerVertex = getVertexDataTotalBytes(newAttributes);
    Vbo vbo = Vbo.create(GL15.GL_ARRAY_BUFFER, usage);
    relatedVbos.add(vbo);
    vbo.allocateData(data.limit());
    vbo.storeData(0, data);
    linkAttributes(bytesPerVertex, newAttributes);
    vbo.unbind();
    return vbo;
}
项目:flex-fov    文件:Shader.java   
public void createShaderProgram(RenderMethod renderMethod) {
    shaderProgram = GL20.glCreateProgram();
    vshader = createShader(vertexShader, GL20.GL_VERTEX_SHADER);
    fshader = createShader(renderMethod.getFragmentShader(), GL20.GL_FRAGMENT_SHADER);
    GL20.glAttachShader(shaderProgram, vshader);
    GL20.glAttachShader(shaderProgram, fshader);
    GL20.glBindAttribLocation(shaderProgram, 0, "vertex");
    GL30.glBindFragDataLocation(shaderProgram, 0, "color");
    GL20.glLinkProgram(shaderProgram);
    int linked = GL20.glGetProgrami(shaderProgram, GL20.GL_LINK_STATUS);
    String programLog = GL20.glGetProgramInfoLog(shaderProgram, GL20.glGetProgrami(shaderProgram, GL20.GL_INFO_LOG_LENGTH));
    if (programLog.trim().length() > 0) {
        System.err.println(programLog);
    }
    if (linked == 0) {
        throw new AssertionError("Could not link program");
    }

    //init vbo
    vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    ByteBuffer bb = BufferUtils.createByteBuffer(2 * 6);
    bb.put((byte) -1).put((byte) -1);
    bb.put((byte) 1).put((byte) -1);
    bb.put((byte) 1).put((byte) 1);
    bb.put((byte) 1).put((byte) 1);
    bb.put((byte) -1).put((byte) 1);
    bb.put((byte) -1).put((byte) -1);
    bb.flip();
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, bb, GL15.GL_STATIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
项目:flex-fov    文件:Shader.java   
public void deleteShaderProgram() {
    GL15.glDeleteBuffers(vbo);
    GL20.glDetachShader(shaderProgram, vshader);
    GL20.glDetachShader(shaderProgram, fshader);
    GL20.glDeleteShader(vshader);
    vshader = 0;
    GL20.glDeleteShader(fshader);
    fshader = 0;
    GL20.glDeleteProgram(shaderProgram);
    shaderProgram = 0;
}