/*
* Copyright 2013 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.terasology.rendering;
import org.lwjgl.opengl.GL15;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
/**
* Provides support for buffering Vertex Buffer Objects.
*
*/
public final class VertexBufferObjectUtil {
private VertexBufferObjectUtil() {
}
public static void bufferVboData(int id, FloatBuffer buffer, int drawMode) {
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, id);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, drawMode);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public static void bufferVboData(int id, IntBuffer buffer, int drawMode) {
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, id);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, drawMode);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public static void bufferVboElementData(int id, IntBuffer buffer, int drawMode) {
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, id);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, drawMode);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
public static void bufferVboData(int id, ByteBuffer buffer, int drawMode) {
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, id);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, drawMode);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public static void bufferVboData(int id, ShortBuffer buffer, int drawMode) {
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, id);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, drawMode);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public static void bufferVboElementData(int id, ByteBuffer buffer, int drawMode) {
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, id);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, drawMode);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}
}