Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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 game flickers on Linux  (Read 3122 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Devvie


Projects: 3



« Posted 2013-11-29 19:54:32 »

I have made a game in Slick2D that works just fine in Windows OS. The same can not be said for Linux. The graphics flicker a lot!
This is a major problem to all Linux and probably Mac users.

I am not using any LWJGL calls, so what can be causing this?

Some code:

Starting the game:
1  
2  
3  
4  
5  
6  
7  
8  
         Engine engine = new Engine(title, stage, replay, frame);
         
         AppGameContainer agc = new AppGameContainer(engine, stage.visibleWidth, stage.visibleHeight, false);
         engine.setAppGameContainer(agc);
         agc.setTargetFrameRate(60);
         agc.setShowFPS(false);
         agc.setVSync(true);
         agc.start();


Rendering method:
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  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
   @Override
   public void render(GameContainer gc, Graphics g) throws SlickException
   {
      g.setAntiAlias(AA);
     
      if(state == GameState.PAUSED)
      {
         renderPause(g);
         return;
      }
      if(prevPaused && stage.music != null)
         stage.music.setVolume(Stage.MUSIC_VOLUME);
      prevPaused = false;
     
      if(autoTranslate)
      {
         float focusX = focus.currX + focus.width  /2,
              focusY = focus.currY + focus.height / 2;
         
         tx = Math.min(stage.width  - stage.visibleWidth,   Math.max(0, focusX - stage.visibleWidth  / 2));
         ty = Math.min(stage.height - stage.visibleHeight,  Math.max(0, focusY - stage.visibleHeight / 2));
      }
     
      if(vertSpeed > 0)
         moveVert();
      if(horSpeed > 0)
         moveHor();
      if(scaleSpeed > 0)
         scale();
     
      g.translate(-tx, -ty);
      g.scale(sx, sy);
      g.rotate(rx, ry, ang);      
     
      if(stage.map != null)
         g.drawImage(stage.map, 0,0);
     
      if(stage.background != null)
         stage.background.getObject().draw(0,0);
     
      for(ReplayData rd : ghosts)
      {
         DataImage di = rd.character.getFrame();
         if(rd.character.visible && di != null)
            di.draw(rd.character.currX + rd.character.offsetX, rd.character.currY + rd.character.offsetY);
      }
     
      if(!mainHighPriority)
      {
         DataImage mainImg = main.getFrame();
         if(main.visible && mainImg != null)
            mainImg.draw(main.currX + main.offsetX, main.currY + main.offsetY);
      }
     
      if (state == GameState.DEAD && main.death != null)
      {
         Image img = main.death.getObject();
         img.draw(main.currX + main.offsetX, main.currY + main.offsetY);
      }
     
      for (Enemy enemy : stage.enemies)
         if (enemy.visible)
         {
            if(enemy.particleBehind)
               for(ParticleSystem ps : enemy.particles)
                  ps.render(enemy.currX + enemy.partOffsetX, enemy.currY + enemy.partOffsetY);
               
            if(enemy.drawSpecialBehind)
               enemy.drawSpecial(g);

            drawObject(enemy);

            if(!enemy.drawSpecialBehind)
               enemy.drawSpecial(g);
           
            if(!enemy.particleBehind)
               for(ParticleSystem ps : enemy.particles)
                  ps.render(enemy.currX + enemy.partOffsetX, enemy.currY + enemy.partOffsetY);
         }
     
      for(GameObject go : stage.stageObjects)
         drawObject(go);
     
      stage.playEffectEvents(g);
     
      if(mainHighPriority)
      {
         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);

      renderStatusBar(g);
     
      if(state == GameState.DEAD)
         renderDeadText(g);
   }


DataImage extends slick Image and only add pixel data for fast pixel-perfect collision.

So why is the game flickering on Linux?
Offline condorcraft110

Senior Newbie





« Reply #1 - Posted 2013-12-02 01:10:33 »

Slick2D is built on top of LWJGL. Every time you call a method in, say, Graphics, Slick makes at least one LWJGL call. Just saying.
Offline P0jahn

Senior Devvie


Projects: 3



« Reply #2 - Posted 2013-12-02 22:21:00 »

I know that. To make Slick2D work correctly, you should not call any LWJGL functions. You should leave it to Slick2D. Otherwise you may get inconsistent behavior.
I am not making any calls to LWJGL, I am leaving that to Slick. So this bug should not occur.

I am considering switching to LibGDX but I am not sure that it will solve this problem.
If it doesn't, then I am positive that LWJGL 3.0 will. Hopefully, LibGDX will update their framework to make it compatible with the new version.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline xsvenson
« Reply #3 - Posted 2013-12-03 09:17:07 »

Flickering might mean unstable FPS, meaning, fps-spikes. I would suggest profiling Your code and find the hotspots and then see what and if You can make things better

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline Violet Hoze
« Reply #4 - Posted 2013-12-16 18:40:54 »

I made only one game with slick2d before I  got LibGDX. I am not sure what exactly your flickering problem is. But as I remember I have some weird choppiness and flickering problem on my windows machine.
Offline P0jahn

Senior Devvie


Projects: 3



« Reply #5 - Posted 2014-03-16 00:05:07 »

Bumping this.

Alright, I have just ported my game to LibGDX. Works great in Windows.
But guess how it looks in Linux. Its flickering! How is that even possible? My games flickers in Linux on both frame Slick2D AND LibGDX!!!! >_>

What is causing this? Really.

I want to note that the only things that are flickering is animated entities.
Offline opiop65

JGO Kernel


Medals: 161
Projects: 7
Exp: 4 years


JumpButton Studios


« Reply #6 - Posted 2014-03-16 00:10:41 »

Probably bad graphics drivers.

Offline P0jahn

Senior Devvie


Projects: 3



« Reply #7 - Posted 2014-03-16 00:34:09 »

No. The very same flickering issue exists on other computers as well.
Offline HeroesGraveDev

JGO Kernel


Medals: 323
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #8 - Posted 2014-03-16 00:50:26 »

You were doing this on an actual Linux system, and not a VM, right?

Have you checked you have the latest and correct drivers installed?

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.

Mr.CodeIt (24 views)
2014-12-23 03:34:11

rwatson462 (55 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (89 views)
2014-12-09 22:41:13

BurntPizza (112 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (92 views)
2014-12-03 16:27:13

CopyableCougar4 (100 views)
2014-11-29 21:32:03

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

toopeicgaming1999 (159 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

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
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!