List of usage examples for org.lwjgl.opengl GL15 glBufferData
public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") double[] data, @NativeType("GLenum") int usage)
From source file:ru.axialshift.vram.gl.VertexVBO.java
License:Apache License
@Override protected void upload_gl() { //Allocation/*from w w w. j a v a 2 s . c o m*/ glpointer = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, glpointer); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, (FloatBuffer) tovram, GL15.GL_STATIC_DRAW); //Mapping int stride = 4 * (MeshData.VERTICES_STRIDE + MeshData.UVS_STRIDE + MeshData.NORMALS_STRIDE + MeshData.TANGENTS_STRIDE + MeshData.BITANGENTS_STRIDE); int offset = 0; //Vertices int bytesPerVertex = MeshData.VERTICES_STRIDE * 4; GL20.glVertexAttribPointer(id_pos, MeshData.VERTICES_STRIDE, GL11.GL_FLOAT, false, stride, offset); //UVs int bytesPerUVs = MeshData.UVS_STRIDE * 4; offset += bytesPerVertex; GL20.glVertexAttribPointer(id_uvs, MeshData.UVS_STRIDE, GL11.GL_FLOAT, false, stride, offset); //Normals int bytesPerNormals = MeshData.NORMALS_STRIDE * 4; offset += bytesPerUVs; GL20.glVertexAttribPointer(id_nor, MeshData.NORMALS_STRIDE, GL11.GL_FLOAT, false, stride, offset); //Tangents int bytesPerTangents = MeshData.TANGENTS_STRIDE * 4; offset += bytesPerNormals; GL20.glVertexAttribPointer(id_tan, MeshData.TANGENTS_STRIDE, GL11.GL_FLOAT, false, stride, offset); //BiTangents //int bytesPerBiTangents = MeshData.BITANGENTS_STRIDE*4; offset += bytesPerTangents; GL20.glVertexAttribPointer(id_btan, MeshData.BITANGENTS_STRIDE, GL11.GL_FLOAT, false, stride, offset); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:se.angergard.engine.graphics.Mesh.java
License:Apache License
public Mesh(long vertexBufferSize, long indicesBufferSize, int usage) { if (aMeshCreated) { new Exception("You can't create multiple meshes as of right now. This is due to a bug") .printStackTrace();/*from ww w . ja v a 2 s . co m*/ } vbo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBufferSize, usage); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); ibo = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferSize, usage); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); this.VERTEX_BUFFER_SIZE = vertexBufferSize; this.INDICES_BUFFER_SIZE = indicesBufferSize; this.INDICES_LENGTH = (int) indicesBufferSize / 4; // removes bytes aMeshCreated = true; }
From source file:thebounzer.org.lwgldemo.Chapter5.java
License:Open Source License
private void createAndBindVertexObject(float[] data) throws IOException { FloatBuffer fBuffer = BufferUtils.createFloatBuffer(data.length); fBuffer.put(data);/*w w w.j av a 2 s .c om*/ fBuffer.flip(); int vboId = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, fBuffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glBufferData(int a, DoubleBuffer b, int c) { GL15.glBufferData(a, b, c); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glBufferData(int a, FloatBuffer b, int c) { GL15.glBufferData(a, b, c); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glBufferData(int a, long b, int c) { GL15.glBufferData(a, b, c); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glBufferData(int a, ByteBuffer b, int c) { GL15.glBufferData(a, b, c); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glBufferData(int a, IntBuffer b, int c) { GL15.glBufferData(a, b, c); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glBufferData(int a, ShortBuffer b, int c) { GL15.glBufferData(a, b, c); }
From source file:uk.co.ifs_studios.engine.geometry.BasicDrawElement.java
License:Open Source License
/** * Set verticies to DrawElement.// w w w . j ava2s.co m * * @param verticies * - Verticies. */ public void setVerticies(Vertex[] verticies) { float[] vertexValues = new float[verticies.length * 4]; int vertexIndex = 0; for (int i = 0; i < vertexValues.length; i += 4) { vertexValues[i + 0] = verticies[vertexIndex].getX(); vertexValues[i + 1] = verticies[vertexIndex].getY(); vertexValues[i + 2] = verticies[vertexIndex].getZ(); vertexValues[i + 3] = verticies[vertexIndex].getW(); vertexIndex++; } FloatBuffer verticiesBuffer = BufferUtils.createFloatBuffer(vertexValues.length); verticiesBuffer.put(vertexValues); verticiesBuffer.flip(); GL30.glBindVertexArray(this.vao); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticiesBuffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 4, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); }