Ok so for now i'll use vbo's only ok so i have the following: But i still can't see my triangle
package Kudze.Amandas.Game;
import Kudze.Engine.Core.Engine;
import Kudze.Engine.Core.Game;
import Kudze.Engine.Math.Vector2;
import Kudze.Engine.Math.Vector3;
import Kudze.Engine.Render.OpenGL.Objects3D.Mesh;
import Kudze.Engine.Render.OpenGL.Objects3D.Vertex;
public class SandBox implements Game {
public static Engine engine;
@Override
public void create(Engine engine) {
SandBox.engine = engine;
}
private Mesh mesh;
@Override
public void start() {
Vertex[] vertices = { new Vertex(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 0)),
new Vertex(new Vector3(0, 0.5f, 0), new Vector2(0, 0)),
new Vertex(new Vector3(0.5f, -0.5f, 0), new Vector2(0, 0))};
int[] indices = {0, 1, 2};
mesh = new Mesh(vertices, indices);
}
@Override
public void update(double deltaTime) {
}
@Override
public void draw() { //It clears screen and displays in other class no worries here
mesh.draw();
}
@Override
public void dispose() {
mesh.dispose();
}
}
package Kudze.Engine.Render.OpenGL.Objects3D;
import Kudze.Engine.Math.Vector2;
import Kudze.Engine.Math.Vector3;
public class Vertex {
public static final int SIZE = 5;
private Vector3 VertexPosition;
private Vector2 TexturePosition;
public Vertex(Vector3 VertexPosition, Vector2 TexturePosition) {
this.VertexPosition = VertexPosition;
this.TexturePosition = TexturePosition;
}
public void setVertexPosition(Vector3 Position) {
VertexPosition = Position;
}
public void setTexturePosition(Vector2 Position) {
TexturePosition = Position;
}
public Vector3 getVertexPosition() { return VertexPosition; }
public Vector2 getTexturePosition() { return TexturePosition; }
}
package Kudze.Engine.Render.OpenGL.Objects3D;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import Kudze.Engine.Render.OpenGL.Util.DataUtil;
public class Mesh {
private int vbo; //Vertices buffer
private int fbo; //Faces buffer
private int size;
public Mesh(Vertex[] vertex, int[] faces) {
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, DataUtil.createFlippedBuffer(vertex), GL_STATIC_DRAW);
fbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, fbo);
glBufferData(GL_ARRAY_BUFFER, DataUtil.createFlippedBuffer(faces), GL_STATIC_DRAW);
size = faces.length;
}
public void draw() {
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE * 4, 0);
glVertexAttribPointer(1, 3, GL_FLOAT, false, Vertex.SIZE * 4, 12);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fbo);
glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
public void dispose() {
glDeleteBuffers(vbo);
glDeleteBuffers(fbo);
}
}