Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
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  
  Slick2D renders unwanted lines  (Read 1333 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Member


Projects: 2



« Posted 2013-11-11 22:00:32 »

Whenever one image is render next to, or overlapping an other image, there will be an line between the two images.
Example:


These two images are either rendered exactly next to each other or overlapping. As you can see, there is an unwanted line between these two images.

Here is an real example from my game, zoomed at 300%


As you can see, there are unwanted lines when two images overlap. Oddly, it does not happen to the main character(the red guy).

How can I prevent this unwanted line from getting rendered?
Offline opiop65

JGO Kernel


Medals: 131
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #1 - Posted 2013-11-11 22:07:20 »

Well, that shouldn't happen, and doesn't happen normally. No one can help unless you post code *hint hint*

Offline P0jahn

Senior Member


Projects: 2



« Reply #2 - Posted 2013-11-11 23:07:50 »

Have a look at the code that renders the background, foreground and main character:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   @Override
   public void render(GameContainer gc, Graphics g) throws SlickException
   {  
      g.translate(-tx, -ty);
      g.scale(sx, sy);
      g.rotate(rx, ry, ang);

      if(stage.background != null)
         stage.background.getObject().draw(0,0);
     
      DataImage mainImg = main.getFrame();
      if(main.visible && mainImg != null)
         mainImg.draw(main.currX + main.offsetX, main.currY + main.offsetY);

      if(stage.foreground != null)      
         stage.foreground.getObject().draw(0,0);

      g.translate(tx, ty);
      g.rotate(rx, ry, -ang);
   }

Nothing special, just the standard drawing functions.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 131
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #3 - Posted 2013-11-12 03:04:42 »

I've barely worked with Slick2D, so I don't know, but can you change the texture filtering options? It looks like it's bleeding the gray color into what I assume is the transparent part of the texture on the wall that you circled. Same goes for the background texture.

Offline CodeHead

JGO Coder


Medals: 36


From rags to riches...to rags.


« Reply #4 - Posted 2013-11-12 03:55:57 »

As Opiop mentioned, it appears to be an anti-aliasing artifact. I'm guessing it's caused by the calls to Graphics translate, scale, and rotate. Try adding g.setAntiAlias(false); to the top of the render function and see if the problem still persists.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline davedes
« Reply #5 - Posted 2013-11-12 04:11:36 »

Could be a premultiplied alpha issue. Maybe a bug with Slick's FBO usage (i.e. "image graphics").

Another possibility is that you're using sprite sheets, and getting bleeding like this. If that doesn't fix it -- you should try using power-of-two texture sizes (16, 32, 64, 128, 256, 512, etc). Slick does some funky stuff to try and turn NPOT into POT sizes.

Offline P0jahn

Senior Member


Projects: 2



« Reply #6 - Posted 2013-11-12 17:38:53 »

Well, disabling anti alias did not work Sad
Also, I am not rendering sprite sheets but a subclass of org.newdawn.slick.Image. This subclass just store pixel data, for pixel-perfect collisions.
Also, there is no transparent edges on these images. All the colors on background and foreground have alpha value 255. I have also tried adding black background to the foreground image, trying to make the unwanted line look black. But nope, it remains gray. That means that the problem is when two images are overlapping/rendered next to each other.
Offline P0jahn

Senior Member


Projects: 2



« Reply #7 - Posted 2013-11-12 22:49:37 »

I resolved this bug using BigImage instead of Image. The dimensions of background and foreground are 5000x5000 so I figure BigImage would solve this and it did Smiley
Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (217 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!