Java 类com.badlogic.gdx.graphics.glutils.FrameBuffer 实例源码

项目:Tower-Defense-Galaxy    文件:VRCamera.java   
public VRCamera(int width, int height, int viewportWidth, int viewportHeight) {
    leftCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    rightCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    leftBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    rightBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    leftTexture = new TextureRegion();
    rightTexture = new TextureRegion();
    batch = new SpriteBatch();
    this.width = width;
    this.height = height;
    this.viewportWidth = viewportWidth;
    this.viewportHeight = viewportHeight;
    tmpVector3 = new Vector3();
    position = new Vector3(250, 20, 250);
    positionLeft = new Vector3(249.5f, 20, 250);
    positionRight = new Vector3(250.5f, 20, 250);
    direction = new Vector3();
    up = new Vector3(0, 1, 0);
    eyeDistance = 0.5f;
}
项目:odb-little-fortune-planet    文件:PlanetRenderSystem.java   
@Override
protected void initialize() {
    batch = new SpriteBatch(4000);
    new ShapeRenderer();

    planetPixel = new TextureRegion(new Texture("planetcell.png"), 1, 1);

    dirtyMask = new int[SIMULATION_WIDTH * SIMULATION_HEIGHT];

    frameBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, SIMULATION_WIDTH, SIMULATION_HEIGHT, false);
    frameBuffer.getColorBufferTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
    frameBuffer.begin();
    Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    frameBuffer.end();

    vboCamera = new OrthographicCamera(SIMULATION_WIDTH, SIMULATION_HEIGHT);
    vboCamera.setToOrtho(true, SIMULATION_WIDTH, SIMULATION_HEIGHT);
    vboCamera.update();
}
项目:gdx-gfx    文件:MultiVisualEffect.java   
@Override
public void render(Texture source, FrameBuffer destination) {

    switch (effects.size) {
    case 0:
        // No effect: make some simple copy
        if (copy == null)
            copy = new Copy();
        copy.render(source, destination);
        break;
    case 1:
        effects.first().render(source, destination);
        break;
    default:
        effects.first().render(source, buffer.getCurrentBuffer());
        for (int i = 1; i < effects.size - 1; i++)
            effects.get(i).render(buffer.getResultTexture(), buffer.getCurrentBuffer());
        effects.peek().render(buffer.getResultTexture(), destination);
        break;
    }
}
项目:gdx-gfx    文件:Outline.java   
@Override
public void render(Texture source, FrameBuffer destination) {

    // Draw outlined to buffer
    buffer.getCurrentTexture().bind(0);
    buffer.begin();

    Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    renderOutlined();

    buffer.end();

    filter.render(buffer.getResultTexture(), buffer.getCurrentBuffer());

    // mix original scene and outlines
    superimpose.setAdditionalInput(buffer.getResultTexture());
    superimpose.render(source, destination);
}
项目:jrpg-engine    文件:LightingEffect.java   
@Override
public void init(final GraphicsService graphicsService, final GameMap map) {
    lightingShader.begin();
    lightingShader.setUniformf(
            "resolution",
            Gdx.graphics.getWidth(),
            Gdx.graphics.getHeight()
    );
    lightingShader.setUniformi("u_lightmap", 1);
    lightingShader.setUniformf("ambientColor", ambientColor.x, ambientColor.y, ambientColor.z, ambientIntensity);
    lightingShader.end();
    frameBuffer = new FrameBuffer(
            Pixmap.Format.RGBA8888,
            graphicsService.getResolutionWidth(),
            graphicsService.getResolutionHeight(),
            false
    );
}
项目:Escapy    文件:AbsStdLight.java   
public AbsStdLight setLightSource(EscapyLightType light) {

        this.updState();
        this.lightSource = light;
        this.interCam = new EscapyGdxCamera((int) this.lightSource.getWidth(), (int) this.lightSource.getHeight());
        this.fbo = new StandartFBO(id, (int) this.lightSource.getWidth(), (int) this.lightSource.getHeight(), "<AbsLightTexture_FBUFFER>");
        FrameBuffer tmpBuff = new FrameBuffer(Pixmap.Format.RGBA8888, (int) this.lightSource.getWidth(),(int) this.lightSource.getHeight(), false);
        tmpBuff.begin();
        Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        tmpBuff.end();
        FrameBuffer bgBuff = new FrameBuffer(Pixmap.Format.RGBA8888, (int) this.lightSource.getWidth(),(int) this.lightSource.getHeight(), false);
        bgBuff.begin();
        Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        bgBuff.end();

        this.lightSprite = new Sprite(tmpBuff.getColorBufferTexture());
        this.bgSprite = new Sprite(bgBuff.getColorBufferTexture());

        System.out.println(lightSource.setName(Integer.toString(getID())));
        return this;
    }
