List of usage examples for com.badlogic.gdx.graphics GL10 GL_MODELVIEW
int GL_MODELVIEW
To view the source code for com.badlogic.gdx.graphics GL10 GL_MODELVIEW.
Click Source Link
From source file:com.badlogic.gdx.tests.lw.WaterRipplesLW.java
License:Apache License
@Override public void render() { GL10 gl = Gdx.graphics.getGL10();//w ww . j a v a 2 s. c o m gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); 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.Water.java
@Override public void render() { GL10 gl = Gdx.graphics.getGL10();/*from w w w . jav a2s. c o m*/ if (gl == null) { return; } gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(camera.getCombinedMatrix().val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); 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), (int) (Gdx.input.getY(i) / (float) Gdx.graphics.getHeight() * Gdx.graphics.getWidth())); 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();//w w w. jav a 2 s . c om gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); 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.balloongame.handlers.CustomSpriteBatch.java
License:Apache License
private void setupMatrices() { if (!Gdx.graphics.isGL20Available()) { GL10 gl = Gdx.gl10;//from w w w. ja v a2 s.c om gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadMatrixf(projectionMatrix.val, 0); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadMatrixf(transformMatrix.val, 0); } else { combinedMatrix.set(projectionMatrix).mul(transformMatrix); if (customShader != null) { customShader.setUniformMatrix("u_projTrans", combinedMatrix); customShader.setUniformi("u_texture", 0); } else { shader.setUniformMatrix("u_projTrans", combinedMatrix); shader.setUniformi("u_texture", 0); } } }
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); gl.glLoadIdentity();/* w w w . j av a2 s. co m*/ // 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); gl.glLoadIdentity();// www . j a va 2 s. c o m // 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();//from w w w . j av a2 s. c o m //x=left-right, y=up-down, z=back-forward camera.far = 1000000; 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();// w w w . jav a 2 s . c om gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); camera.update(); 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.BookEngineRenderer.java
License:Open Source License
public void render() { BookSpecification spec = engine.book; BookModel model = engine.model;/*from ww w .ja v a 2 s . c o m*/ GL10 gl = Gdx.gl10; cnt += .01; engine.attractor.attract(engine.camera, .075f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPushMatrix(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPushMatrix(); engine.camera.apply(gl); gl.glEnable(GL10.GL_LIGHTING); gl.glEnable(GL10.GL_LIGHT0); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambient); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuse); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glTranslatef((float) engine.globalTrans, 0, 0); gl.glRotatef((float) (engine.globalRot * 180 / Math.PI), 0, 1, 0); boolean pageIsActive = engine.hand.pageIsActive; int leftPageIndex = model.leftStack.nStackPages > 0 ? 1 + 2 * (model.leftStack.nStackPages - 1) : -1; int rightPageIndex = model.rightStack.nStackPages > 0 ? leftPageIndex + 1 + (pageIsActive ? 2 : 0) : -1; Bindable leftPage = leftPageIndex >= 0 ? spec.pages.get(leftPageIndex).getTexture() : null; Bindable rightPage = rightPageIndex >= 0 ? spec.pages.get(rightPageIndex).getTexture() : null; Bindable pageFront = pageIsActive ? spec.pages.get(leftPageIndex + 1).getTexture() : null; Bindable pageBack = pageIsActive ? spec.pages.get(leftPageIndex + 2).getTexture() : null; Gdx.gl10.glEnable(GL10.GL_CULL_FACE); gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL); boolean zoomed = engine.zoom.active; model.render(leftPage, rightPage, pageFront, pageBack, engine.book.coverTex, engine.book.innerCoverTex, zoomed ? null : leftRoiMask, zoomed ? null : rightRoiMask); for (Component extension : engine.components) extension.render(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glPopMatrix(); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glPopMatrix(); }
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 . jav a2s . co 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(); }