Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (528)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Strange bug with LibGDX TiledMapRenderer LWJGL backend  (Read 333 times)
0 Members and 1 Guest are viewing this topic.
Offline unknownloner

Junior Newbie


Exp: 2 years



« Posted 2014-02-06 05:40:56 »

So in this video (about 8-10 seconds in), you'll be able to see black lines that appear between rows of tiles for a split second. These definitely should not be there.

<a href="http://www.youtube.com/v/Fg3_Bd9AxKg?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Fg3_Bd9AxKg?version=3&amp;hl=en_US&amp;start=</a>

My rendering code is fairly simple. Here is my world renderer
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
public class WorldRenderer {
   
    private World world;
    private TiledMap map;
    private TiledMapTileLayer layer;
    private OrthogonalTiledMapRenderer renderer;
   
    public WorldRenderer(World world) {
        this.world = world;
        map = new TiledMap();
        layer = new TiledMapTileLayer(world.width, world.height, 16, 16);
        map.getLayers().add(layer);
        renderer = new OrthogonalTiledMapRenderer(map, 2F);
    }
   
    public void dispose() {
        map.dispose();
    }
   
    public void render(float x, float y, float width, float height) {
        for(int i = 0; i < world.dirtyChunks.length; i++) {
            updateChunk(i);
        }
       
        OrthographicCamera cam = Game.instance.screenCam;
        renderer.setView(cam);
        renderer.render();
    }
   
    private void updateChunk(int chunk) {
        if(!world.dirtyChunks[chunk]) {
            return;
        }
        world.dirtyChunks[chunk] = false;
        int x = world.getChunkStartX(chunk);
        int y = world.getChunkStartY(chunk);
       
        for(int iy = 0; iy < 16; iy++) {
            for(int ix = 0; ix < 16; ix++) {
                int tx = ix + x;
                int ty = iy + y;
                int tileID = world.tiles[tx + ty * world.width] & 0xFF;
               
                Cell cell = layer.getCell(tx, ty);
                if(cell == null) {
                    cell = new Cell();
                    layer.setCell(tx, ty, cell);
                }
                cell.setTile(Tile.TYPES[tileID].getMapTile());
            }
        }
    }

}


and here is the code that calls it in the main render method of the program
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
    public void render() {
        //Input code goes here, just adjusts camX/camY

        float width = Gdx.graphics.getWidth();
        float height = Gdx.graphics.getHeight();
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        screenCam.setToOrtho(false, width, height);
        screenCam.translate(camX, camY);
        screenCam.update();
        worldRenderer.render(0, 0, width, height);
    }


I don't run into these problems with the webgl backend. Also, I'm on Lubuntu (Linux) 64bit if that helps. How can I fix this?

EDIT: I was able to fix the problem by flooring camX and camY. I'm still interested in what caused it, wouldn't a non integer value for the translation at most slightly distort the texture rather than causing those black lines?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (10 views)
2014-11-28 16:25:09

PocketCrafter7 (11 views)
2014-11-28 16:24:29

toopeicgaming1999 (76 views)
2014-11-26 15:22:04

toopeicgaming1999 (67 views)
2014-11-26 15:20:36

toopeicgaming1999 (17 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!