项目:rbcgj-2016    文件:LightMap.java   
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);

}
项目:nhglib    文件:LightProbe.java   
private Texture renderBRDF() {
    ShaderProgram brdfShader = new ShaderProgram(
            Gdx.files.internal("shaders/brdf_shader.vert"),
            Gdx.files.internal("shaders/brdf_shader.frag"));

    FrameBuffer frameBuffer = FrameBuffer.createFrameBuffer(Pixmap.Format.RGB888, (int) brdfWidth, (int) brdfHeight, true);

    brdfShader.begin();
    frameBuffer.begin();
    Gdx.gl.glViewport(0, 0, (int) brdfWidth, (int) brdfHeight);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    quadMesh.render(brdfShader, GL20.GL_TRIANGLES);
    frameBuffer.end();
    brdfShader.end();
    brdfShader.dispose();

    return frameBuffer.getColorBufferTexture();
}
项目:exterminate    文件:CrtMonitor.java   
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, 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);
}
项目:fabulae    文件:LightMap.java   
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);

}
项目:RavTech    文件:PostProcessingEffect.java   
public FrameBuffer applyPasses (SpriteBatch batch, FrameBuffer inputBuffer, FrameBuffer outputBuffer) {
    batch.begin();
    batch.setProjectionMatrix(matrix);
    FrameBuffer iBuffer = inputBuffer;
    FrameBuffer oBuffer = outputBuffer;
    for (int i = 0; i < passes.size; i++) {
        oBuffer.begin();
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.setShader(RavTech.sceneHandler.shaderManager.get(passes.get(i)));
        batch.draw(iBuffer.getColorBufferTexture(), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        batch.setShader(RavTech.sceneHandler.shaderManager.get("default"));
        oBuffer.end();
        FrameBuffer tempBuffer = oBuffer;
        oBuffer = iBuffer;
        iBuffer = tempBuffer;
    }
    batch.end();
    return oBuffer;
}
项目:RavTech    文件:ShaderManager.java   
public ShaderManager (String shaderDir, AssetManager am, boolean addProcessors) {
    shaders = new ObjectMap<String, ShaderProgram>();
    shaderPaths = new ObjectMap<String, String>();
    sourcesVert = new ObjectMap<String, String>();
    sourcesFrag = new ObjectMap<String, String>();
    frameBuffers = new ObjectMap<String, FrameBuffer>();
    openedFrameBuffers = new Array<String>(true, MAX_FRAMEBUFFERS);
    screenCamera = new OrthographicCamera(Gdx.graphics.getWidth() + 2, Gdx.graphics.getHeight() + 2);
    createScreenQuad();
    screenCamera.translate(0, -1);
    screenCamera.update();
    setShaderDir(shaderDir);
    setAssetManager(am);
    // add("empty", "empty.vert", "empty.frag");
    // add("default", "default.vert", "default.frag");
    if (addProcessors && (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet
        || Gdx.app.getType() == ApplicationType.WebGL)) {
        /*
         * add("processor", "processor.vert", "processor.frag"); add("processor_blur", "processor.vert", "processor_blur.frag");
         * add("copy", "processor.vert", "copy.frag"); add("processor_draw", "processor.vert", "processor_draw.frag");
         * add("processor_fill", "processor.vert", "processor_fill.frag");
         */
    }
}
项目:RavTech    文件:ShaderManager.java   
/** Resizes internal RavCamera for framebuffer use, call this in you ApplicationListener's resize.
 * 
 * @param width - new screen width
 * @param height - new screen height
 * @param resizeFramebuffers - whether all of the framebuffers should be recreated to match new screen size */
public void resize (int width, int height, boolean resizeFramebuffers) {
    // ?????
    if (resizeFramebuffers) {
        Keys<String> keys = frameBuffers.keys();
        while (keys.hasNext) {
            String key = keys.next();
            FrameBuffer fb = frameBuffers.get(key);
            int oldWidth = fb.getWidth();
            int oldHeight = fb.getHeight();
            Format format = fb.getColorBufferTexture().getTextureData().getFormat();
            fb.dispose();
            frameBuffers.put(key, null);
            float factorX = 1f * width / screenCamera.viewportWidth;
            float factorY = 1f * height / screenCamera.viewportHeight;
            createFB(key, format, (int)(factorX * oldWidth), (int)(factorY * oldHeight));
            // System.out.println("Recreated FB '" + key + "' from " +
            // oldWidth + "x" + oldHeight + " to " +
            // frameBuffers.get(key).getWidth() + "x" +
            // frameBuffers.get(key).getHeight());
        }
    }
    screenCamera = new OrthographicCamera(width, height);
    createScreenQuad();
}
项目:braingdx    文件:CrtMonitor.java   
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);
}
项目:braingdx    文件:CombinedRenderPipe.java   
public void render(Batch batch, float delta, FrameBuffer buffer) {
   if (isEnabled()) {
      if (shaderManager.hasEffects()) {
         shaderManager.begin();
         this.batch.setProjectionMatrix(camera.combined);
         this.batch.begin();
         this.batch.draw(buffer.getColorBufferTexture(), 0f, 0f);
         this.batch.end();
         layer.render(batch, delta);
         shaderManager.end(buffer);
      } else {
         buffer.begin();
         layer.render(batch, delta);
         buffer.end();
      }
   }
}
项目:braingdx    文件:MockedCombinedRenderPipelineFactory.java   
@Override
 public RenderPipeline create() {
    ShaderConfig config = mock(ShaderConfig.class);
    PostProcessor processorMock = mock(PostProcessor.class);
    FrameBufferFactory factory = mock(FrameBufferFactory.class);
    FrameBuffer buffer = mock(FrameBuffer.class);
    Texture mockTexture = mock(Texture.class);
    ViewportFactory viewportFactory = mock(ViewportFactory.class);
    Viewport viewport = mock(Viewport.class);
    when(factory.create(Mockito.anyInt(), Mockito.anyInt())).thenReturn(buffer);
    Mockito.doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
    return null;
}         
    }).when(viewport).update(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyBoolean());
    when(viewportFactory.create(Mockito.anyInt(), Mockito.anyInt())).thenReturn(viewport);
    when(buffer.getColorBufferTexture()).thenReturn(mockTexture);
    return new CombinedRenderPipeline(config, processorMock, factory, mock(SpriteBatch.class),
          mock(OrthographicCamera.class), viewportFactory);
 }
