I implemented a basic lighting system (from this answer) to my game and now some of my textures won't render. Here's my main render method:

@Override
public void render(float delta) {

    update(delta);

    frameBuffer.begin();

    Gdx.gl.glClearColor(CLEAR, CLEAR, CLEAR, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camera.combined);
    batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE);
    batch.begin();

    // render lights
    currentMap.lightsController.render(batch);

    batch.end();

    frameBuffer.end();

    batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    batch.begin();

    // render map and its entities (including player)
    currentMap.render(camera, batch);

    batch.end();

    batch.setProjectionMatrix(batch.getProjectionMatrix().idt());
    batch.setBlendFunction(GL20.GL_ZERO, GL20.GL_SRC_COLOR);
    batch.begin();
    batch.draw(frameBuffer.getColorBufferTexture(), -1, 1, 2, -2);
    batch.end();

}

When I run the game, the light is rendered and the TiledMap from the currentMap object is rendered, however my other entities such as the player and buildings are not. The currentMap.render() method is this:

tiledMapRenderer.setView(camera);
    tiledMapRenderer.render();

    for(Entity e : entities) {
        e.render(batch);
    }

    // render player LAST
    player.render(batch);

I'm guessing it is something to do with the SpriteBatch being set up incorrectly as the player and entities use the batch and don't render while the TiledMap doesn't use it and does render.

To try and figure it out I created a basic Sprite and rendered it by calling batch.draw(sprite, 0, 0); just before my currentMap.render() line, but that is just rendered as a white rectangle.

What would be causing this?

0 Answers