Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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  
  Why god why... More game loop nonsense  (Read 2404 times)
0 Members and 1 Guest are viewing this topic.
Offline GiraffeTap222

Senior Newbie





« Posted 2013-01-08 08:56:00 »

For one reason or another my game loop has been acting strange. Its seems like I have started to stutter again... and again, no matter if I used a fixed time step or variable time step!

If possible could any one test this code and/or tell me where I went wrong? Its based on a fixed timestep decoupled from FPS. You should just be able to just cut and paste it
Thanks!

http://pastebin.java-gaming.org/4440b947231

{Edit : I always forget this, specs on my dev pc}

Dell Studio XPS 1640 Laptop -
Windows 7 64 bit
4.0 GB ram DDR2
Core Duo T955 2.66 Ghz
ATI Mobility Radeon HD 4670 [Drivers up to date]
Online theagentd
« Reply #1 - Posted 2013-01-09 01:09:13 »

Butter smooth here at 7000 FPS.

EDIT:
Try changing your initing code to this:
1  
2  
3  
         Display.setDisplayMode(new DisplayMode(800, 600));
         Display.create(new PixelFormat(24, 0, 0, 0, 8));
         Display.setVSyncEnabled(true);

Myomyomyo.
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #2 - Posted 2013-01-09 01:36:54 »

Hey! I just wrote an article on game loops, maybe it can help you figure out what your problem is:

http://www.gameprogblog.com/generic-game-loop/

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GiraffeTap222

Senior Newbie





« Reply #3 - Posted 2013-01-09 02:13:53 »

Butter smooth here at 7000 FPS.

EDIT:
Try changing your initing code to this:
1  
2  
3  
         Display.setDisplayMode(new DisplayMode(800, 600));
         Display.create(new PixelFormat(24, 0, 0, 0, 8));
         Display.setVSyncEnabled(true);


I tried this and still same results Sad

This also happens on the other computer I test on which was built for gaming and much more powerful than the dev computer. It has a fresh install of Windows 7 and updated drivers directly from the nvidia site.

Now this may sound crazy but is there some "openGL driver" I have to install? I mean this should have already been with my drivers but at this point I don't know. DirectX games and etc run just fine, but anything dealing with openGL stutters or has some crazy line distortion going down the screen when I go full screen (Same thing happens on the gaming pc).
Online theagentd
« Reply #4 - Posted 2013-01-09 02:38:41 »

Then your computer is the cause of the stuttering. Radeon cards do have a reputation of having small frame time spikes at times. It could also be something with your laptop's monitor. For example, my desktop monitor is pretty cheap and only updates every other line each frame or something like that, so things moving at exactly 1 pixel / screen refresh looks all fuzzy. It might also just be your imagination. We're all differently sensitive to stuttering. I'd say I'm pretty good at seeing it though. Let me just say that you've done pretty much everything you can with code.

Myomyomyo.
Online theagentd
« Reply #5 - Posted 2013-01-09 02:39:58 »

Wait, you're getting stuttering with VSync on? -_-'

Myomyomyo.
Offline Best Username Ever

Junior Member





« Reply #6 - Posted 2013-01-09 02:44:53 »

Is it stuttering because you have a low FPS or is it something less consistent?
Offline GiraffeTap222

Senior Newbie





« Reply #7 - Posted 2013-01-09 03:13:03 »

Wait, you're getting stuttering with VSync on? -_-'

Yep Sad

Is it stuttering because you have a low FPS or is it something less consistent?

According to the Direct X Samples from the June 2010 SDK I run in the range of 200 - 700 FPS.
Where samples with multiple lighting effects and etc trigger the low end of my FPS range.
Online theagentd
« Reply #8 - Posted 2013-01-09 04:55:24 »

Definitely something wrong with your computer. VSync + 60FPS + good interpolation values = no stuttering. You've done everything right if that's what you're getting.

Myomyomyo.
Offline Shiu

Junior Member


Medals: 2



« Reply #9 - Posted 2013-01-09 05:11:43 »

Have you checked in the nvidia control panel if you're forcing vsync off ? This can screw with some things, not sure if it applies to your specific problem, but worth checking.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GiraffeTap222

Senior Newbie





« Reply #10 - Posted 2013-01-09 05:37:28 »

Have you checked in the nvidia control panel if you're forcing vsync off ? This can screw with some things, not sure if it applies to your specific problem, but worth checking.

Both machines have the setting set to vsync off unless the application says other wise. I tried using force off anyway but I still stutter.

Also can someone check out
https://sites.google.com/site/starflighttlc/

And tell me if they get this really weird horizontal line (its like the refresh line that distorts everything) going down the screen every second or so when it is in full screen mode or a steady ticking (once again every second or so) in windowed mode?
Also, if you do get the moving line, what would you call this? I'm not sure how to research it at the moment.
Offline cylab

JGO Ninja


Medals: 49



« Reply #11 - Posted 2013-01-09 08:52:39 »

Also, if you do get the moving line, what would you call this? I'm not sure how to research it at the moment.

