本文整理汇总了Java中org.lwjgl.opengl.GL15.glGenBuffers方法的典型用法代码示例。如果您正苦于以下问题:Java GL15.glGenBuffers方法的具体用法?Java GL15.glGenBuffers怎么用?Java GL15.glGenBuffers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.opengl.GL15
的用法示例。
在下文中一共展示了GL15.glGenBuffers方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: store
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
/**
* Store the specified indices into an ElementBufferObject
* @param indices
*/
private void store(int[] indices) {
bind();
// Create an id for the ElementBufferObject
int eboid = GL15.glGenBuffers();
// Bind the EBO
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, eboid);
// Store the data in the EBO
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, Util.toBuffer(indices), GL15.GL_STATIC_DRAW);
// Add this to the buffer objects for memory management and rendering
addBufferObject(eboid);
unbind();
}
示例2: bindIndicesBuffer
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
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);
}
示例3: store
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
/**
* 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();
}
示例4: storeDataInAttributeList
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
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);
}
示例5: VertexArrayObject
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
/**
* 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);
}
示例6: VBO
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public VBO(int target)
{
this.target = target;
this.handle = GL15.glGenBuffers();
this.normalized = false;
this.length = 0;
VBOS.add(this);
}
示例7: createShaderProgram
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
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);
}
示例8: glGenBuffers
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public static int glGenBuffers()
{
return arbVbo ? ARBVertexBufferObject.glGenBuffersARB() : GL15.glGenBuffers();
}
示例9: createShaderProgram
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public void createShaderProgram() {
shaderProgram = GL20.glCreateProgram();
vShader = createShader(vertexShader, GL20.GL_VERTEX_SHADER);
fShader = createShader(fragmentShader, 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);
GL20.glDetachShader(shaderProgram, vShader);
GL20.glDetachShader(shaderProgram, fShader);
GL20.glDeleteShader(vShader);
vShader = 0;
GL20.glDeleteShader(fShader);
fShader = 0;
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);
worldChunkSsbo = GL15.glGenBuffers();
chunkSsbo = GL15.glGenBuffers();
worldMetadataSsbo = GL15.glGenBuffers();
metadataSsbo = GL15.glGenBuffers();
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, worldChunkSsbo);
GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 2, worldChunkSsbo);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, chunkSsbo);
GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 3, chunkSsbo);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, worldMetadataSsbo);
GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 4, worldMetadataSsbo);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, metadataSsbo);
GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, 0, GL15.GL_DYNAMIC_DRAW);
GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, 5, metadataSsbo);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
}
示例10: create
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public static Vbo create(int type){
int id = GL15.glGenBuffers();
return new Vbo(id, type);
}
示例11: create
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public static Vbo create(int type, int usage){
int id = GL15.glGenBuffers();
return new Vbo(id, type, usage);
}
示例12: create
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public static Vbo create(int type, int usage) {
int id = GL15.glGenBuffers();
return new Vbo(id, type, usage);
}
示例13: Mesh
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public Mesh() {
vao = GL30.glGenVertexArrays();
vbo = GL15.glGenBuffers();
vboTexture = GL15.glGenBuffers();
vboi = GL15.glGenBuffers();
}
示例14: FrameBufferObject
import org.lwjgl.opengl.GL15; //导入方法依赖的package包/类
public FrameBufferObject(){
int width = Main.WIDTH;
int height = Main.HEIGHT;
this.fbo = glGenFramebuffers();
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
//Creation de la texture qui va contenir la sortie RGB du shader
int renderedTexture = glGenTextures();
glBindTexture(GL_TEXTURE_2D, renderedTexture);
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, width, height, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//Creation du tampon de profondeur
int depthrenderbuffer = glGenRenderbuffers();
glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthrenderbuffer);
//Definir le render Texture
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, renderedTexture, 0);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
throw new IllegalStateException("FBO not loaded !");
fboTexID = renderedTexture;
renderID = depthrenderbuffer;
this.vbo = GL15.glGenBuffers();
float[] a = new float[]{
0,0, 0.0f,0.0f,
1,0, 1.0f,0.0f,
1,1, 1.0f,1.0f,
0,1, 0.0f,1.0f
};
FloatBuffer buffer = BufferUtils.createFloatBuffer(a.length);
buffer.put(a).flip();
size = a.length/(2+2);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL20.glEnableVertexAttribArray(Shaders.MAIN_SHADERS.getAttribLocation("vert"));
GL20.glVertexAttribPointer(Shaders.MAIN_SHADERS.getAttribLocation("vert"), 2, GL11.GL_FLOAT, false, (2+2)*4, 0);
GL20.glEnableVertexAttribArray(Shaders.MAIN_SHADERS.getAttribLocation("vertTexCoord"));
GL20.glVertexAttribPointer(Shaders.MAIN_SHADERS.getAttribLocation("vertTexCoord"), 2, GL11.GL_FLOAT, true, (2+2)*4, 2*4);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}