List of usage examples for org.lwjgl.opengl GL20 glEnableVertexAttribArray
public static void glEnableVertexAttribArray(@NativeType("GLuint") int index)
From source file:opengl.test.object.cube.wall.java
@Override public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); this.VertexAttribPointer(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, 6, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:opengl.test.object.endgame.endgame.java
/** * Method nay duoc tach rieng ra tu initVertex * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer *///from w w w . j a va 2s . c o m @Override protected void VertexAttribPointer() { if (this.vbo == 0) throw new RuntimeException("Chua khoi tao VBO"); int positionID = GL20.glGetAttribLocation(programID, "position"); GL20.glEnableVertexAttribArray(positionID); GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 8 * 4, 0);// float size = 4 byte --> next is 3*4 byte // size = 3 --> position = x,y,z vec3 int colorID = GL20.glGetAttribLocation(programID, "color"); GL20.glEnableVertexAttribArray(colorID); GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 8 * 4, 3 * 4); // size = 3 --> vec3 int texcoordID = GL20.glGetAttribLocation(programID, "texcoord"); GL20.glEnableVertexAttribArray(texcoordID); GL20.glVertexAttribPointer(texcoordID, 2, GL11.GL_FLOAT, false, 8 * 4, 6 * 4); // size = 2 --> vec2 }
From source file:opengl.test.object.endgame.endgame.java
public void render(int status) { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); this.VertexAttribPointer(); GL20.glEnableVertexAttribArray(0);// set index ve 0 if (status == endgame.win) GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDWIN); else if (status == endgame.lose) GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDLOSE); else//from w w w .j a v a 2 s .c o m GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDDRAW); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.size); //GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max //GL11. GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:opengl.test.object.image.java
@Override public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo); this.VertexAttribPointer(); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:opengl.test.object.lineCube.java
@Override protected void VertexAttribPointer() { if (this.vbo == 0) throw new RuntimeException("Chua khoi tao VBO"); int positionID = GL20.glGetAttribLocation(programID, "position"); GL20.glEnableVertexAttribArray(positionID); GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 6 * 4, 0);// float size = 4 byte --> next is 3*4 byte int colorID = GL20.glGetAttribLocation(programID, "color"); GL20.glEnableVertexAttribArray(colorID); GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 6 * 4, 3 * 4); }
From source file:opengl.test.object.lineCube.java
@Override public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); this.VertexAttribPointer(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glDrawElements(GL11.GL_LINE_STRIP, 16, GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:opengl.test.object.table.table.java
@Override public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); this.VertexAttribPointer(); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.size); //GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max //GL11.// w w w.j av a2s . c om GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:opengl.test.object.tivi.tivi.java
@Override public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); this.VertexAttribPointer(); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.size); //GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max //GL11.// www .j a v a2s .c o m GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }
From source file:opengl.test.object.tree.testobject.leaf.java
/** * Method nay duoc tach rieng ra tu initVertex * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer *//*w w w. j a v a 2s.co m*/ private void VertexAttribPointer() { if (this.vbo == 0) throw new RuntimeException("Chua khoi tao VBO"); int positionID = GL20.glGetAttribLocation(programID, "position"); GL20.glEnableVertexAttribArray(positionID); GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 6 * 4, 0);// float size = 4 byte --> next is 3*4 byte // size = 3 --> position = x,y,z vec3 int colorID = GL20.glGetAttribLocation(programID, "color"); GL20.glEnableVertexAttribArray(colorID); GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 6 * 4, 3 * 4); // size = 3 --> vec3 }
From source file:opengl.test.object.tree.testobject.leaf.java
public void render() { this.bind();// use porgrma --> ket thuc disable program GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo); this.VertexAttribPointer(); GL20.glEnableVertexAttribArray(0);// set index ve 0 GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max //GL11./* w w w. j a v a 2 s .co m*/ GL20.glDisableVertexAttribArray(0);// disable GL30.glBindVertexArray(0);// unbind vao this.unbind();// dsiable program }