List of usage examples for com.badlogic.gdx.graphics GL10 glLoadIdentity
public void glLoadIdentity();
From source file:com.badlogic.gdx.tests.lw.WaterRipplesLW.java
License:Apache License
@Override public void render() { GL10 gl = Gdx.graphics.getGL10(); gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update();/* ww w . ja va 2s. com*/ gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(camera.combined.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); accum += Gdx.graphics.getDeltaTime(); while (accum > TICK) { // for (int i = 0; i < 5; i++) { // if (Gdx.input.isTouched(i)) { // Ray ray = camera.getPickRay(Gdx.input.getX(i), Gdx.input.getY(i)); // Intersector.intersectRayPlane(ray, plane, point); // touchWater(point); // } // } updateWater(); float[][] tmp = curr; curr = last; last = tmp; accum -= TICK; } float alpha = accum / TICK; interpolateWater(alpha); updateVertices(intp); gl.glEnable(GL10.GL_TEXTURE_2D); texture.bind(); mesh.render(GL10.GL_TRIANGLES); batch.begin(); // batch.drawText(font, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20, Color.WHITE); batch.end(); }
From source file:com.badlogic.gdx.tests.WaterRipples.java
License:Apache License
@Override public void render() { GL10 gl = Gdx.graphics.getGL10(); gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update();/* w ww .java 2 s. co m*/ gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(camera.combined.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); accum += Gdx.graphics.getDeltaTime(); while (accum > TICK) { for (int i = 0; i < 5; i++) { if (Gdx.input.isTouched(i)) { Ray ray = camera.getPickRay(Gdx.input.getX(i), Gdx.input.getY(i)); Intersector.intersectRayPlane(ray, plane, point); touchWater(point); } } updateWater(); float[][] tmp = curr; curr = last; last = tmp; accum -= TICK; } float alpha = accum / TICK; interpolateWater(alpha); updateVertices(intp); gl.glEnable(GL10.GL_TEXTURE_2D); texture.bind(); mesh.render(GL10.GL_TRIANGLES); batch.begin(); // batch.drawText(font, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20, Color.WHITE); batch.end(); }
From source file:com.digitale.mygdxgame.Renderer.java
License:Open Source License
private void setProjectionAndCamera(Graphics graphics, Ship ship, Application app, GL10 gl) { gl.glMatrixMode(GL10.GL_MODELVIEW);/* w w w. j a v a2s . c om*/ gl.glLoadIdentity(); // x=left-right, y=up-down, z=back-forward camera.far = 1000000; // camera.near=0.01f; Vector3 heading = new Vector3(0, 0, -1); Ship.shipRot.transform(heading); camera.direction.set(heading.x, heading.y, heading.z); camera.fieldOfView = 67; camera.position.set(Ship.position.x, 20f + Ship.position.y, 20f + Ship.position.z); float orbitRadius = 30f; camera.rotate(GameLoop.cameraHorizAngle, 0, 1, 0); Vector3 orbitReturnVector = new Vector3(0, 0, 0); orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius)); camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z); camera.position.set(Ship.position); orbitReturnVector = new Vector3(0, 0, 0); orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius)); camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z); if (Ship.pitchAngle > 90 && Ship.pitchAngle < 270) { camera.up.set(0, -1, 0); } else { camera.up.set(0, 1, 0); } camera.up.nor(); camera.translate(0, GameLoop.cameraVertAngle, 0); camera.lookAt(Ship.position.x, Ship.position.y, Ship.position.z); camera.update(); camera.apply(gl); Simulation.camera = camera.position; }
From source file:com.digitale.mygdxgame.Renderer.java
License:Open Source License
private void setStaticProjectionAndCamera(Graphics graphics, Application app, GL10 gl) { gl.glMatrixMode(GL10.GL_MODELVIEW);/* w w w . j ava 2s .com*/ gl.glLoadIdentity(); // x=left-right, y=up-down, z=back-forward camera.far = 1000; // camera.near=0.01f; Vector3 heading = new Vector3(0, 0, -1); camera.direction.set(heading.x, heading.y, heading.z); camera.fieldOfView = 67; camera.position.set(0, 4f + 0, 9f + 0); float orbitRadius = 18f; camera.rotate(GameLoop.cameraHorizAngle, 0, 1, 0); Vector3 orbitReturnVector = new Vector3(0, 0, 0); orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius)); camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z); camera.position.set(new Vector3(0, 0, 0)); orbitReturnVector = new Vector3(0, 0, 0); orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius)); camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z); camera.up.set(0, 1, 0); camera.up.nor(); camera.translate(0, ((float) (GameLoop.cameraVertAngle)) / 10, 0); camera.lookAt(0, 0, 0); camera.update(); camera.apply(gl); }
From source file:com.digitale.mygdxgame.SplashRenderer.java
License:Open Source License
private void setStaticProjectionAndCamera(Graphics graphics, Application app, GL10 gl) { gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); //x=left-right, y=up-down, z=back-forward camera.far = 1000000;/*from w w w . j av a2 s . c om*/ camera.position.set(0, 7f + 0, 9f + 0); //camera.direction.set(0, 0, -4f).sub(camera.position).nor(); camera.fieldOfView = 67; float orbitRadius = (new Vector3(0, 0, 0).dst(camera.position)); camera.position.set(new Vector3(0, 0, 0)); camera.rotate(Splash.cameraHorizAngle, 0, 1, 0); Vector3 orbitReturnVector = new Vector3(0, 0, 0); orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius)); camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z); camera.update(); camera.apply(gl); orbitRadius = (new Vector3(0, 0, 0)).dst(camera.position); camera.position.set(new Vector3(0, 0, 0)); camera.rotate(Splash.cameraVertAngle, 1, 0, 0); orbitReturnVector = new Vector3(0, 0, 0); orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius)); camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z); camera.update(); camera.apply(gl); gl.glMatrixMode(GL10.GL_MODELVIEW); Splash.cameraHorizAngle = 0; Splash.cameraVertAngle = 0; }
From source file:com.eightbitmage.lwtemplate.WaterRipplesLW.java
License:Apache License
@Override public void render() { GL10 gl = Gdx.graphics.getGL10(); gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update();/*from w ww.ja v a 2s . c om*/ gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(camera.combined.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); accum += Gdx.graphics.getDeltaTime(); while (accum > TICK) { updateWater(); float[][] tmp = curr; curr = last; last = tmp; accum -= TICK; } float alpha = accum / TICK; interpolateWater(alpha); updateVertices(intp); gl.glEnable(GL10.GL_TEXTURE_2D); texture.bind(); mesh.render(GL10.GL_TRIANGLES); batch.begin(); // batch.drawText(font, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, // 20, Color.WHITE); batch.end(); }
From source file:org.interreg.docexplore.reader.book.ParchmentEngine.java
License:Open Source License
public void render() { if (book == null || !active) return;/*from w w w . j av a2 s. c o m*/ GL10 gl = Gdx.gl10; cnt += .01; globalFrame.attract(camera, .075f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); camera.apply(gl); Gdx.gl10.glEnable(GL10.GL_TEXTURE_2D); Gdx.gl10.glDisable(GL10.GL_CULL_FACE); Gdx.gl10.glDisable(GL10.GL_LIGHTING); gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL); int page = (int) (-camera.position.y * book.aspectRatio); int p0 = Math.max(0, page - pageSpread), p1 = Math.min(book.pages.size() - 1, page + pageSpread); for (int i = p0; i <= p1; i++) { book.pages.get(i).getTexture().bind(); GfxUtils.fillQuad(-.5f, -(float) (i / book.aspectRatio), 0, 0, .5f, -(float) ((i + 1) / book.aspectRatio), 1, 1); } gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPopMatrix(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPopMatrix(); }
From source file:org.interreg.docexplore.reader.book.roi.ROIOverlay.java
License:Open Source License
public void render() { if (alpha < alphaGoal) alpha += .02f;//from w w w. j av a 2 s .co m else if (alpha > alphaGoal) alpha -= .02f; alpha = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha; if (alpha == 0) return; GL10 gl = Gdx.gl10; gl.glDisable(GL10.GL_LIGHTING); gl.glDisable(GL10.GL_DEPTH_TEST); gl.glDisable(GL10.GL_CULL_FACE); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrthof(-1, 1, -1, 1, -1, 1); gl.glDisable(GL10.GL_TEXTURE_2D); gl.glColor4f(0, 0, 0, .75f * alpha); doQuad(-2 * offsetMargin, 1, 1, -1); float y0 = 0; gl.glEnable(GL10.GL_TEXTURE_2D); gl.glColor4f(1, 1, 1, alpha); for (OverlayElement element : elements) { float w = elementWidth(element); float h = elementHeight(w, element); if (element.bind()) { doQuad(-offsetMargin + .5f - .5f * w, 1 - y0 + offset, -offsetMargin + .5f + .5f * w, 1 - y0 - h + offset); y0 += h + vmargin * element.marginFactor(); } } if (offset > 0) { up.bind(); gl.glColor4f(1, 1, 1, .5f * alpha); float bw = .05f; doQuad(1 - bw, 1, 1, 1 - (bw * Gdx.graphics.getWidth() / Gdx.graphics.getHeight())); } if (offset < maxOffset) { down.bind(); gl.glColor4f(1, 1, 1, .5f * alpha); float bw = .05f; doQuad(1 - bw, (bw * Gdx.graphics.getWidth() / Gdx.graphics.getHeight()) - 1, 1, -1); } gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPopMatrix(); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glDisable(GL10.GL_TEXTURE_2D); }
From source file:org.interreg.docexplore.reader.gfx.Camera.java
License:Open Source License
public void setup() { GL10 gl = Gdx.gl10; gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix();/*from w w w. ja v a 2s . co m*/ gl.glLoadIdentity(); gl.glFrustumf(-.25f, .25f, -.25f, .25f, .25f, 100f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); double[] buf = Math3D.getVector3d(), up = Math3D.getVector3d(); Math3D.crossProduct(Math3D.basej, dir, buf); Math3D.crossProduct(dir, buf, up); Math3D.normalize(up, up); position.set((float) eye[0], (float) eye[1], (float) eye[2]); target.set((float) (eye[0] + dir[0]), (float) (eye[1] + dir[1]), (float) (eye[2] + dir[2])); cup.set((float) up[0], (float) up[1], (float) up[2]); model.setToLookAt(position, target, cup); // Gdx.glu.gluLookAt(gl, (float)eye[0], (float)eye[1], (float)eye[2], // (float)(eye[0]+dir[0]), (float)(eye[1]+dir[1]), (float)(eye[2]+dir[2]), // (float)up[0], (float)up[1], (float)up[2]); Math3D.freeVector3d(buf); Math3D.freeVector3d(up); }
From source file:org.interreg.docexplore.reader.gui.GuiLayer.java
License:Open Source License
public void render() { GL10 gl = Gdx.gl10; gl.glMatrixMode(GL10.GL_MODELVIEW);//from w w w . j a v a 2 s . c o m gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glOrthof(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, -1, 1); for (Widget widget : widgets) widget.render(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPopMatrix(); }