项目:swampmachine    文件:OrthogonalTiledMapRendererWithObjects.java   
public OrthogonalTiledMapRendererWithObjects(TiledMap map) {
    super(map);


    this.occlusionFbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, false);
    this.shadowmapFbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth() / 2, 1, false);

    this.shadowmapTex = shadowmapFbo.getColorBufferTexture();
    this.shadowmapTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    this.shadowmapTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);

    //this.orthoCam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    //this.orthoCam.setToOrtho(Y_DOWN);

    this.lights = new ArrayList<Light>();
    this.mouseLight = new Light(0, 0, Color.WHITE);
}
项目:LWPTools    文件:GaussianBlur.java   
private static FrameBuffer getLinearFrameBuffer(int width, int height, boolean hasDepth){

        if (try8888) {
            try {
                FrameBuffer frameBuffer = new FrameBuffer(
                        Pixmap.Format.RGBA8888, width, height, hasDepth);
                return frameBuffer;
            } catch (IllegalStateException e) {
                try8888 = false;
                Gdx.app.log("GaussianBlur.getLinearFrameBuffer",
                        "Could not create RGBA8888 FrameBuffer. Switching to RGB565.");
            }
        }

        return new FrameBuffer(
                Pixmap.Format.RGB565, width, height, hasDepth);
    }
