com.badlogic.gdx.graphics.glutils.FrameBuffer Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.glutils.FrameBuffer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UIScreen.java From uracer-kotd with Apache License 2.0 | 6 votes |
@Override public void render (FrameBuffer dest) { boolean hasDest = (dest != null); if (hasDest) { ui.getViewport().update(dest.getWidth(), dest.getHeight(), true); dest.begin(); } else { ui.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); } draw(); if (hasDest) { dest.end(); } }
Example #2
Source File: TransitionManager.java From uracer-kotd with Apache License 2.0 | 6 votes |
public TransitionManager (Rectangle viewport, boolean use32Bits, boolean useAlphaChannel, boolean useDepth) { this.viewport.set(viewport); transition = null; paused = false; fbFormat = Format.RGB565; usedepth = useDepth; if (use32Bits) { if (useAlphaChannel) { fbFormat = Format.RGBA8888; } else { fbFormat = Format.RGB888; } } else { if (useAlphaChannel) { fbFormat = Format.RGBA4444; } else { fbFormat = Format.RGB565; } } fbFrom = new FrameBuffer(fbFormat, (int)viewport.width, (int)viewport.height, useDepth); fbTo = new FrameBuffer(fbFormat, (int)viewport.width, (int)viewport.height, useDepth); }
Example #3
Source File: CrtMonitor.java From uracer-kotd with Apache License 2.0 | 6 votes |
public CrtMonitor (int fboWidth, int fboHeight, boolean barrelDistortion, boolean performBlur, RgbMode mode, int effectsSupport) { doblur = performBlur; if (doblur) { pingPongBuffer = PostProcessor.newPingPongBuffer(fboWidth, fboHeight, PostProcessor.getFramebufferFormat(), false); blur = new Blur(fboWidth, fboHeight); blur.setPasses(1); blur.setAmount(1f); // blur.setType( BlurType.Gaussian3x3b ); // high defocus blur.setType(BlurType.Gaussian3x3); // modern machines defocus } else { buffer = new FrameBuffer(PostProcessor.getFramebufferFormat(), fboWidth, fboHeight, false); } combine = new Combine(); crt = new CrtScreen(barrelDistortion, mode, effectsSupport); }
Example #4
Source File: ShaderTest.java From seventh with GNU General Public License v2.0 | 6 votes |
/** * */ public ShaderTest() { ShaderProgram.pedantic = false; vertBlur = loadShader("blurv.frag"); horBlur = loadShader("blurh.frag"); light = loadShader("light.frag"); shader = loadShader("inprint.frag"); this.camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); this.camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // camera.setToOrtho(false); transform = new Matrix4(); camera.update(); batch = new SpriteBatch();//1024, shader); batch.setShader(null); batch.setProjectionMatrix(camera.combined); batch.setTransformMatrix(transform); this.buffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); this.fboPing = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); this.fboPong = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); }
Example #5
Source File: GLTFBinaryExporter.java From gdx-gltf with Apache License 2.0 | 6 votes |
public void export(GLTFImage image, Texture texture, String baseName) { String fileName = baseName + ".png"; image.uri = fileName; FileHandle file = folder.child(fileName); FrameBuffer fbo = new FrameBuffer(texture.getTextureData().getFormat(), texture.getWidth(), texture.getHeight(), false); fbo.begin(); Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); SpriteBatch batch = new SpriteBatch(); batch.getProjectionMatrix().setToOrtho2D(0, 0, 1, 1); batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE); batch.begin(); batch.draw(texture, 0, 0, 1, 1, 0, 0, 1, 1); batch.end(); Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, texture.getWidth(), texture.getHeight()); fbo.end(); batch.dispose(); fbo.dispose(); savePNG(file, pixmap); pixmap.dispose(); }
Example #6
Source File: GameScreenUI.java From uracer-kotd with Apache License 2.0 | 6 votes |
public void render (FrameBuffer dest) { if (!enabled) return; ui.act(URacer.Game.getLastDeltaSecs() /* Config.Physics.Dt */); boolean hasDest = (dest != null); if (hasDest) { ui.getViewport().update(dest.getWidth(), dest.getHeight(), true); dest.begin(); } else { ui.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); } ui.draw(); if (hasDest) { dest.end(); } }
Example #7
Source File: Screenshot.java From Cubes with MIT License | 6 votes |
@Override public void frameStart() { if (!state.compareAndSet(0, 1)) return; String setting = ((DropDownSetting) Settings.getSetting(Settings.GRAPHICS_SCREENSHOT_SIZE)).getSelected(); if ("max".equals(setting)) { IntBuffer intBuffer = BufferUtils.newIntBuffer(2); Gdx.gl20.glGetIntegerv(GL20.GL_MAX_VIEWPORT_DIMS, intBuffer); screenshotWidth = Math.min(intBuffer.get(0), 16384); screenshotHeight = Math.min(intBuffer.get(1), 16384); } else { screenshotWidth = Screenshot.resolutionMap.get(setting)[0]; screenshotHeight = Screenshot.resolutionMap.get(setting)[1]; } Log.debug("Attempting to take " + setting + " (" + screenshotWidth + "x" + screenshotHeight + ") resolution screenshot"); frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, screenshotWidth, screenshotHeight, true, true); frameBuffer.begin(); oldWidth = Graphics.RENDER_WIDTH; oldHeight = Graphics.RENDER_HEIGHT; Adapter.getInterface().resize(screenshotWidth, screenshotHeight); }
Example #8
Source File: LightMap.java From box2dlights with Apache License 2.0 | 6 votes |
public LightMap(RayHandler rayHandler, int fboWidth, int fboHeight) { this.rayHandler = rayHandler; if (fboWidth <= 0) fboWidth = 1; if (fboHeight <= 0) fboHeight = 1; frameBuffer = new FrameBuffer(Format.RGBA8888, fboWidth, fboHeight, false); pingPongBuffer = new FrameBuffer(Format.RGBA8888, fboWidth, fboHeight, false); lightMapMesh = createLightMapMesh(); shadowShader = ShadowShader.createShadowShader(); diffuseShader = DiffuseShader.createShadowShader(); withoutShadowShader = WithoutShadowShader.createShadowShader(); blurShader = Gaussian.createBlurShader(fboWidth, fboHeight); }
Example #9
Source File: ScreenUtils.java From uracer-kotd with Apache License 2.0 | 5 votes |
/** Render the specified screen to the specified buffer. */ public static void copyScreen (Screen screen, FrameBuffer buffer, Color clearColor, float clearDepth, boolean useDepth) { if (screen != null) { clear(buffer, clearColor, clearDepth, useDepth); // ensures default active texture is active Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0); screen.render(buffer); } }
Example #10
Source File: RenderTransition.java From Entitas-Java with MIT License | 5 votes |
@Override public void loadResources() { int w = Gdx.graphics.getWidth(); int h = Gdx.graphics.getHeight(); nextFbo = new FrameBuffer(Pixmap.Format.RGBA8888, w, h, true); currFbo = new FrameBuffer(Pixmap.Format.RGBA8888, w, h, true); }
Example #11
Source File: CameraMotion.java From RuinsOfRevenge with MIT License | 5 votes |
@Override public void render( FrameBuffer src, FrameBuffer dest ) { if( dest != null ) { camblur.setViewport( dest.getWidth(), dest.getHeight() ); } else { camblur.setViewport( width, height ); } camblur.setInput( src ).setOutput( dest ).render(); }
Example #12
Source File: Fader.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void frameBuffersReady (Screen current, FrameBuffer from, ScreenId nextScreen, FrameBuffer to) { this.from = from; this.to = to; this.nextType = nextScreen; ScreenUtils.copyScreen(current, from); ScreenUtils.clear(to, Color.BLACK); }
Example #13
Source File: CrossFader.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void frameBuffersReady (Screen current, FrameBuffer from, ScreenId nextScreen, FrameBuffer to) { this.from = from; this.to = to; ScreenUtils.copyScreen(current, from); next = createScreen(nextScreen); ScreenUtils.copyScreen(next, to); }
Example #14
Source File: GameScreen.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void render (FrameBuffer dest) { if (!initialized) return; game.render(dest); // overlay the whole in-game UI gameui.render(dest); }
Example #15
Source File: LightShafts.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void render (FrameBuffer src, FrameBuffer dest) { Texture tsrc = src.getColorBufferTexture(); // blur.setPasses(2); // 1, render occlusion map occlusionMap.begin(); { threshold.setInput(tsrc).setOutput(occlusionMap.getSourceBuffer()).render(); blur.render(occlusionMap); } occlusionMap.end(); // threshold.setInput(tsrc).setOutput(occlusionMap.getResultBuffer()).render(); // threshold without blur Texture result = occlusionMap.getResultTexture(); // 2, render shafts occlusionMap.capture(); { shShafts.begin(); { // Gdx.gl.glClearColor(0, 0, 0, 1); // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); result.bind(0); shShafts.setUniformi("u_texture", 0); quad.render(shShafts); } shShafts.end(); // blur pass // blur.render(occlusionMap); } occlusionMap.end(); restoreViewport(dest); // 3, combine combine.setOutput(dest).setInput(tsrc, occlusionMap.getResultTexture()).render(); }
Example #16
Source File: LensFlare2.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void render (final FrameBuffer src, final FrameBuffer dest) { Texture texsrc = src.getColorBufferTexture(); boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND); pingPongBuffer.begin(); { // apply bias bias.setInput(texsrc).setOutput(pingPongBuffer.getSourceBuffer()).render(); lens.setInput(pingPongBuffer.getSourceBuffer()).setOutput(pingPongBuffer.getResultBuffer()).render(); pingPongBuffer.set(pingPongBuffer.getResultBuffer(), pingPongBuffer.getSourceBuffer()); // blur pass blur.render(pingPongBuffer); } pingPongBuffer.end(); if (blending || blendingWasEnabled) { Gdx.gl.glEnable(GL20.GL_BLEND); } if (blending) { Gdx.gl.glBlendFunc(sfactor, dfactor); } restoreViewport(dest); // mix original scene and blurred threshold, modulate via combine.setOutput(dest).setInput(texsrc, pingPongBuffer.getResultTexture()).render(); }
Example #17
Source File: Bloom.java From uracer-kotd with Apache License 2.0 | 5 votes |
@Override public void render (final FrameBuffer src, final FrameBuffer dest) { Texture texsrc = src.getColorBufferTexture(); boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND); pingPongBuffer.begin(); { // threshold / high-pass filter // only areas with pixels >= threshold are blit to smaller fbo threshold.setInput(texsrc).setOutput(pingPongBuffer.getSourceBuffer()).render(); // blur pass blur.render(pingPongBuffer); } pingPongBuffer.end(); if (blending || blendingWasEnabled) { Gdx.gl.glEnable(GL20.GL_BLEND); } if (blending) { // TODO support for Gdx.gl.glBlendFuncSeparate(sfactor, dfactor, GL20.GL_ONE, GL20.GL_ONE ); Gdx.gl.glBlendFunc(sfactor, dfactor); } restoreViewport(dest); // mix original scene and blurred threshold, modulate via // set(Base|Bloom)(Saturation|Intensity) combine.setOutput(dest).setInput(texsrc, pingPongBuffer.getResultTexture()).render(); }
Example #18
Source File: PingPongBuffer.java From uracer-kotd with Apache License 2.0 | 5 votes |
/** Creates a new ping-pong buffer with the given buffers. */ public PingPongBuffer (FrameBuffer buffer1, FrameBuffer buffer2) { ownResources = false; owned1 = null; owned2 = null; set(buffer1, buffer2); }
Example #19
Source File: ScreenUtils.java From uracer-kotd with Apache License 2.0 | 5 votes |
/** Clear the specified buffer. */ public static void clear (FrameBuffer buffer, Color clearColor, float clearDepth, boolean useDepth) { Gdx.gl20.glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); buffer.begin(); { if (useDepth) { Gdx.gl20.glClearDepthf(clearDepth); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); } else { Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); } } buffer.end(); }
Example #20
Source File: VfxFrameBuffer.java From gdx-vfx with Apache License 2.0 | 5 votes |
public void initialize(int width, int height) { if (initialized) { dispose(); } initialized = true; int boundFboHandle = getBoundFboHandle(); fbo = new FrameBuffer(pixelFormat, width, height, false); fbo.getColorBufferTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest); Gdx.gl20.glBindFramebuffer(GL20.GL_FRAMEBUFFER, boundFboHandle); OrthographicCamera cam = tmpCam; cam.setToOrtho(false, width, height); localProjection.set(cam.combined); localTransform.set(zeroTransform); }
Example #21
Source File: SlideUpAnimation.java From Radix with MIT License | 5 votes |
@Override public void init() { super.init(); fbo = new FrameBuffer(Pixmap.Format.RGBA4444, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); fboTex = fbo.getColorBufferTexture(); Gdx.gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL_BLEND); SpriteBatch batch = new SpriteBatch(); batch.setProjectionMatrix(RadixClient.getInstance().getHudCamera().combined); fbo.bind(); batch.begin(); currentScreen.render(false, batch); batch.end(); FrameBuffer.unbind(); }
Example #22
Source File: FadingGame.java From libgdx-transitions with Apache License 2.0 | 5 votes |
@Override public void resize(int width, int height) { if (screen != null) screen.resize(width, height); if (nextScreen != null) nextScreen.resize(width, height); this.currentScreenFBO.dispose(); this.nextScreenFBO.dispose(); this.currentScreenFBO = new FrameBuffer(Format.RGBA8888, width, height, false); this.nextScreenFBO = new FrameBuffer(Format.RGBA8888, width, height, false); }
Example #23
Source File: World.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public void takeScreenshot(String filename, int w) { // get viewport IntBuffer results = BufferUtils.newIntBuffer(16); Gdx.gl20.glGetIntegerv(GL20.GL_VIEWPORT, results); int h = (int) (w * getSceneCamera().viewportHeight / getSceneCamera().viewportWidth); FrameBuffer fbo = new FrameBuffer(Format.RGB565, w, h, false); fbo.begin(); Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); draw(); Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, w, h); // restore viewport fbo.end(results.get(0), results.get(1), results.get(2), results.get(3)); // Flip the pixmap upside down ByteBuffer pixels = pixmap.getPixels(); int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } pixels.clear(); pixels.put(lines); PixmapIO.writePNG(EngineAssetManager.getInstance().getUserFile(filename), pixmap); fbo.dispose(); }
Example #24
Source File: SceneList.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
private TextureRegion createBgIcon(String atlas, String region) { TextureAtlas a = new TextureAtlas( Gdx.files.absolute(Ctx.project.getAssetPath() + Project.ATLASES_PATH + "/1/" + atlas + ".atlas")); AtlasRegion r = a.findRegion(region); if (r == null) { a.dispose(); return null; } GLFrameBuffer.FrameBufferBuilder frameBufferBuilder = new GLFrameBuffer.FrameBufferBuilder(200, (int) (r.getRegionHeight() * 200f / r.getRegionWidth())); frameBufferBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); FrameBuffer fbo = frameBufferBuilder.build(); SpriteBatch fboBatch = new SpriteBatch(); fboBatch.setColor(Color.WHITE); OrthographicCamera camera = new OrthographicCamera(); camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight()); fboBatch.setProjectionMatrix(camera.combined); Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST); fbo.begin(); fboBatch.begin(); fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight()); fboBatch.end(); TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight()); // tex.flip(false, true); fbo.end(); Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); fbo.dispose(); a.dispose(); fboBatch.dispose(); return tex; }
Example #25
Source File: GdxCanvas.java From seventh with GNU General Public License v2.0 | 5 votes |
/** * */ public GdxCanvas() { this.batch = new SpriteBatch(); this.color = new Color(); this.tmpColor = new Color(); this.shaderStack = new Stack<>(); this.zoomStack = new Stack<>(); this.camera = new OrthographicCamera(getWidth(), getHeight()); this.camera.setToOrtho(true, getWidth(), getHeight()); this.camera.position.x = this.camera.viewportWidth/2; this.camera.position.y = this.camera.viewportHeight/2; this.camera.update(); this.viewport = new FitViewport(getWidth(), getHeight(), camera); this.viewport.apply(); this.generators = new HashMap<String, FreeTypeFontGenerator>(); this.fonts = new HashMap<String, BitmapFont>(); this.bounds = new GlyphLayout(); this.transform = new Matrix4(); //this.batch.setTransformMatrix(transform); //Matrix4 projection = new Matrix4(); //projection.setToOrtho( 0, getWidth(), getHeight(), 0, -1, 1); //this.batch.setProjectionMatrix(projection); // this.wHeight = getHeight(); this.batch.setProjectionMatrix(this.camera.combined); this.shapes = new ShapeRenderer(); //this.shapes.setTransformMatrix(transform); // this.shapes.setProjectionMatrix(projection); //this.shapes.setProjectionMatrix(camera.combined); this.fbo = new FrameBuffer(Format.RGBA8888, getWidth(), getHeight(), false); }
Example #26
Source File: PingPongBuffer.java From RuinsOfRevenge with MIT License | 5 votes |
/** Creates a new ping-pong buffer and owns the resources. */ public PingPongBuffer( int width, int height, Format frameBufferFormat, boolean hasDepth ) { ownResources = true; owned1 = new FrameBuffer( frameBufferFormat, width, height, hasDepth ); owned2 = new FrameBuffer( frameBufferFormat, width, height, hasDepth ); set( owned1, owned2 ); }
Example #27
Source File: PingPongBuffer.java From RuinsOfRevenge with MIT License | 5 votes |
/** Creates a new ping-pong buffer with the given buffers. */ public PingPongBuffer( FrameBuffer buffer1, FrameBuffer buffer2 ) { ownResources = false; owned1 = null; owned2 = null; set( buffer1, buffer2 ); }
Example #28
Source File: PingPongBuffer.java From RuinsOfRevenge with MIT License | 5 votes |
/** * An instance of this object can also be used to manipulate some other * externally-allocated buffers, applying just the same ping-ponging behavior. * * If this instance of the object was owning the resources, they will be preserved * and will be restored by a {@link #reset()} call. * * @param buffer1 the first buffer * @param buffer2 the second buffer */ public void set( FrameBuffer buffer1, FrameBuffer buffer2 ) { if( ownResources ) { ownedResult = bufResult; ownedSource = bufSrc; ownedW = width; ownedH = height; } this.buffer1 = buffer1; this.buffer2 = buffer2; width = this.buffer1.getWidth(); height = this.buffer1.getHeight(); rebind(); }
Example #29
Source File: PostProcessor.java From RuinsOfRevenge with MIT License | 5 votes |
/** * Stops capturing the scene and returns the result, or null if nothing was * captured. */ public FrameBuffer captureEnd() { if( enabled && capturing ) { capturing = false; hasCaptured = true; composite.end(); return composite.getResultBuffer(); } return null; }
Example #30
Source File: PostProcessor.java From RuinsOfRevenge with MIT License | 5 votes |
/** After a capture/captureEnd action, returns the just captured buffer */ public FrameBuffer captured() { if( enabled && hasCaptured ) { return composite.getResultBuffer(); } return null; }