List of usage examples for com.badlogic.gdx.graphics GL10 GL_TEXTURE_2D
int GL_TEXTURE_2D
To view the source code for com.badlogic.gdx.graphics GL10 GL_TEXTURE_2D.
Click Source Link
From source file:com.badlogic.gdx.tests.Water.java
@Override public void render() { GL10 gl = Gdx.graphics.getGL10();/*from w w w .jav a 2s . 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 .j a v a2 s. co 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.rtm.LevelRenderer.java
License:Apache License
@Override public void render() { GL10 gl = Gdx.gl10;// www. j ava 2s . c o m gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glEnable(GL10.GL_TEXTURE_2D); camera.update(); camera.apply(gl); tiles.bind(); gl.glColor4f(1, 1, 1, 1); floorMesh.render(GL10.GL_TRIANGLES); wallMesh.render(GL10.GL_TRIANGLES); batch.begin(); batch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA); font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond() + ", delta:" + Gdx.graphics.getDeltaTime(), 10, 25); batch.end(); processInput(); }
From source file:com.balloongame.handlers.CustomSpriteBatch.java
License:Apache License
/** Sets up the SpriteBatch for drawing. This will disable depth buffer writting. It enables blending and texturing. If you have * more texture units enabled than the first one you have to disable them before calling this. Uses a screen coordinate system * by default where everything is given in pixels. You can specify your own projection and modelview matrices via * {@link #setProjectionMatrix(Matrix4)} and {@link #setTransformMatrix(Matrix4)}. */ public void begin() { if (drawing)/*from ww w . j av a 2 s. co m*/ throw new IllegalStateException("you have to call SpriteBatch.end() first"); renderCalls = 0; Gdx.gl.glDepthMask(false); if (Gdx.graphics.isGL20Available()) { if (customShader != null) customShader.begin(); else shader.begin(); } else { Gdx.gl.glEnable(GL10.GL_TEXTURE_2D); } setupMatrices(); idx = 0; lastTexture = null; drawing = true; }
From source file:com.balloongame.handlers.CustomSpriteBatch.java
License:Apache License
/** Finishes off rendering. Enables depth writes, disables blending and texturing. Must always be called after a call to * {@link #begin()} *///w w w .j a v a2 s . c o m public void end() { if (!drawing) throw new IllegalStateException("SpriteBatch.begin must be called before end."); if (idx > 0) renderMesh(); lastTexture = null; idx = 0; drawing = false; GLCommon gl = Gdx.gl; gl.glDepthMask(true); if (isBlendingEnabled()) gl.glDisable(GL10.GL_BLEND); if (Gdx.graphics.isGL20Available()) { if (customShader != null) customShader.end(); else shader.end(); } else { gl.glDisable(GL10.GL_TEXTURE_2D); } }
From source file:com.davidykay.shootout.Renderer.java
License:Apache License
public void render(Application app, Simulation simulation) { GL10 gl = app.getGraphics().getGL10(); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glViewport(0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight()); renderBackground(gl);//w w w .ja v a 2s . c o m renderEarth(gl); gl.glDisable(GL10.GL_DITHER); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glEnable(GL10.GL_CULL_FACE); //setProjectionAndCamera(app.getGraphics(), simulation.ship, app); setProjectionAndCameraAugmentedReality(app.getGraphics(), simulation, app); setLighting(gl); gl.glEnable(GL10.GL_TEXTURE_2D); renderMoon(gl, simulation.ship); renderShip(gl, simulation.ship, app); renderAliens(gl, simulation.aliens); gl.glDisable(GL10.GL_TEXTURE_2D); renderBlocks(gl, simulation.blocks); gl.glDisable(GL10.GL_LIGHTING); //renderShots(gl, simulation.shots); //renderRays(gl, simulation.mRays, true); renderAlienRays(gl, simulation.mAlienRays); renderPlayerRays(gl, simulation.mShipRays); gl.glEnable(GL10.GL_TEXTURE_2D); renderExplosions(gl, simulation.explosions); renderBombExplosions(gl, simulation.bombExplosions); gl.glDisable(GL10.GL_CULL_FACE); gl.glDisable(GL10.GL_DEPTH_TEST); spriteBatch.setProjectionMatrix(viewMatrix); spriteBatch.setTransformMatrix(transformMatrix); spriteBatch.begin(); if (simulation.ship.lives != lastLives || simulation.score != lastScore || simulation.wave != lastWave) { status = "lives: " + simulation.ship.lives + " wave: " + simulation.wave + " score: " + simulation.score; lastLives = simulation.ship.lives; lastScore = simulation.score; lastWave = simulation.wave; } spriteBatch.enableBlending(); spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA); font.draw(spriteBatch, status, 0, 320); spriteBatch.end(); alienAngle += app.getGraphics().getDeltaTime() * 90; if (alienAngle > 360) alienAngle -= 360; }
From source file:com.dgcgames.balloonblast.GameScreen.java
License:Apache License
@Override public void present(float deltaTime) { GLCommon gl = Gdx.gl;/*w w w . j av a 2 s.c o m*/ gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glEnable(GL10.GL_TEXTURE_2D); renderer.render(); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.enableBlending(); batcher.begin(); switch (state) { case GAME_READY: presentReady(); break; case GAME_RUNNING: presentRunning(); break; case GAME_PAUSED: presentPaused(); break; case GAME_LEVEL_END: presentLevelEnd(); break; case GAME_OVER: presentGameOver(); break; } batcher.end(); }
From source file:com.dgcgames.balloonblast.HelpScreen.java
License:Apache License
@Override public void present(float deltaTime) { GLCommon gl = Gdx.gl;//from w ww. j a v a2 s. co m gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); guiCam.apply(Gdx.gl10); gl.glEnable(GL10.GL_TEXTURE_2D); batcher.disableBlending(); batcher.begin(); batcher.draw(helpRegion, 0, 0, 1024, 768); batcher.end(); batcher.enableBlending(); batcher.begin(); //batcher.draw(Assets.arrow, 320, 0, -64, 64); batcher.end(); gl.glDisable(GL10.GL_BLEND); }
From source file:com.dgcgames.balloonblast.HighscoresScreen.java
License:Apache License
@Override public void present(float deltaTime) { GLCommon gl = Gdx.gl;/*from w w w. ja va2 s.c o m*/ gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); guiCam.apply(Gdx.gl10); gl.glEnable(GL10.GL_TEXTURE_2D); batcher.disableBlending(); batcher.begin(); batcher.draw(Assets.backgroundRegion, 0, 0, 1024, 768); batcher.end(); batcher.enableBlending(); batcher.begin(); batcher.draw(Assets.highScoresRegion, 400, 360 - 18, 300, 33); float y = 230; for (int i = 4; i >= 0; i--) { Assets.font.draw(batcher, highScores[i], xOffset, y); y += Assets.font.getLineHeight(); } //batcher.draw(Assets.arrow, 0, 0, 64, 64); //batcher.draw(Assets.balloon, 0, 0, 64, 64); batcher.end(); }
From source file:com.digitale.mygdxgame.Renderer.java
License:Open Source License
private void renderSolarSystem(Application app, Simulation simulation) { GL10 gl = app.getGraphics().getGL10(); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glViewport(0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight()); // renderBackground(gl); gl.glDisable(GL10.GL_DITHER);/*from w w w. j a va 2 s . c o m*/ gl.glEnable(GL10.GL_DEPTH_TEST); gl.glEnable(GL10.GL_CULL_FACE); setProjectionAndCamera(app.getGraphics(), Simulation.ship, app, gl); setLighting(gl); gl.glEnable(GL10.GL_TEXTURE_2D); // renderRoids(gl); // camera.unproject(GameLoop.touchPoint.set(Gdx.input.getX(), // Gdx.input.getY(), 0)); // render earth // renderPlanet(gl, "earth", true, 63780f, 200000, 0, 50000); // render mars renderPlanet(gl, "sun", true, 33970, 0, 0, 50000); // render sun renderSun(gl, 69550f, 0, 0, -500000, app); // render jupiter // renderPlanet(gl, "earth", false, 714920f, -4000000, 0, 50000); // render moon // renderMoon(gl, 17370f, 100000, 0, -50000); // renderDrones(gl, simulation.drones, app, Simulation.ship); renderSky(gl, Simulation.ship, app); renderActors(gl); // do alpha models after this // render station renderStation(gl, "station01", true, 1000f, 0, 0, 0); // render myship renderShip(gl, Simulation.ship, Stardust3d.myCharacter.getShipname()); renderDusts(gl, Simulation.dusts); renderShots(gl, simulation.shots); renderMissiles(gl, simulation.missiles); // renderTrails(gl, simulation.trails); gl.glDisable(GL10.GL_TEXTURE_2D); // renderBlocks(gl, simulation.blocks); // gl.glDisable(GL10.GL_LIGHTING); gl.glEnable(GL10.GL_TEXTURE_2D); renderExplosions(gl, Simulation.explosions); renderHud(simulation, gl); stationAngle += app.getGraphics().getDeltaTime() * 1; if (stationAngle > 360) stationAngle -= 360; invaderAngle += app.getGraphics().getDeltaTime() * 10; if (invaderAngle > 360) invaderAngle -= 360; }