Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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  
  Libgdx: Padding on a game board is not consistent  (Read 615 times)
0 Members and 1 Guest are viewing this topic.
Offline Achri

Junior Newbie





« Posted 2013-11-28 17:48:14 »

I've posted this on the Libgdx forums without much luck:
http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11688&sid=927deea3ddfa3bc92c1f5e35050f2213

I'm trying to create a puzzle game where the tiles are separated by padding. This padding is shown via the background color showing through between the tiles.

To try and debug this I created a separate project and stripped everything from my game. The new test project is basically the LibGDX demo with some Textures being created in a table format via a double for loop.

When I create a simple board with no logic and just basic Libgdx Textures my problem shows through. It creates a padding between the tiles that varies by a number of pixels. Sometimes there are several lines thicker than other lines.

The textures are added via a double 'for' loop and their positions are set with a constant relative to the x and y of the for loops.

I don't believe this is bleed-through, I am using single textures and the Nearest Texture filter.

I posted it in the OpenGL forum, because I think this is due to OpenGL.

I am out of ideas, I really need a nudge in a new direction.

Here is an example:
Offline Phibedy

Senior Member


Medals: 8



« Reply #1 - Posted 2013-11-28 18:13:48 »

What texturefilters are you using?
links:
http://www.java-gaming.org/index.php?;topic=31138.0
http://phibedy.mineforce.de/publicFiles/random/padding-error.png
Offline Achri

Junior Newbie





« Reply #2 - Posted 2013-11-29 00:35:53 »

Thanks for the reply,

The padding-error.png picture looks exactly like my issue.

I am using the Nearest filter on every Texture.

I followed the first link and ran into a bunch of other links I have attempted. The first time I encountered this I thought it was a floating point division issue. I tried recasting everything either way, and I also printed out all of the  x,y,h,w data for each Sprite/Texture.

I manually calculated each height, width, x, and y and according to the values everything should look perfectly square. This is why I think it is an OpenGL issue.

Here is a picture and the code that produced it:



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  
55  
56  
57  
58  
59  
60  
   public void create() {      
      camera = new OrthographicCamera();
      camera.setToOrtho(false, 550, 550);
     
      batch = new SpriteBatch();
     
      spriteContainer = new Array<Texture>();

    redTexture = new Texture(Gdx.files.internal("data/red.png"));
    greenTexture = new Texture(Gdx.files.internal("data/green.png"));
    blueTexture = new Texture(Gdx.files.internal("data/blue.png"));
    yellowTexture = new Texture(Gdx.files.internal("data/yellow.png"));
    purpleTexture = new Texture(Gdx.files.internal("data/purple.png"));
     
   
    redTexture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    greenTexture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    blueTexture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    yellowTexture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    purpleTexture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
   
    colorContainer = new Array<Texture>();
    colorContainer.add(redTexture);
    colorContainer.add(greenTexture);
    colorContainer.add(blueTexture);
    colorContainer.add(yellowTexture);
    colorContainer.add(purpleTexture);
   
    createSpriteContainer();
   }

   @Override
   public void render() {      
    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      camera.update();
     
      batch.setProjectionMatrix(camera.combined);
      batch.disableBlending();
      batch.begin();
      for(int x = 0; x < 8; x++)
    {
      for(int y = 0; y < 8; y++)
      {
        batch.draw(spriteContainer.get(x + y * 8), 20 + x * 65, 20 + y * 65);
      }
    }
      batch.end();
   }

   private void createSpriteContainer()
   {
      for(int x = 0; x < 8; x++)
      {
         for(int y = 0; y < 8; y++)
         {
           spriteContainer.add(colorContainer.random());
         }
      }
   }


I created the tiles by just changing the color of the tile to each of the colors and exporting. So the tiles should all be identical except for the color.
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.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!