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  
  FPS problems in LWJGL  (Read 1852 times)
0 Members and 1 Guest are viewing this topic.
Offline trollwarrior1
« Posted 2013-05-17 21:02:08 »

Hello,

Whole eclipse project.
http://www.mediafire.com/?vp0ybzwfutqd4o5

So to the point.

I have a LWJGL game. It renders simple tiles. I'm using VBO along with textures. My game loop calculates when to render and update the game. FPS should be 60. It says 60. After random periods of time my game screen seems to start to laggg like hell. Seems like 10 fps or something. But my game loop still says 60 fps and updates. So I guess this is openGL or LWJGL problem.

A little bit more about my VBO:
I have certain sized vertices(which make certain size squares). I'm guessing this might be caused due to use of translatef.

Just in short again.
Game runs normally. At random times FPS drop very low, but my program executes like usually. FPS fixes after some times. Then starts to lag again. You get the point.
Offline theagentd
« Reply #1 - Posted 2013-05-17 21:15:54 »

GPU or CPU drops into power saving mode and lowers its clock rates? Scratch that if your FPS is fine. >_>

Myomyomyo.
Offline trollwarrior1
« Reply #2 - Posted 2013-05-17 21:25:01 »

I don't think you understood me. This is just some lame ass game. Shouldn't cause any problems for hardware even in power saving modes. It runs at 1000fps if I don't cap it. But doesn't seem that way when the FPS drop.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 130
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #3 - Posted 2013-05-17 21:42:55 »

No, I don't think you understood. I have never had a problem with FPS drops, I would take a look at your code and make sure something isn't messing with your main loops. We really can't help without some sort of source code. I, as of this moment, have no clue what it could possibly be.

Quote
First things first: Can't really post source because it's pretty big and you wouldn't bother trying to understand it.
And how do you know this? I would be glad to look through the code because I could actually help instead of spending the next hour asking you how your game works. Don't assume anything.

Offline theagentd
« Reply #4 - Posted 2013-05-17 21:53:25 »

FPS drop = an actual drop in FPS.
Stuttering = high FPS but it's still not smooth.

Myomyomyo.
Offline gimbal

JGO Coder


Medals: 25



« Reply #5 - Posted 2013-05-17 23:56:48 »

I've seen so many ways my (attempts at) games stuttered and bogged down over the years... the most critical was using integers to represent speed and positions where I now use floats. The second most critical was to let the loop timing ("when to draw the next frame") go out of sync due to not correcting for overshoots and such.
Offline trollwarrior1
« Reply #6 - Posted 2013-05-18 09:15:58 »

Ok I now know where the problem is. I'm doing something wrong with VBO. I switched to intermediate mode for rendering (glVertex2i, you know the simpliest one) and I seem to be getting twice the FPS. This means I'm doing something very wrong with VBO. If anybody has the time and knowledge you could guide me to the right direction Smiley
Offline relminator
« Reply #7 - Posted 2013-05-18 10:15:52 »

Are you rebuilding vbos each frame?

Hard to help without seeing code.
Offline trollwarrior1
« Reply #8 - Posted 2013-05-18 10:21:26 »

Are you rebuilding vbos each frame?

Hard to help without seeing code.

Whole project is available for download. It's an eclipse project.
Offline trollwarrior1
« Reply #9 - Posted 2013-05-18 20:03:50 »

Hm... seems I was wrong. The low fps problem is still there even with intermediate render mode.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kerai

Junior Member


Medals: 4



« Reply #10 - Posted 2013-05-19 20:52:41 »

I played it for a few minutes and no problem so far.. FPS is stable and it looks smooth.
Problem is specific to your hardware, it seems.
Offline trollwarrior1
« Reply #11 - Posted 2013-05-20 09:17:13 »

Hm.... That's heart breaking because I have been looking into this problem for a while now...
Offline trollwarrior1
« Reply #12 - Posted 2013-05-20 11:13:11 »

I think I found the solution. As I was speculating, the problem was with not clearing something from opengl. I found a forum thread somewhere suggesting glFlush(). I implemented it and now I have no FPS drops.
Told ya I wasn't clearing something Tongue
Offline theagentd
« Reply #13 - Posted 2013-05-20 15:35:42 »

I think I found the solution. As I was speculating, the problem was with not clearing something from opengl. I found a forum thread somewhere suggesting glFlush(). I implemented it and now I have no FPS drops.
Told ya I wasn't clearing something Tongue
That sounds a driver problem. glFlush() reduces parallelism between the GPU and CPU since the CPU waits for the GPU. Also, are you using a variable delta?

Myomyomyo.
Offline trollwarrior1
« Reply #14 - Posted 2013-05-20 15:46:03 »

I think I found the solution. As I was speculating, the problem was with not clearing something from opengl. I found a forum thread somewhere suggesting glFlush(). I implemented it and now I have no FPS drops.
Told ya I wasn't clearing something Tongue
That sounds a driver problem. glFlush() reduces parallelism between the GPU and CPU since the CPU waits for the GPU. Also, are you using a variable delta?

If you're asking whether my game renders and updates only at some point of the second than yes. Most of the time game loop runs without doing anything.
As for my problem, it seems to come back sometimes for no reason. I just don't understand why would it persist. I tried it on other computer and it had same fps drop problem.
Offline theagentd
« Reply #15 - Posted 2013-05-20 17:39:08 »

In Main, change all your time variables to longs instead of doubles.

Also, your game loop has a lot of boilerplate code.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
         if(nowTime - oldTime > idleTime) {
            shouldUpdate = true;
            oldTime = nowTime;
         }
         
         if (shouldUpdate) {
            tick();
            ticks+=1;
            shouldRender = true;
         }

         
         if(shouldRender){
            render();
            frames+=1;
         }


is exactly the same as just

1  
2  
3  
4  
5  
6  
if(nowTime - oldTime > idleTime) {
    oldTime = nowTime;
    tick();
    render();
    frames++; //ticks is always equal to frames, so remove one of them.
}


You're also using a busy loop which is a bit bad. You should probably ditch the whole time-related code and throw in a Display.sync(60) instead.

Myomyomyo.
Offline trollwarrior1
« Reply #16 - Posted 2013-05-20 17:48:54 »

Yea I know the thing about "boiler plate" as you called it. I just sometimes switch between 60 and unlimited fps.

I changed doubles to longs. ATM I don't encounter ant fps drop. I thought problem might be there but I didn't actually take a swet to try it.
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.

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