This is called screen tearing and is caused by updating or switching the frame buffer while it is displayed. This is usually caused by not doing double buffering or when VSYNC is off.

Since LWJGL uses double buffering by default, either your VSYNC is off, or there is a bug in your driver or the lwjgl version you are using.

Also I am not sure, if using a tight gameloop without any sleep or yield like this may cause hickups with the OS thread/process scheduler, that may force executing of another thread/process at unfavorable times, because it simply does not have a "free" time slot. But thats just a guess, not really backed by knowledge Wink

Mathias - I Know What [you] Did Last Summer!
Online theagentd
« Reply #12 - Posted 2013-01-09 15:30:16 »

Could it be caused by garbage collection pauses or something? But that would still make a dent in the FPS with Vsync on!

Myomyomyo.
Offline Shiu

Junior Member


Medals: 2



« Reply #13 - Posted 2013-01-09 17:55:44 »

Both machines have the setting set to vsync off unless the application says other wise. I tried using force off anyway but I still stutter.

If anything you should force it on in this case, not off.
Offline Best Username Ever

Junior Member





« Reply #14 - Posted 2013-01-09 22:06:06 »

According to the Direct X Samples from the June 2010 SDK I run in the range of 200 - 700 FPS.
Where samples with multiple lighting effects and etc trigger the low end of my FPS range.

That's completely irrelevant. What is your program's average frame rate when it's not stuttering?

Could it be caused by garbage collection pauses or something? But that would still make a dent in the FPS with Vsync on!

There is nothing that creates garbage.
Online theagentd
« Reply #15 - Posted 2013-01-10 01:48:08 »

I just ran it and you're syncing to 59 FPS. Sigh. -_-'

Myomyomyo.
Offline GiraffeTap222

Senior Newbie





« Reply #16 - Posted 2013-01-10 04:44:13 »

I just ran it and you're syncing to 59 FPS. Sigh. -_-'

Is that a bad thing, cause I never set any sync options. Other than the Display.setVSyncEnabled(true) up at the top

I have added a FPS counter and I get

Roughly 2000 FPS without vsync, and then I get 59 - 61? FPS with it on (using the Display.setVSyncEnabled(true) command)

Here is the code I am currently using
http://pastebin.java-gaming.org/0b421288735
Online theagentd
« Reply #17 - Posted 2013-01-10 15:26:37 »

Oh, sorry, I ran this:
That one synched to 59 FPS and didn't use VSync, which gave screen tearing.

Concerning your latest paste: First of all,
glColor3f(255, 255, 255);
is wrong. Float values go from 0.0 to 1.0. It's getting clamped to 1.0 right now anyway, so it works by chance. A gray color would be
glColor3f(0.5f, 0.5f, 0.5f);


I changed it to use nanoTime() instead and to use longs instead of doubles for measuring time. See if it's any better.

http://www.java-gaming.org/?action=pastebin&id=383

Also, setting the update rate to 30 seems to improve things slightly unless I'm imagining things.

Myomyomyo.
Offline GiraffeTap222

Senior Newbie





« Reply #18 - Posted 2013-01-10 23:56:27 »

Oh, sorry, I ran this:
That one synched to 59 FPS and didn't use VSync, which gave screen tearing.

Concerning your latest paste: First of all,
glColor3f(255, 255, 255);
is wrong. Float values go from 0.0 to 1.0. It's getting clamped to 1.0 right now anyway, so it works by chance. A gray color would be
glColor3f(0.5f, 0.5f, 0.5f);


I changed it to use nanoTime() instead and to use longs instead of doubles for measuring time. See if it's any better.

http://www.java-gaming.org/?action=pastebin&id=383

Also, setting the update rate to 30 seems to improve things slightly unless I'm imagining things.

I tried your code and something strange is happening for sure. If I leave the line setting Vsync on it makes the square hiccup horrible.
But if I turn it off it moves smoothly but hiccups every once and a while.

Any ideas?

I have also tried a complete removal of my graphics drivers by
1. Running the ATI Catalyst uninstaller
2. Using driver sweeper AKA Driver Fusion to pick up any remaining files
3. Reinstalled ATI Drivers and Catalysis Control Center
Online theagentd
« Reply #19 - Posted 2013-01-11 00:32:13 »

You can test how accurate the interpolation calculation is by setting the update rate to 60 updates/sec, enabling V-sync and printing the interpolation value each frame. The value should remain very constant. If it's jumping around a lot, you have a problem. Anyway, I'm almost sure it's a driver problem with the AMD drivers now. Either that or System.nanoTime() isn't accurate enough.

Myomyomyo.
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.

BurntPizza (22 views)
2014-09-21 02:42:18

BurntPizza (15 views)
2014-09-21 01:30:30

moogie (18 views)
2014-09-21 00:26:15

UprightPath (25 views)
2014-09-20 20:14:06

BurntPizza (28 views)
2014-09-19 03:14:18

Dwinin (43 views)
2014-09-12 09:08:26

Norakomi (73 views)
2014-09-10 13:57:51

TehJavaDev (97 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!