Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

finally got triangle to draw by reordering drawing call

  • Loading branch information...
commit 738e45cb2e3fcda423c5d36f1e89e3804efd936f 1 parent 9540b93
@alihelmy authored
View
17 LessonTwo/com/onehandstand/lwjgltutorial/lessontwo/ShaderTriangle.java
@@ -19,11 +19,10 @@
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT;
import static org.lwjgl.opengl.GL11.GL_VERTEX_ARRAY;
import static org.lwjgl.opengl.GL11.glDisableClientState;
-import static org.lwjgl.opengl.GL11.glDrawElements;
import static org.lwjgl.opengl.GL11.glEnableClientState;
import static org.lwjgl.opengl.GL11.glLoadIdentity;
import static org.lwjgl.opengl.GL11.glVertexPointer;
-
+import static org.lwjgl.opengl.GL12.glDrawRangeElements;
import java.nio.ByteBuffer;
public class ShaderTriangle {
@@ -115,19 +114,15 @@ public void draw() {
glUseProgramObjectARB(0);
}
- protected void drawVertices() {
- //drawing code through buffers
+ protected void drawVertices() { //drawing code through buffers
+ //bind vertex array
glEnableClientState(GL_VERTEX_ARRAY);
-
- //bind the buffers
glBindBufferARB(GL_ARRAY_BUFFER_ARB, this.vboVertexAttributes);
- glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this.vboVertexIndices);
-
- //get vertex position data
- glVertexPointer(this.numAxisPerVertex, GL_FLOAT, this.vboVertexAttributesSize, 0);
+ glVertexPointer(this.numAxisPerVertex, GL_FLOAT, 0, 0);
//draw the vertices using the indices
- glDrawElements(GL_TRIANGLES, this.numVertices, GL_UNSIGNED_INT, 0);
+ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, this.vboVertexIndices);
+ glDrawRangeElements(GL_TRIANGLES, 0, this.numVertices-1, this.numVertices, GL_UNSIGNED_INT, 0);
//unbind the buffers
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
Please sign in to comment.
Something went wrong with that request. Please try again.