List of usage examples for com.badlogic.gdx.graphics GL10 GL_BLEND
int GL_BLEND
To view the source code for com.badlogic.gdx.graphics GL10 GL_BLEND.
Click Source Link
From source file:app.badlogicgames.superjumper.HelpScreen.java
License:Apache License
public void draw() { GLCommon gl = Gdx.gl;/*from w w w . ja v a 2s .c o m*/ gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(helpRegion, 0, 0, 320, 480); 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.badlogic.gdx.graphics.g3d.test.PrototypeRendererGL20.java
License:Apache License
private void renderBlended() { Gdx.gl.glEnable(GL10.GL_BLEND); final Array<Drawable> transparentDrawables = drawableManager.drawablesBlended; transparentDrawables.sort();/* w w w . ja va 2 s. co m*/ // find N nearest lights per model // draw all models from opaque queue int lastSrcBlend = -1; int lastDstBlend = -1; for (int i = 0, size = transparentDrawables.size; i < size; i++) { final Drawable drawable = transparentDrawables.get(i); final Vector3 center = drawable.sortCenter; lightManager.calculateLights(center.x, center.y, center.z); final Matrix4 modelMatrix = drawable.transform; normalMatrix.set(modelMatrix); if (drawable.isAnimated) ((AnimatedModel) (drawable.model)).setAnimation(drawable.animation, drawable.animationTime, drawable.isLooping); final SubMesh subMeshes[] = drawable.model.getSubMeshes(); boolean matrixChanged = true; for (int j = 0; j < subMeshes.length; j++) { final SubMesh subMesh = subMeshes[j]; final Material material = drawable.materials.get(j); // bind new shader if material can't use old one final boolean shaderChanged = bindShader(material); if (shaderChanged || matrixChanged) { currentShader.setUniformMatrix("u_normalMatrix", normalMatrix, false); currentShader.setUniformMatrix("u_modelMatrix", modelMatrix, false); matrixChanged = false; } for (int k = 0, len = material.getNumberOfAttributes(); k < len; k++) { final MaterialAttribute atrib = material.getAttribute(k); // yet another instanceof. TODO is there any better way to do this? maybe stuffing this to material if (atrib instanceof BlendingAttribute) { final BlendingAttribute blending = (BlendingAttribute) atrib; if (blending.blendSrcFunc != lastSrcBlend || blending.blendDstFunc != lastDstBlend) { atrib.bind(currentShader); lastSrcBlend = blending.blendSrcFunc; lastDstBlend = blending.blendDstFunc; } } else if (atrib instanceof TextureAttribute) { // special case for textures. really important to batch these final TextureAttribute texAtrib = (TextureAttribute) atrib; if (!texAtrib.texturePortionEquals(lastTexture[texAtrib.unit])) { lastTexture[texAtrib.unit] = texAtrib; texAtrib.bind(currentShader); } else { // need to be done, shader textureAtribute name could be changed. currentShader.setUniformi(texAtrib.name, texAtrib.unit); } } else if (atrib instanceof GpuSkinningAttribute) { final GpuSkinningAttribute gpuAtrib = (GpuSkinningAttribute) atrib; gpuAtrib.setModelMatrix(modelMatrix); gpuAtrib.bind(currentShader); } else { atrib.bind(currentShader); } } // finally render current submesh subMesh.getMesh().render(currentShader, subMesh.primitiveType); } } Gdx.gl.glDisable(GL10.GL_BLEND); }
From source file:com.badlogic.gdx.graphics.g3d.test.QbobViewer.java
License:Apache License
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1);//from www . ja va2s . co m Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); cam.update(); cam.apply(Gdx.gl10); Gdx.gl.glEnable(GL10.GL_CULL_FACE); Gdx.gl.glEnable(GL10.GL_DEPTH_TEST); Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0); Gdx.gl.glEnable(GL10.GL_TEXTURE_2D); diffuse.bind(); diffuse.setFilter(TextureFilter.MipMap, TextureFilter.Linear); Gdx.gl.glActiveTexture(GL10.GL_TEXTURE1); Gdx.gl.glEnable(GL10.GL_TEXTURE_2D); lightMaps[0].bind(); lightMaps[0].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear); setCombiners(); model[0].render(); lightMaps[1].bind(); lightMaps[1].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear); setCombiners(); model[1].render(); lightMaps[2].bind(); lightMaps[2].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear); setCombiners(); model[2].render(); lightMaps[3].bind(); lightMaps[3].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear); setCombiners(); model[3].render(); Gdx.gl.glActiveTexture(GL10.GL_TEXTURE1); Gdx.gl.glDisable(GL10.GL_TEXTURE_2D); Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0); Gdx.gl.glDisable(GL10.GL_CULL_FACE); Gdx.gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); Gdx.gl.glDisable(GL10.GL_BLEND); animTime += Gdx.graphics.getDeltaTime(); if (animTime > anim.totalDuration - anim.frameDuration) animTime = 0; animModel.setAnimation(anim.name, animTime, true); Gdx.gl10.glPushMatrix(); Gdx.gl10.glTranslatef(cam.position.x, cam.position.y, 6); animModel.render(); Gdx.gl10.glPopMatrix(); Gdx.gl.glDisable(GL10.GL_DEPTH_TEST); batch.begin(); font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20); batch.end(); fps.log(); }
From source file:com.badlogic.gdx.graphics.g3d.test.SkeletonModelViewer.java
License:Apache License
@Override public void render() { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL10.GL_DEPTH_TEST); cam.update();//from w ww . j av a 2s .co m cam.apply(Gdx.gl10); drawAxes(); if (hasNormals) { Gdx.gl.glEnable(GL10.GL_LIGHTING); Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL); Gdx.gl.glEnable(GL10.GL_LIGHT0); Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0); Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0); } if (texture != null) { Gdx.gl.glEnable(GL10.GL_TEXTURE_2D); Gdx.gl.glEnable(GL10.GL_BLEND); Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); } angle += 45 * Gdx.graphics.getDeltaTime(); Gdx.gl10.glRotatef(angle, 0, 1, 0); animTime += Gdx.graphics.getDeltaTime() / 10; if (animTime > anim.totalDuration) { animTime = 0; } model.setAnimation(anim.name, animTime, false); model.render(); if (texture != null) { Gdx.gl.glDisable(GL10.GL_TEXTURE_2D); } if (hasNormals) { Gdx.gl.glDisable(GL10.GL_LIGHTING); } batch.begin(); font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30); batch.end(); }
From source file:com.badlogic.gdx.physics.bullet.demo.screens.SimulationScreen.java
@Override public final void render(float graphicsDelta) { // Physics// www . ja va2 s . com hookRenderPrePhysics(graphicsDelta); final float physicsDelta = stepPhysics(); hookRenderPostPhysics(graphicsDelta, physicsDelta); // Clear frame and enable model styles Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); hookRenderPostClear(graphicsDelta, physicsDelta); // Apply perspective player camera perspectiveCamera.apply(Gdx.gl10); Gdx.gl10.glEnable(GL10.GL_DITHER); Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST); Gdx.gl10.glEnable(GL10.GL_CULL_FACE); Gdx.gl10.glEnable(GL10.GL_BLEND); Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); // Position lights so lighting calculations for objects are correct positionLights(graphicsDelta, physicsDelta); renderDynamicsWorld(); hookRenderScene(graphicsDelta, physicsDelta); // Apply orthographic OSD camera osdCamera.apply(Gdx.gl10); // Disable face culling so we draw everything Gdx.gl10.glDisable(GL10.GL_CULL_FACE); // Render OSD disableLights(); osdSpriteBatch.begin(); osdFont.setColor(1, 1, 1, 1f); osdFont.draw(osdSpriteBatch, getOSDText(), 10, 10 + osdFont.getCapHeight()); osdSpriteBatch.end(); hookRenderOSD(graphicsDelta, physicsDelta); }
From source file:com.badlogicgames.superjumper.CharScreen.java
License:Apache License
public void draw(float deltaTime) { GLCommon gl = Gdx.gl;//from w w w. ja v a 2 s. c o m gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(Assets.welcome, 0, 0, 512, 512); //MainMenuScreen.drawGradient(batcher, Assets.rect, 0, 0, 320, 480,Color.BLACK,Color.BLUE, false); batcher.end(); batcher.enableBlending(); batcher.begin(); ruota.draw(batcher, Assets.ruotaRegion, 512 + 128, 512 + 128); batcher.draw(Assets.choose, 0, 0, 512, 512); batcher.draw(Assets.icontext, 275, 10, 45, 45); batcher.draw(Assets.icontextback, 0, 10, 45, 45); //int len = buttons.size(); /* for (int i = 0; i < len; i++) { Button button = buttons.get(i); Texture keyFrame =Assets.lock; if(i==1)keyFrame=Assets.locked; //batcher.draw(keyFrame,button.position.x,button.position.y,145,145); }*/ for (Button button : buttons) { button.draw(batcher); } Assets.fontsmall.draw(batcher, "GO", 285, 40); stateTime = stateTime + 0.020f; TextureRegion keyFrame1 = Assets.swipeAnim.getKeyFrame(stateTime, Animation.ANIMATION_LOOPING); if (stateTime > 4) stateTime = 0; if (swipedeactive == 0) { batcher.draw(Assets.swipetext, 10, 0, 320, 256); batcher.draw(keyFrame1, 10, 0, 320, 256); } batcher.draw(Assets.backgroundRegion, bob.position.x, bob.position.y, 130, 130); batcher.draw(Assets.backgroundRegion10, bobfem.position.x, bobfem.position.y, 130, 130); batcher.draw(Assets.backgroundRegion11, bobmil.position.x - 20, bobmil.position.y, 170, 170); if (Settings.firstScore() < 20000 && state == 0) { batcher.draw(Assets.lock, bobfem.position.x - 10, bobfem.position.y + 30, 100, 100); batcher.draw(Assets.locked, bobfem.position.x - 45, bobfem.position.y - 70, 170, 150); Assets.fontsmall.draw(batcher, "need 20000 scores", guiCam.position.x - 90, guiCam.position.y - 150); } if (Settings.firstScore() < 70000 && state == 2) { batcher.draw(Assets.lock, bobmil.position.x + 26, bobmil.position.y + 30, 85, 100); batcher.draw(Assets.locked, bobmil.position.x - 18, bobmil.position.y - 70, 170, 150); Assets.fontsmall.draw(batcher, "need 70000 scores", guiCam.position.x - 90, guiCam.position.y - 150); } //batcher.draw(Assets.backgroundRegion,bob.position.x ,bob.position.y ,25, 35, 120, 150, 1, 1, 180); //batcher.draw(Assets.backgroundRegion10,bobfem.position.x ,bobfem.position.y ,25, 35, 120, 150, 1, 1, 180); batcher.end(); gl.glDisable(GL10.GL_BLEND); }
From source file:com.badlogicgames.superjumper.FirstScreen.java
License:Apache License
public void draw(float deltaTime) { GLCommon gl = Gdx.gl;// w ww .ja va 2s . c o m gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(Assets.welcome, 0, 0, UI.SCREENPOSITIONX, UI.SCREENPOSITIONY); batcher.end(); batcher.enableBlending(); batcher.begin(); ruota.draw(batcher, Assets.ruotaRegion, UI.RUOTASIZE, UI.RUOTASIZE); Assets.handfontsmall.scale(-UI.FIRSTSCREENTEXTSCALE); Assets.handfontsmall.getRegion().getTexture().setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.MipMapLinearNearest); for (int i = 0; i < testo.size(); i++) testo.get(i).drawAnim(batcher); Assets.handfontsmall.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); Assets.handfontsmall.scale(UI.FIRSTSCREENTEXTSCALE); batcher.end(); gl.glDisable(GL10.GL_BLEND); }
From source file:com.badlogicgames.superjumper.HelpScreen.java
License:Apache License
public void draw(float deltaTime) { GLCommon gl = Gdx.gl;//ww w.ja v a2 s. co m gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(helpRegion, 0, 0, 320, 480); 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.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()} *//*from w w w.j a v a 2 s. com*/ 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.bitfire.postprocessing.effects.CrtMonitor.java
License:Apache License
@Override public void render(FrameBuffer src, FrameBuffer dest) { // the original scene Texture in = src.getColorBufferTexture(); boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND); Gdx.gl.glDisable(GL10.GL_BLEND); Texture out = null;//w w w. jav a2 s . c o m if (doblur) { pingPongBuffer.begin(); { // crt pass crt.setInput(in).setOutput(pingPongBuffer.getSourceBuffer()).render(); // blur pass blur.render(pingPongBuffer); } pingPongBuffer.end(); out = pingPongBuffer.getResultTexture(); } else { // crt pass crt.setInput(in).setOutput(buffer).render(); out = buffer.getColorBufferTexture(); } if (blending || blendingWasEnabled) { Gdx.gl.glEnable(GL20.GL_BLEND); } if (blending) { Gdx.gl.glBlendFunc(sfactor, dfactor); } // do combine pass combine.setOutput(dest).setInput(in, out).render(); }