List of usage examples for com.badlogic.gdx.graphics GL20 GL_TEXTURE0
int GL_TEXTURE0
To view the source code for com.badlogic.gdx.graphics GL20 GL_TEXTURE0.
Click Source Link
From source file:com.watabou.glwrap.NoosaTexture.java
License:Open Source License
public static void activate(int index) { Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0 + index); }
From source file:it.alcacoop.fourinaline.actors.BoardImage.java
License:Open Source License
public void layout() { if (drawable == null) return;//ww w .ja v a 2s . c o m float regionWidth = drawable.getMinWidth(); float regionHeight = drawable.getMinHeight(); float width = getWidth(); float height = getHeight(); Vector2 size = scaling.apply(regionWidth, regionHeight, width, height); imageWidth = size.x; imageHeight = size.y; if ((align & Align.left) != 0) imageX = 0; else if ((align & Align.right) != 0) imageX = (int) (width - imageWidth); else imageX = (int) (width / 2 - imageWidth / 2); if ((align & Align.top) != 0) imageY = (int) (height - imageHeight); else if ((align & Align.bottom) != 0) imageY = 0; else imageY = (int) (height / 2 - imageHeight / 2); if (fbo1 == null) { fbo1 = new FrameBuffer(Format.RGBA8888, (int) getWidth(), (int) getHeight(), false); fbo2 = new FrameBuffer(Format.RGBA8888, (int) getWidth(), (int) getHeight(), false); } SpriteBatch sb = new SpriteBatch(); Matrix4 matrix = new Matrix4(); matrix.setToOrtho2D(0, 0, getWidth(), getHeight()); // here is the actual size you want sb.setProjectionMatrix(matrix); fbo1.begin(); sb.begin(); Gdx.gl.glClearColor(1, 1, 1, 0); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); if (drawable != null) { for (int x = 0; x < nx; x++) for (int y = 0; y < ny; y++) { sb.draw(mask, x * xdim, y * ydim, 0, 0, xdim, ydim, 1, 1, 0); } } sb.end(); fbo1.end(); fbo2.begin(); sb.setShader(shader); sb.begin(); Gdx.gl.glClearColor(1, 1, 1, 0); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE1); wood.bind(); shader.setUniformi("u_wood", 1); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); sb.draw(fbo1.getColorBufferTexture(), 0, 0, getWidth(), getHeight()); sb.end(); shader.end(); sb.setShader(null); fbo2.end(); }
From source file:it.alcacoop.fourinaline.actors.Checker.java
License:Open Source License
public void setColor(int color) { this.color = color; rotation = rnd.nextFloat() * 360;//ww w . j av a2 s . c o m Sprite sprite; sprite = new Sprite(r1); sprite.setRotation(rotation); double a = (double) r1.getRegionWidth(); double b = (double) wood.getWidth(); float d = (float) (a / b); float x = (rnd.nextFloat() * d); float y = (rnd.nextFloat() * d); fbo.begin(); Gdx.gl.glClearColor(1, 1, 1, 0); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); sb.setShader(shader); shader.begin(); sb.begin(); shader.setUniformf("u_sx", x); shader.setUniformf("u_sy", y); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE1); wood.bind(); shader.setUniformi("u_wood", 1); Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); sprite.draw(sb); sb.end(); shader.end(); sb.setShader(null); fbo.end(); reg = new TextureRegion(fbo.getColorBufferTexture()); }
From source file:mobi.shad.s3lib.gfx.effect.PostRender.java
License:Apache License
@Override public void postRender() { sourceTexture = captureTexture.getResultTexture(); if (blurSwitch) { processBlurFilter();/*from w w w .j a v a2 s . c o m*/ } else { captureTexture.end(); sourceTexture = captureTexture.getResultTexture(); destTexture = captureTexture.getResultTexture(); } // // Draw result // S3.gl.glClearColor(0.0f, 0.0f, 0.0f, 1); S3.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (blurSwitch || sepiaSwitch || vignetteSwitch || levelSwitch) { S3.gl.glEnable(GL20.GL_TEXTURE); S3Gfx.drawFlipMeshQuad(sourceTexture, destTexture, mixShader); // // Clear texture unit // S3.gl.glActiveTexture(GL20.GL_TEXTURE0); S3.gl.glDisable(GL20.GL_TEXTURE); } else { S3Gfx.drawFlipBackground(sourceTexture); } // S3Gfx.drawBackground(sourceTexture, 0, 0, 300, 300); // S3Gfx.drawBackground(destTexture, 300, 600, 0, 300); }
From source file:mobi.shad.s3lib.main.S3AppManager.java
License:Apache License
/** * @param gfx//from w w w. ja v a 2s .co m * @param delta */ public void render(final S3Gfx gfx) { if (pauseApp) { return; } S3.gl.glClearColor(backGroundColor.r, backGroundColor.g, backGroundColor.b, backGroundColor.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (isTransistion == false) { if (currentApp != null) { currentApp.render(gfx); } } else { transistionTime += S3.osDeltaTime; transistionProcent = transistionTime / transistionDuration; transistionAlpha = transistionInterpolation.apply(0f, 1f, transistionProcent); if (transistionProcent < 0.5) { if (currentApp != null) { currentApp.update(); currentApp.render(gfx); } } else { if (isTransistionEnd == false) { isTransistionEnd = true; if (lastApp != null) { if (logEnable) { S3Log.log(TAG, "hide: " + lastApp.getClass().getSimpleName()); } lastApp.hide(); } if (nextApp != null) { if (logEnable) { S3Log.log(TAG, "show: " + nextApp.getClass().getSimpleName()); } nextApp.show(); } } if (nextApp != null) { nextApp.update(); nextApp.render(gfx); } } if (transistionProcent > 1) { isTransistion = false; lastApp = null; currentApp = nextApp; nextApp = null; S3.renderStage = true; } switch (transistionMode) { default: transistionColor.a = (transistionAlpha > 0.5f) ? 1 - (transistionAlpha * 2 - 1) : (transistionAlpha * 2); break; case 1: transistionColor.a = transistionAlpha; break; case 2: transistionColor.a = 1 - transistionAlpha; break; } if (transistionColor.a < 0.001f) { transistionColor.a = 0; } if (transistionColor.a > 0.999f) { transistionColor.a = 1f; } if (S3.stage != null) { // // Resetowanie GUI dla texture0 // S3Screen.gl20.glActiveTexture(GL20.GL_TEXTURE0); S3.stage.act(S3.osDeltaTime); S3.stage.draw(); } S3Gfx.drawBackground(transistionColor); } }
From source file:postprocessing.PostProcessor.java
License:Apache License
/** Stops capturing the scene and apply the effect chain, if there is one. If the specified output framebuffer is NULL, then the * rendering will be performed to screen. */ public void render(FrameBuffer dest) { captureEnd();//from w w w.j a v a 2 s . c o m if (!hasCaptured) { return; } // Array<PostProcessorEffect> items = manager.items; Array<PostProcessorEffect> items = enabledEffects; int count = items.size; if (count > 0) { Gdx.gl.glDisable(GL20.GL_CULL_FACE); Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); // render effects chain, [0,n-1] if (count > 1) { for (int i = 0; i < count - 1; i++) { PostProcessorEffect e = items.get(i); composite.capture(); { e.render(composite.getSourceBuffer(), composite.getResultBuffer()); } } // complete composite.end(); } if (listener != null && dest == null) { listener.beforeRenderToScreen(); } // render with null dest (to screen) items.get(count - 1).render(composite.getResultBuffer(), dest); // ensure default texture unit #0 is active Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); } else { Gdx.app.log("PostProcessor", "No post-processor effects enabled, aborting render"); } }
From source file:releasethekraken.ui.renderer.GameRenderer.java
/** * Constructs a new GameRenderer//from w w w. j a v a 2s. c o m * @param rtk The ReleaseTheKraken instance. This is final so that the * anonymous inner classes can access it. * @param world The world to be rendered */ public GameRenderer(final ReleaseTheKraken rtk, GameWorld world) { super(); this.world = world; //Populate the list of connected paths this.world.getFirstPath().getAllConnectedPaths(this.seaCreaturePaths); //Create the camera to view the world this.camera = new OrthographicCamera(); float cameraWidth = 80.0F; float cameraHeight = (Gdx.graphics.getHeight() * 1F / Gdx.graphics.getWidth()) * cameraWidth; this.camera.setToOrtho(false, cameraWidth, cameraHeight); Gdx.app.log("GameRenderer", "Calculated camera dimensions: " + cameraWidth + " x " + cameraHeight); this.worldSpriteBatch = new SpriteBatch(); this.worldShapeRenderer = new ShapeRenderer(); //Set the world renderers to render to the camera's projection matrix this.worldSpriteBatch.setProjectionMatrix(this.camera.combined); this.worldShapeRenderer.setProjectionMatrix(this.camera.combined); //Create the Box2D debug renderer this.box2DDebugRenderer = new Box2DDebugRenderer(); this.box2DDebugRenderer.setDrawVelocities(true); //Create the tile map renderer this.tiledMapRenderer = new OrthogonalTiledMapRenderer(world.getTiledMap(), 1 / (world.getTiledMapUnitScale())); //this.tiledMapRenderer.getBatch().setShader(GameAssets.tilemapShader); //Set the shader //Don't use the shader for now this.debugOverlay = new DebugOverlay(this); this.uiObjects.add(this.debugOverlay); UiButton pauseButton = new UiButton(this, Gdx.graphics.getWidth() - 0.075F * Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 0.05F * Gdx.graphics.getHeight(), 0.075F, 0.05F, "Pause", Color.GRAY.cpy().sub(0.1F, 0.1F, 0.1F, 0)) { @Override public void onClick(int mouseButton) { super.onClick(mouseButton); //Take a screenshot of the game Pixmap pixmap = Screenshots.getScreenshot(true); //Push a new pause screen onto the screen stack rtk.pushScreen(new PauseScreen(rtk, pixmap)); } }; pauseButton.setToolTip(new TextToolTip(this, "Pause the game")); this.uiObjects.add(pauseButton); UiButton debugMenuButton = new UiButton(this, Gdx.graphics.getWidth() - 0.2323F * Gdx.graphics.getWidth(), Gdx.graphics.getHeight() - 0.05F * Gdx.graphics.getHeight(), 0.157F, 0.05F, "Debug Screen", Color.GRAY.cpy().sub(0.1F, 0.1F, 0.1F, 0)) { @Override public void onClick(int mouseButton) { super.onClick(mouseButton); if (this.renderer instanceof GameRenderer) { ((GameRenderer) this.renderer).debugScreenVisible = !((GameRenderer) this.renderer).debugScreenVisible; //Toggle visibility Gdx.app.log("Debug Menu Button", "Debug screen " + (((GameRenderer) this.renderer).debugScreenVisible ? "ON" : "OFF")); } } }; debugMenuButton.setToolTip(new TextToolTip(this, "Show/Hide Debug Screen")); this.uiObjects.add(debugMenuButton); this.uiObjects.add(new Sidebar(this)); //Add the sidebar this.uiObjects.sort(); //Sort the UI objects so that they render in the order of their render depths //Generate path pixmap and texture Pixmap.setBlending(Pixmap.Blending.None); //Disable Pixmap blending, because it causes weird lines this.pathPixmap = new Pixmap((int) (this.world.getWidth() * this.world.getTiledMapUnitScale()), (int) (this.world.getHeight() * this.world.getTiledMapUnitScale()), Pixmap.Format.RGBA8888); //Make sure the pixmap is clear this.pathPixmap.setColor(new Color(0, 0, 0, 0)); //Completely clear this.pathPixmap.fill(); this.pathPixmap.setColor(Color.valueOf("61B5FF66")); //Partial transparency with color //Draw the path for every path for (SeaCreaturePath path : this.seaCreaturePaths) { CatmullRomSpline smoothPath = path.getSmoothPath(); Vector2 pathPoint = new Vector2(); //Move across the path from 0 to 1, drawing circles along the way for (float f = -0.1F; f < 1.1F; f += 0.001F) { smoothPath.valueAt(pathPoint, f); //Stores the value of the path at the point in the vector this.pathPixmap.fillCircle((int) (pathPoint.x * this.world.getTiledMapUnitScale()), (int) (this.world.getHeight() * this.world.getTiledMapUnitScale() - (pathPoint.y * this.world.getTiledMapUnitScale())), (int) this.world.getTiledMapUnitScale()); } } //Create texture to hold pixmap data this.pathTexture = new Texture(this.pathPixmap); this.pathTexture.draw(this.pathPixmap, 0, 0); //Draw the pixmap to the texture this.pathTexture.bind(1); //Bind the texture to texture unit 1 Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); //Set the active texture back to the normal one }