List of usage examples for org.lwjgl.opengl GL11 glLoadIdentity
public static native void glLoadIdentity();
From source file:org.meanworks.engine.camera.Camera.java
License:Open Source License
/** * Setup the camera to look at something * //w w w . j a v a2s . c o m * @param eye * @param target * @return */ public Matrix4f lookAt(Vector3f eye, Vector3f target) { Matrix4f persp = new Matrix4f(); GL11.glMatrixMode(GL11.GL_MODELVIEW); { GL11.glPushMatrix(); { GL11.glLoadIdentity(); GLU.gluLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, upVector.x, upVector.y, upVector.z); MatrixHelper.getMatrix(GL11.GL_MODELVIEW_MATRIX, persp); } GL11.glPopMatrix(); } GL11.glMatrixMode(GL11.GL_MODELVIEW); return persp; }
From source file:org.meanworks.engine.camera.Camera.java
License:Open Source License
/** * Temporary function for setting up the projection matrix *///from w ww . j a v a2s . c o m private Matrix4f perspective(float fovY, float aspect, float nearPlane, float farPlane, Matrix4f storeIn) { GL11.glMatrixMode(GL11.GL_PROJECTION); { GL11.glPushMatrix(); { GL11.glLoadIdentity(); GLU.gluPerspective(fovY, aspect, nearPlane, farPlane); MatrixHelper.getMatrix(GL11.GL_PROJECTION_MATRIX, storeIn); } GL11.glPopMatrix(); } GL11.glMatrixMode(GL11.GL_MODELVIEW); return storeIn; }
From source file:org.meanworks.engine.camera.Camera.java
License:Open Source License
/** * /*from www. j a v a 2 s.c o m*/ */ public void immediateCameraSetup() { // Setup camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glRotatef(rotation.x, 1.0f, 0.0f, 0.0f); GL11.glRotatef(rotation.y, 0.0f, 1.0f, 0.0f); GL11.glTranslatef(-cameraPosition.x, -cameraPosition.y, -cameraPosition.z); }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private boolean initGL() { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(FOV, ((float) targetWidth) / ((float) targetHeight), 0.1f, 100.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity();/* w ww. java 2 s.co m*/ GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_FASTEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); setupLights(); setupFog(Settings.FOG_DENSITY, Settings.FOG_START, Settings.FOG_END); GL11.glEnable(GL11.GL_TEXTURE_2D); return true; }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void run() { while (isRunning) { update();/*from w w w . j a v a 2s . c o m*/ render(); Display.update(); Display.sync(Settings.FPS); processKeyboard(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(FOV, ((float) targetWidth) / ((float) targetHeight), 0.1f, 100.0f); GL11.glMatrixMode(GL11.GL_MATRIX_MODE); if (Display.isCloseRequested()) { isRunning = false; Display.destroy(); System.exit(0); } if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { System.exit(0); } } }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void render() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); drawBackground();/* ww w . java 2 s .com*/ GL11.glPushMatrix(); Camera.applyRotation(); drawWireframeCube(); GL11.glTranslatef(-1.5f, -1.5f, -1.5f); drawSceneCubes(); GL11.glPopMatrix(); dt = getDeltaTime(); }
From source file:org.mkdev.ai.langton3d.core.App.java
License:GNU General Public License
private void drawBackground() { GL11.glDisable(GL11.GL_DEPTH_TEST);/* w w w . ja va2 s . c o m*/ GL11.glDisable(GL11.GL_LIGHTING); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glClearColor(Settings.BKG_COLOR_RED, Settings.BKG_COLOR_GREEN, Settings.BKG_COLOR_BLUE, Settings.BKG_COLOR_ALPHA); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glDisable(GL_LIGHTING); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(Settings.BKG_COLOR_RED, Settings.BKG_COLOR_GREEN, Settings.BKG_COLOR_BLUE, Settings.BKG_COLOR_ALPHA); GL11.glVertex2f(-1.0f, -1.0f); GL11.glVertex2f(1.0f, -1.0f); GL11.glColor4f(Settings.BKG_COLOR_RED / 2, Settings.BKG_COLOR_GREEN / 2, Settings.BKG_COLOR_BLUE / 2, Settings.BKG_COLOR_ALPHA); GL11.glVertex2f(1.0f, 1.0f); GL11.glVertex2f(-1.0f, 1.0f); GL11.glEnd(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
private void setCamera(float x, float y, float z, float rx, float ry, float rz) { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); // GL11.glRotatef (90, 0,0,1); // GL11.glRotatef (90, 0,1,0); GL11.glRotatef(rx, 1, 0, 0);/*from w w w .j a v a2 s . c o m*/ GL11.glRotatef(ry, 0, 1, 0); GL11.glRotatef(rz, 0, 0, 1); GL11.glTranslatef(-x, -y, -z); }
From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java
License:Open Source License
@Override // void dsDrawFrame (int width, int height, dsFunctions *fn, int pause) void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) { if (current_state < 1) dsDebug("internal error"); current_state = 2;/*ww w.j ava2 s .c om*/ // setup stuff GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_GEN_S); GL11.glDisable(GL11.GL_TEXTURE_GEN_T); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glCullFace(GL11.GL_BACK); GL11.glFrontFace(GL11.GL_CCW); // setup viewport GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); final float vnear = 0.1f; final float vfar = 100.0f; final float k = 0.8f; // view scale, 1 = +/- 45 degrees if (width >= height) { float k2 = (float) height / (float) width; GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar); } else { float k2 = (float) width / (float) height; GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar); } // setup lights. it makes a difference whether this is done in the // GL_PROJECTION matrix mode (lights are scene relative) or the // GL_MODELVIEW matrix mode (lights are camera relative, bad!). // static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; // static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; // static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular); GL11.glColor3f(1.0f, 1.0f, 1.0f); // clear the window GL11.glClearColor(0.5f, 0.5f, 0.5f, 0); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // snapshot camera position (in MS Windows it is changed by the GUI thread) float[] view2_xyz = view_xyz.clone(); float[] view2_rxyz = view_rxyz.clone(); // memcpy (view2_xyz,view_xyz);//,sizeof(float)*3); // memcpy (view2_hpr,view_hpr);//,sizeof(float)*3); // go to GL_MODELVIEW matrix mode and set the camera GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]); // set the light position (for some reason we have to do this in model view. // static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 }; GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position); // draw the background (ground, sky etc) drawSky(view2_xyz); drawGround(); // draw the little markers on the ground drawPyramidGrid(); // leave openGL in a known state - flat shaded white, no textures GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LESS); GL11.glColor3f(1, 1, 1); setColor(1, 1, 1, 1); // draw the rest of the objects. set drawing state first. color[0] = 1; color[1] = 1; color[2] = 1; color[3] = 1; tnum = DS_TEXTURE_NUMBER.DS_NONE; //if (fn.step) fn.step(pause); }
From source file:org.spout.engine.renderer.shader.BasicShader.java
License:Open Source License
public void assign(boolean compatabilityMode) { if (!variables.containsKey("Projection")) { throw new IllegalStateException("Basic Shader must have a projection matrix assigned"); }/*from w w w . j a v a2 s. c o m*/ if (!variables.containsKey("View")) { throw new IllegalStateException("Basic Shader must have a view matrix assigned"); } if (compatabilityMode) { GL11.glMatrixMode(GL11.GL_PROJECTION); matrixBuffer.clear(); matrixBuffer.put(getProjectionMatrix().toArray()); matrixBuffer.flip(); GL11.glLoadMatrix(matrixBuffer); GL11.glMatrixMode(GL11.GL_MODELVIEW); /*matrixBuffer.clear(); matrixBuffer.put(getViewMatrix().toArray()); matrixBuffer.flip(); GL11.glLoadMatrix(matrixBuffer);*/ SpoutClient client = ((SpoutClient) Spout.getEngine()); Quaternion r = client.getActivePlayer().getTransform().getRotation(); Point p = client.getActivePlayer().getTransform().getPosition(); GL11.glLoadIdentity(); GL11.glRotatef(r.getPitch(), 1, 0, 0); GL11.glRotatef(r.getYaw(), 0, 1, 0); GL11.glRotatef(r.getRoll(), 0, 0, 1); GL11.glTranslatef(-p.getX(), -p.getY(), -p.getZ()); } else { super.assign(); } }