项目:LWPTools    文件:GaussianBlur.java   
private void doBlurPass(FrameBuffer fboInput, boolean vertical) {
    GL20 gl = Gdx.gl20;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    spriteBatch.setShader(blurPassShaderProgram);
    gl.glDisable(GL20.GL_BLEND);
    spriteBatch.begin();
    if (useInverseTarget) {
        blurPassShaderProgram.setUniformf("u_size",
                vertical ? horizontalOnePixelSize : verticalOnePixelSize,
                0);
    } else {
        blurPassShaderProgram.setUniformf("u_size",
                vertical ? 0 : horizontalOnePixelSize,
                vertical ? verticalOnePixelSize : 0);
    }
    blurPassShaderProgram.setUniform4fv("u_offsets", offsets, 0, 4);
    blurPassShaderProgram.setUniformf("u_weightAtCenter", weightAtCenter);
    blurPassShaderProgram.setUniform4fv("u_weights", weights, 0, 4);

    spriteBatch.draw(fboInput.getColorBufferTexture(), -1, -1, 2, 2);
    spriteBatch.end();
    spriteBatch.setShader(null);
}
项目:libgdxcn    文件:AndroidGraphics.java   
@Override
public void onSurfaceCreated (javax.microedition.khronos.opengles.GL10 gl, EGLConfig config) {
    eglContext = ((EGL10)EGLContext.getEGL()).eglGetCurrentContext();
    setupGL(gl);
    logConfig(config);
    updatePpi();

    Mesh.invalidateAllMeshes(app);
    Texture.invalidateAllTextures(app);
    Cubemap.invalidateAllCubemaps(app);
    ShaderProgram.invalidateAllShaderPrograms(app);
    FrameBuffer.invalidateAllFrameBuffers(app);

    logManagedCachesStatus();

    Display display = app.getWindowManager().getDefaultDisplay();
    this.width = display.getWidth();
    this.height = display.getHeight();
    this.mean = new WindowedMean(5);
    this.lastFrameTime = System.nanoTime();

    gl.glViewport(0, 0, this.width, this.height);
}
项目:libgdxcn    文件:FrameBufferTest.java   
@Override
public void create () {
    mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(Usage.ColorPacked, 4,
        "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
    float c1 = Color.toFloatBits(255, 0, 0, 255);
    float c2 = Color.toFloatBits(255, 0, 0, 255);
    float c3 = Color.toFloatBits(0, 0, 255, 255);

    mesh.setVertices(new float[] {-0.5f, -0.5f, 0, c1, 0, 0, 0.5f, -0.5f, 0, c2, 1, 0, 0, 0.5f, 0, c3, 0.5f, 1});

    stencilMesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(
        Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
    stencilMesh.setVertices(new float[] {-0.5f, 0.5f, 0, c1, 0, 0, 0.5f, 0.5f, 0, c2, 1, 0, 0, -0.5f, 0, c3, 0.5f, 1});

    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));

    spriteBatch = new SpriteBatch();
    frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, false);
    stencilFrameBuffer = new FrameBuffer(Format.RGB565, 128, 128, false, true);
    createShader(Gdx.graphics);
}
项目:libgdx-maps    文件:MapManager.java   
public MapManager(AbstractTileInfo info, TileListener listener, ByteCache cache, float width, float height, float mapX, float mapY) {
      this.info = info;
      this.listener = listener;
      this.cache = cache;

this.width = width;
this.height = height;
this.mapX = mapX;
this.mapY = mapY;

tiledMap = new TiledMap();
renderer = new OrthogonalTiledMapRenderer(tiledMap, 1f);
buffer = new FrameBuffer(Pixmap.Format.RGB888, (int)width, (int)height, false);
camera = new OrthographicCamera(width, height);
camera.position.set(width*0.5f, height*0.5f, 0);

mapRegion = new TextureRegion();

// Initialize map
updateTiles();
  }
