Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adjusted matrix setup

  • Loading branch information...
commit 3072712ed8e4914e1922efd59caae14f276c2a70 1 parent 7ffda27
@alihelmy authored
View
26 LessonFive/com/onehandstand/lwjgltutorial/lessonfive/Main.java
@@ -9,11 +9,9 @@
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
-import static org.lwjgl.opengl.GL11.GL_MODELVIEW;
import static org.lwjgl.opengl.GL11.GL_NICEST;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_PERSPECTIVE_CORRECTION_HINT;
-import static org.lwjgl.opengl.GL11.GL_PROJECTION;
import static org.lwjgl.opengl.GL11.GL_SMOOTH;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.glBlendFunc;
@@ -26,12 +24,14 @@
import static org.lwjgl.opengl.GL11.glMatrixMode;
import static org.lwjgl.opengl.GL11.glShadeModel;
import static org.lwjgl.opengl.GL11.glViewport;
+import static org.lwjgl.util.glu.GLU.gluLookAt;
+import static org.lwjgl.util.glu.GLU.gluPerspective;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
-import org.lwjgl.util.glu.GLU;
+import org.lwjgl.opengl.GL11;
public class Main {
@@ -113,22 +113,24 @@ private void initOpenGL() {
int width=displayMode.getWidth();
int height=displayMode.getHeight();
glViewport(0, 0, width, height);
- // setup the camera params
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- GLU.gluLookAt(0f, 2f, 0f, 0f, 0f, -4f, 0f, 1f, 0f);
- GLU.gluPerspective(45.0f, (float)width/(float)height, 0.1f, 10f);
- // setup the model (drawing) params
- glMatrixMode(GL_MODELVIEW);
+
+ // setup the world & camera params [model & view matrices]
+ glMatrixMode(GL11.GL_MODELVIEW_MATRIX);
glLoadIdentity();
glShadeModel(GL_SMOOTH);
- glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // white
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // white
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
+ GL11.glDepthFunc(GL11.GL_LESS);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- // enable blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ gluLookAt(0f, 2f, 0f, 0f, 0f, -4f, 0f, 1f, 0f);
+
+ // setup the lens params [projection matrix]
+ glMatrixMode(GL11.GL_PROJECTION_MATRIX);
+ glLoadIdentity();
+ gluPerspective(45.0f, (float)width/(float)height, 0.1f, 10f);
}
public static void main(String[] args) {
View
2  LessonFive/shaders/screen.vert
@@ -30,7 +30,7 @@ void main(void) {
mat4x4 rotationMatrix=mat4x4(1.0);
rotationMatrix=heading*pitch*roll;
- gl_Position=gl_ModelViewProjectionMatrix*positionMatrix*rotationMatrix*vec4(coords,1.0);
+ gl_Position=gl_ModelViewProjectionMatrix*vec4(coords,1.0);
fragmentColor=color;
}
Please sign in to comment.
Something went wrong with that request. Please try again.