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

项目:Argent    文件:PointLightWrapper.java   
@Override
public GLFrameBuffer draw(List<ModelInstance> renderables) {
    applyToShader(shaderProgram);
    if(fbo == null) buildFBO();
    fbo.begin();
    while(((FrameBufferCubemap)fbo).nextSide()) {
        camera().direction.set(
                ((FrameBufferCubemap) fbo)
                        .getSide()
                        .direction);
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        batch.begin(camera());
        batch.render(renderables);
        batch.end();
        if (Gdx.input.isKeyJustPressed(Input.Keys.F3))
            ScreenshotFactory.saveScreenshot(DEPTHMAPSIZE, DEPTHMAPSIZE, "PointLight");
    }
    fbo.end();
    return fbo;
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
/**
 * Renders the content of the given eye's rendering surface
 * to the entirety of the companion window.
 */
public void renderToCompanionWindow(Eye eye) {      
    GLFrameBuffer<Texture> buffer = perEyeData[eye.index].buffer;
    TextureRegion region = perEyeData[eye.index].region;        
    batcher.getProjectionMatrix().setToOrtho2D(0, 0, buffer.getWidth(), buffer.getHeight());
    batcher.begin();
    batcher.draw(region, 0, 0);
    batcher.end();
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
public void setFrameBuffer(GLFrameBuffer<Texture> fbo, boolean disposeOld) {
    if (disposeOld) {
        this.buffer.dispose();
    }
    this.buffer = fbo;
    this.region.setTexture(fbo.getColorBufferTexture());
    this.texture.set(buffer.getColorBufferTexture().getTextureObjectHandle(), VR.ETextureType_TextureType_OpenGL, VR.EColorSpace_ColorSpace_Gamma);
}
项目:nhglib    文件:LightProbe.java   
private Cubemap renderEnvironmentFromHDRData(HDRData2 data) {
    Texture equirectangularTexture;
    ShaderProgram equiToCubeShader = new ShaderProgram(
            Gdx.files.internal("shaders/equi_to_cube_shader.vert"),
            Gdx.files.internal("shaders/equi_to_cube_shader.frag"));

    equirectangularTexture = data.getTexture();

    GLFrameBuffer.FrameBufferCubemapBuilder builder = new GLFrameBuffer.FrameBufferCubemapBuilder(
            (int) environmentWidth, (int) environmentHeight);
    builder.addColorTextureAttachment(GL30.GL_RGB8, GL30.GL_RGB, GL30.GL_UNSIGNED_BYTE);
    builder.addDepthRenderBufferAttachment();
    FrameBufferCubemap frameBufferCubemap = builder.build();

    equirectangularTexture.bind(0);
    equiToCubeShader.begin();
    equiToCubeShader.setUniformMatrix("u_projection", perspectiveCameras.first().projection);
    equiToCubeShader.setUniformi("u_equirectangularMap", 0);
    frameBufferCubemap.begin();
    for (int i = 0; i < 6; i++) {
        equiToCubeShader.setUniformMatrix("u_view", perspectiveCameras.get(i).view);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        cubeMesh.render(equiToCubeShader, GL20.GL_TRIANGLES);
        frameBufferCubemap.nextSide();
    }
    frameBufferCubemap.end();
    equiToCubeShader.end();
    equiToCubeShader.dispose();

    return frameBufferCubemap.getColorBufferTexture();
}
项目:Argent    文件:LightWrapper.java   
public GLFrameBuffer draw(List<ModelInstance> renderables) {
    applyToShader(shaderProgram);
    if(fbo == null) buildFBO();
    fbo.begin();
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    batch.begin(camera());
    batch.render(renderables);
    batch.end();
    if(Gdx.input.isKeyJustPressed(Input.Keys.F3))
        ScreenshotFactory.saveScreenshot(DEPTHMAPSIZE, DEPTHMAPSIZE, light.getClass().getSimpleName());
    fbo.end();
    return fbo;
}
项目:gaiasky    文件:GaiaSky.java   
@Override
public void run() {
    // FPS
    EventManager.instance.post(Events.FPS_INFO, 1f / Gdx.graphics.getDeltaTime());
    // Current session time
    EventManager.instance.post(Events.DEBUG1, TimeUtils.timeSinceMillis(startTime) / 1000d);
    // Memory
    EventManager.instance.post(Events.DEBUG2, MemInfo.getUsedMemory(), MemInfo.getFreeMemory(), MemInfo.getTotalMemory(), MemInfo.getMaxMemory());
    // Observed octants
    EventManager.instance.post(Events.DEBUG4, GLFrameBuffer.getManagedStatus() + ", Observed octants: " + OctreeNode.nOctantsObserved + ", Load queue: " + StreamingOctreeLoader.getLoadQueueSize());
}
项目:bladecoder-adventure-engine    文件:SceneList.java   
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;
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
/**
 * Resizes the companion window so the rendering buffers
 * can be displayed without stretching.
 */
public void resizeCompanionWindow() {
    GLFrameBuffer<Texture> buffer = perEyeData[0].buffer;
    Gdx.graphics.setWindowedMode(buffer.getWidth(), buffer.getHeight());
}
项目:Tower-Defense-Galaxy    文件:VRContext.java   
public GLFrameBuffer<Texture> getFrameBuffer() {
    return buffer;
}
项目:Argent    文件:CompositeFrameBuffer.java   
/** See {@link GLFrameBuffer#unbind()} */
public static void unbind () {
    GLFrameBuffer.unbind();
}
项目:bladecoder-adventure-engine    文件:Sprite3DRenderer.java   
@Override
public void retrieveAssets() {
    // create STATIC BATCHS if not created yet
    if (modelBatch == null)
        createBatchs();

    createEnvirontment();

    for (String key : sourceCache.keySet()) {
        if (sourceCache.get(key).refCounter > 0)
            retrieveSource(key);
    }

    if (currentAnimation != null) { // RESTORE FA
        ModelCacheEntry entry = (ModelCacheEntry)sourceCache.get(currentAnimation.source);
        currentSource = entry;

        float speed = currentAnimation.duration;

        if (currentAnimationType == Tween.Type.REVERSE || currentAnimationType == Tween.Type.REVERSE_REPEAT)
            speed *= -1;

        ((ModelCacheEntry)currentSource).controller.setAnimation(currentAnimation.id, currentCount, speed, animationListener);

        update(lastAnimationTime);

    } else if (initAnimation != null) {
        startAnimation(initAnimation, Tween.Type.SPRITE_DEFINED, 1, null);

        if (currentAnimation != null)
            lookat(modelRotation);
    }

    if (currentSource != null && renderShadow)
        genShadowMap();

    if (USE_FBO) {
        GLFrameBuffer.FrameBufferBuilder frameBufferBuilder = new GLFrameBuffer.FrameBufferBuilder(
                width, height);

        frameBufferBuilder.addColorTextureAttachment( GL30.GL_RGBA8,  GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE);
        fb = frameBufferBuilder.build();

        tex = new TextureRegion(fb.getColorBufferTexture());
        tex.flip(false, true);

        renderTex();
    }

    computeBbox();
}