项目:box2dlights    文件:LightMap.java   
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);

}
项目:gaiasky    文件:SGRFov.java   
@Override
public void render(SceneGraphRenderer sgr, ICamera camera, double t, int rw, int rh, FrameBuffer fb, PostProcessBean ppb) {
    boolean postproc = postprocessCapture(ppb, fb, rw, rh);

    /** FIELD OF VIEW CAMERA - we only render the star group process **/

    FovCamera cam = ((CameraManager) camera).fovCamera;
    int fovmode = camera.getMode().getGaiaFovMode();
    if (fovmode == 1 || fovmode == 3) {
        cam.dirindex = 0;
        sgr.renderSystem(camera, t, rc, StarGroupRenderSystem.class);
    }

    if (fovmode == 2 || fovmode == 3) {
        cam.dirindex = 1;
        sgr.renderSystem(camera, t, rc, StarGroupRenderSystem.class);
    }

    postprocessRender(ppb, fb, postproc, camera, rw, rh);

}
项目:gaiasky    文件:SGRStereoscopic.java   
public SGRStereoscopic() {
    super();
    // INIT VIEWPORT
    stretchViewport = new StretchViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    // INIT FRAME BUFFER FOR 3D MODE
    fb3D = new HashMap<Integer, FrameBuffer>();
    fb3D.put(getKey(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight()), new FrameBuffer(Format.RGB888, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight(), true));

    // Init anaglyphic effect
    anaglyphic = new Anaglyphic();

    // Aux vectors
    aux1 = new Vector3();
    aux2 = new Vector3();
    aux3 = new Vector3();
    aux1d = new Vector3d();
    aux2d = new Vector3d();
    aux3d = new Vector3d();
    aux4d = new Vector3d();
    aux5d = new Vector3d();

    EventManager.instance.subscribe(this, Events.FRAME_SIZE_UDPATE, Events.SCREENSHOT_SIZE_UDPATE);
}
项目:BotLogic    文件:GameLevelScreen.java   
public void renderDecalsForBufferAndBatch(FrameBuffer buffer, DecalBatch batch) {
  buffer.begin();
    renderContext.begin();
    renderContext.end();
    renderContext.begin();

      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glViewport(0, 0, buffer.getWidth(), buffer.getHeight());
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT  | GL20.GL_DEPTH_BUFFER_BIT);

      for (Entity entity : entities) {
        if (EntityDecalRenderable.class.isInstance(entity)) {
          EntityDecalRenderable en = (EntityDecalRenderable)entity;
          en.renderBatch(batch, environment);
        }
      }

      batch.flush();
    renderContext.end();
  buffer.end();
}
项目:BotLogic    文件:GameLevelScreen.java   
@Override
public void resize(int width, int height) {
  perspectiveCamera.viewportWidth = width;
  perspectiveCamera.viewportHeight = height;
  perspectiveCamera.update(true);

  if (this.colorBuffer != null) {
    this.colorBuffer.dispose();
  }

  if (this.depthBuffer != null) {
    this.depthBuffer.dispose();
  }

  if (this.decalBuffer != null) {
    this.decalBuffer.dispose();
  }

  this.colorBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
  this.depthBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
  this.decalBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
  cellShadingCompositor.resize(width, height);
}
项目:seventh    文件:ShaderTest.java   
/**
     * 
     */
    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);
    }
项目:Stray-core    文件:PostProcessing.java   
/**
 * gaussian blur on the entire screen
 * 
 * @param batch
 * @param buffer
 * @param blurshader
 * @param radius
 *            amount in pixels to blur
 */
public static void twoPassBlur(Batch batch, FrameBuffer buffer, ShaderProgram blurshader,
        float radius, float x, float y, float drawWidth, float drawHeight, int u, int v,
        int width, int height) {
    buffer.begin();
    batch.setShader(blurshader);
    blurshader.setUniformf("radius", (float) radius);
    blurshader.setUniformf("dir", 1f, 0f);
    batch.draw(buffer.getColorBufferTexture(), x, y, drawWidth, drawHeight, u, v, width,
            height, false, true);
    batch.flush();
    buffer.end();

    buffer.begin();
    blurshader.setUniformf("dir", 0f, 1f);
    batch.draw(buffer.getColorBufferTexture(), x, y, drawWidth, drawHeight, u, v, width,
            height, false, true);
    batch.setShader(null);
    buffer.end();

    batch.draw(buffer.getColorBufferTexture(), 0, Gdx.graphics.getHeight(), buffer.getWidth(),
            -buffer.getHeight());
    batch.flush();
}
项目:craft    文件:SimpleShaderManager.java   
private void drawTo(FrameBuffer buffer, float delta, Batch batch, Shader<?> shader, ShadeArea area) {

    // Apply the current shader
    if (shader != null) {
      batch.setShader(shader.getProgram());
    } else {
      batch.setShader(null);
    }

    batch.begin();
    if (shader != null) // Update shader
      shader.update(delta);
    if (buffer != null) // Draw buffer
      batch.draw(buffer.getColorBufferTexture(), 0f, 0f);
    if (area != null) // Draw area
      area.draw(batch, delta);
    batch.end();

    // Send the data directly through the graphics pipeline
    batch.flush();

    // Reset the current shader
    batch.setShader(null);
  }
