Created
December 27, 2014 11:52
-
-
Save theresajayne/039bc1fce287a9bba682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.theresajayne.thepeople.game; | |
import com.github.theresajayne.thepeople.utilities.Util; | |
import static org.lwjgl.opengl.GL11.*; | |
import static org.lwjgl.opengl.GL15.*; | |
import static org.lwjgl.opengl.GL20.*; | |
/** | |
* Created by Theresa on 27/12/2014. | |
*/ | |
public class Mesh | |
{ | |
private int vbo; | |
private int size; | |
public Mesh() | |
{ | |
vbo = glGenBuffers(); | |
size = 0; | |
} | |
public void addVertices(Vertex[] vertices) | |
{ | |
size = vertices.length; | |
glBindBuffer(GL_ARRAY_BUFFER, vbo); | |
glBufferData(GL_ARRAY_BUFFER, Util.createFlippedBuffer(vertices),GL_STATIC_DRAW); | |
} | |
public void draw() | |
{ | |
glEnableVertexAttribArray(0); | |
glBindBuffer(GL_ARRAY_BUFFER,vbo); | |
glVertexAttribPointer(0,3,GL_FLOAT,false,Vertex.SIZE * Float.SIZE,0 ); | |
glDrawArrays(GL_TRIANGLES,0,size); | |
glDisableVertexAttribArray(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment