Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (761)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (845)
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 5906 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Devvie

Medals: 1
Projects: 3

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

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

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 Opiop
« Reply #1 - Posted 2013-11-11 21: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 Devvie

Medals: 1
Projects: 3

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

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

   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)
      DataImage mainImg = main.getFrame();
      if(main.visible && mainImg != null)
         mainImg.draw(main.currX + main.offsetX, main.currY + main.offsetY);

      if(stage.foreground != null)      

      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 Opiop
« Reply #3 - Posted 2013-11-12 02: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 Knight

Medals: 52

From rags to rags.

« Reply #4 - Posted 2013-11-12 02: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 03: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 Devvie

Medals: 1
Projects: 3

« Reply #6 - Posted 2013-11-12 16: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 Devvie

Medals: 1
Projects: 3

« Reply #7 - Posted 2013-11-12 21: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  

EgonOlsen (348 views)
2018-06-10 19:43:48

EgonOlsen (342 views)
2018-06-10 19:43:44

EgonOlsen (290 views)
2018-06-10 19:43:20

DesertCoockie (514 views)
2018-05-13 18:23:11

nelsongames (797 views)
2018-04-24 18:15:36

nelsongames (784 views)
2018-04-24 18:14:32

ivj94 (1230 views)
2018-03-24 14:47:39

ivj94 (393 views)
2018-03-24 14:46:31

ivj94 (1057 views)
2018-03-24 14:43:53

Solater (412 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!