项目:craft    文件:UIRenderer.java   
public UIRenderer(int width, int height, Viewport viewport, Batch batch) {
  SharedInjector.get().injectMembers(this);
  this.batch = batch;
  blurHandler = new GaussianBlur(this);
  buffer = new FrameBuffer(Format.RGBA8888, width, height, false);
  baseStage = new InputEventProcessor(viewport, batch);
  overlayStage = new InputEventProcessor(viewport, batch);
  cliStage = new InputEventProcessor(viewport, batch);
  baseStage.getViewport().setCamera(camera);
  overlayStage.getViewport().setCamera(camera);
  cliStage.getViewport().setCamera(camera);
  cliStage.addActor(cli);
  eventBus.subscribe(baseStage);
  eventBus.subscribe(overlayStage);
  eventBus.subscribe(this);
  overlay = new Sprite(GraphicsFactory.createTexture(16, 16, Color.BLACK));
  overlay.setAlpha(0f);
}
项目:c2d-engine    文件:WaterTest.java   
public Water(TextureRegion particleTexture, int segment, float height, Color topColor, Color endColor) {
    this.particleTexture = particleTexture;
    columns = new WaterColumn[segment];

    for (int i = 0; i < columns.length; i++) {
        columns[i] = new WaterColumn();
        columns[i].Height = height;
        columns[i].TargetHeight = height;
        columns[i].Speed = 0;

    }
    scale = Engine.getWidth() / (columns.length - 1);
    this.color1 = endColor;
    this.color2 = topColor;

    fbo = new FrameBuffer(Pixmap.Format.RGBA8888, (int) Engine.getWidth(), (int) Engine.getHeight(), false);
}
项目:ead    文件:CreateSceneThumbnail.java   
private FrameBuffer drawActor(Actor actor) {
    root.addActor(actor);

    int width = (int) (Gdx.graphics.getHeight() - Gdx.graphics.getDensity() * 56);
    int height = (int) (Gdx.graphics.getHeight() / 2.15f);

    FrameBuffer frameBuffer = new FrameBuffer(Format.RGB888, width, height,
            false);
    frameBuffer.begin();

    Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    root.draw(batch, 1.0f);
    batch.end();
    frameBuffer.end();
    batch.setColor(Color.WHITE);
    return frameBuffer;
}
项目:RuinsOfRevenge    文件:CrtMonitor.java   
public CrtMonitor( boolean barrelDistortion, boolean performBlur ) {
    // the effect is designed to work on the whole screen area, no small/mid size tricks!
    int w = Gdx.graphics.getWidth();
    int h = Gdx.graphics.getHeight();
    doblur = performBlur;

    if( doblur ) {
        pingPongBuffer = PostProcessor.newPingPongBuffer( w, h, PostProcessor.getFramebufferFormat(), false );
        blur = new Blur( w, h );
        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(), w, h, false );
    }

    combine = new Combine();
    combine.setSource1Intensity( barrelDistortion ? 0f : 0.15f );
    combine.setSource2Intensity( barrelDistortion ? 1.2f : 1.1f );
    combine.setSource1Saturation( 1f );
    combine.setSource2Saturation( 0.8f );

    crt = new CrtScreen( barrelDistortion );
}
项目:it.alcacoop.fourinaline    文件:Checker.java   
public Checker() {
  super();
  r1 = FourInALine.Instance.atlas.findRegion("CSW");
  r2 = FourInALine.Instance.atlas.findRegion("CSB");

  shader = new ShaderProgram(Gdx.files.internal("shaders/vertex.s"), Gdx.files.internal("shaders/fragment2.s"));
  System.out.println(shader.isCompiled());
  System.out.println(shader.getLog());
  wood = FourInALine.Instance.wood;
  rnd = new Random();

  fbo = new FrameBuffer(Format.RGBA4444, r1.getRegionWidth(), r1.getRegionHeight(), true);
  sb = new SpriteBatch();
  Matrix4 matrix = new Matrix4();
  matrix.setToOrtho2D(0, 0, r1.getRegionWidth(), r1.getRegionHeight());
  sb.setProjectionMatrix(matrix);
  setColor(1);
}
项目:ingress-indonesia-dev    文件:AndroidGraphics.java   
public final void onSurfaceCreated(javax.microedition.khronos.opengles.GL10 paramGL10, EGLConfig paramEGLConfig)
{
  this.eglContext = ((EGL10)EGLContext.getEGL()).eglGetCurrentContext();
  setupGL(paramGL10);
  logConfig(paramEGLConfig);
  updatePpi();
  if (!this.isContextPreserved)
  {
    Mesh.invalidateAllMeshes(this.app);
    Texture.invalidateAllTextures(this.app);
    ShaderProgram.invalidateAllShaderPrograms(this.app);
    FrameBuffer.invalidateAllFrameBuffers(this.app);
    SpriteBatch.invalidateAllSpriteBatches(this.app);
  }
  Gdx.app.log("AndroidGraphics", Mesh.getManagedStatus());
  Gdx.app.log("AndroidGraphics", Texture.getManagedStatus());
  Gdx.app.log("AndroidGraphics", ShaderProgram.getManagedStatus());
  Gdx.app.log("AndroidGraphics", FrameBuffer.getManagedStatus());
  Display localDisplay = this.app.getWindowManager().getDefaultDisplay();
  this.width = localDisplay.getWidth();
  this.height = localDisplay.getHeight();
  this.mean = new WindowedMean(5);
  this.lastFrameTime = System.nanoTime();
  paramGL10.glViewport(0, 0, this.width, this.height);
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
private void setupEye(Eye eye, int width, int height, boolean hasStencil) {
    FrameBuffer buffer = new FrameBuffer(Format.RGBA8888, width, height, true, hasStencil);
    TextureRegion region = new TextureRegion(buffer.getColorBufferTexture());
    region.flip(false, true);
    VRCamera camera = new VRCamera(this, eye);
    camera.near = 0.1f;
    camera.far = 1000f;
    perEyeData[eye.index] = new VRPerEyeData(buffer, region, camera);
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
VRPerEyeData(FrameBuffer buffer, TextureRegion region, VRCamera cameras) {
    this.buffer = buffer;
    this.region = region;
    this.camera = cameras;
    this.texture = org.lwjgl.openvr.Texture.create();
    this.texture.set(buffer.getColorBufferTexture().getTextureObjectHandle(), VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma);
}
项目:arcadelegends-gg    文件:PlayerHelper.java   
/**
 * Draws the given gradient {@link Texture} to the given {@link FrameBuffer}, using the given {@link Color} with the given percent.
 * <p>
 * This is achieved via a gradient shader.
 *
 * @param buffer     the {@link FrameBuffer} to be drawn to
 * @param color      the {@link Color} which should be drawn
 * @param gradient   the gradient texture which should be drawn
 * @param perc       the percent the gradient texture should be drawn
 * @param projection projection matrix for pixel perfect rendering
 */
private void drawToBuffer(FrameBuffer buffer, Color color, TextureRegion gradient, float perc, Matrix4 projection) {
    buffer.begin();
    AL.graphics.getGL20().glClearColor(0, 0, 0, 0);
    AL.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);

    shaderBatch.setProjectionMatrix(projection);
    shaderBatch.begin();
    shaderBatch.setColor(color);
    shader.setUniformf("u_gradient", perc);
    shaderBatch.draw(gradient, -buffer.getWidth() / 2, -buffer.getHeight() / 2);
    shaderBatch.end();
    buffer.end();
}
项目:arcadelegends-gg    文件:PlayerHelper.java   
@Override
public void dispose() {
    for (FrameBuffer buffer : abilityBuffers) {
        buffer.dispose();
    }
    healthBuffer.dispose();
    xpBuffer.dispose();
    resourceBuffer.dispose();
    shaderBatch.dispose();
    shader.dispose();
    for (Sprite s : abilityOverlaySprites)
        s.getTexture().dispose();
}