ObjectGl, ObjectGlColor, ObjectGlTex added
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package engine.graphics;
|
||||
|
||||
import engine.utils.BufferUtils;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
@ -12,46 +11,6 @@ public class VertexArray {
|
||||
private int VAO ,VBO, EBO, CBO, TBO;
|
||||
private int count;
|
||||
|
||||
public VertexArray(float[] vertices, byte[] indices){
|
||||
count = indices.length;
|
||||
// VERTEX ARRAY OBJECT
|
||||
VAO = glGenVertexArrays();
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
// VERTEX BUFFER OBJECT
|
||||
createVertexBufferObject(vertices);
|
||||
|
||||
EBO = glGenBuffers();
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
GL15.glBufferData(GL_ELEMENT_ARRAY_BUFFER, BufferUtils.createByteBuffer(indices), GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
}
|
||||
|
||||
public VertexArray(float[] vertices, byte[] indices, float[] color) {
|
||||
count = indices.length;
|
||||
// VERTEX ARRAY OBJECT
|
||||
VAO = glGenVertexArrays();
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
// VERTEX BUFFER OBJECT
|
||||
createVertexBufferObject(vertices);
|
||||
// COLOR BUFFER OBJECT
|
||||
createColorBufferObject(color);
|
||||
|
||||
EBO = glGenBuffers();
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, BufferUtils.createByteBuffer(indices), GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
}
|
||||
|
||||
public VertexArray(float[] vertices, byte[] indices, float[] color, float[] texture) {
|
||||
count = indices.length;
|
||||
// VERTEX ARRAY OBJECT
|
||||
@ -63,9 +22,9 @@ public class VertexArray {
|
||||
// VERTEX BUFFER OBJECT
|
||||
createVertexBufferObject(vertices);
|
||||
// COLOR BUFFER OBJECT
|
||||
createColorBufferObject(color);
|
||||
if (color != null) createColorBufferObject(color);
|
||||
// TEXTURE BUFFER OBJECT
|
||||
createTextureBufferObject(texture);
|
||||
if (texture != null) createTextureBufferObject(texture);
|
||||
|
||||
EBO = glGenBuffers();
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
|
Reference in New Issue
Block a user