# alihelmy/lwjglTutorial

code for first exercise, drawing a square

• Loading branch information...
1 parent f06f628 commit 4e246a3de63eecb1e26fac20612393e72ab7fe21 committed Sep 24, 2011
21 LessonOne/com/onehandstand/lwjgltutorial/lessonone/Ex1ShaderSquare.java
 @@ -0,0 +1,21 @@ +package com.onehandstand.lwjgltutorial.lessonone; + +import static org.lwjgl.opengl.GL11.*; + +public class Ex1ShaderSquare extends ShaderTriangle { + + public Ex1ShaderSquare() { + super(); + } + + @Override + protected void drawVertices() { + glBegin(GL_QUADS); + glVertex2f(-0.8f, 0.8f); + glVertex2f(-0.8f, -0.8f); + glVertex2f(0.8f, -0.8f); + glVertex2f(0.8f, 0.8f); + glEnd(); + } + +}
11 LessonOne/com/onehandstand/lwjgltutorial/lessonone/ShaderTriangle.java
 @@ -52,20 +52,23 @@ public void draw() { glUseProgramObjectARB(this.shader); } - // normal rendering code glLoadIdentity(); //red, which will show if our fragment shader doesn't work glColor3f(1.0f, 0.0f, 0.0f); + drawVertices(); + + //free up use of shader program + glUseProgramObjectARB(0); + } + + protected void drawVertices() { //drawn at 0.0 in z axis, so wont show if vertex shader doesn't work glBegin(GL_TRIANGLES); glVertex2f(0.0f, 0.8f); glVertex2f(-0.8f, -0.8f); glVertex2f(0.8f, -0.8f); glEnd(); - - //free up use of shader program - glUseProgramObjectARB(0); } private int createFragmentShader(String pathToShaderFile) {

#### 0 comments on commit `4e246a3`

Please sign in to comment.