Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 7th Jul 2013 00:33
Hellooo,

This is my last technical problem that I am having with my program.
This is NOT a coding issue, as it happens on all of my programs.

A little over half way down.. maybe 5/8 there is a "ripple" in the screen. Where when I move or rotate the camera it becomes blurry and kinda "liney."

This happens on the other computers when people test my program, so it has to do with relations between the program and my Windows 7 64 bit computer. I run everything as admin and have the latest updates installed for both drivers and the program.

Any advice is appreciated,
Thank you
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Jul 2013 00:38
Are you perhaps running the application in fullscreen mode and using a much lower resolution than what the screen would be able to handle?

Or would you say this is an anti-aliasing artifact?

TheComet

Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 7th Jul 2013 02:08 Edited at: 7th Jul 2013 02:16
I recall seeing the problem that I think you're experiencing, I even made a thread on it back in the day.

Could you post an example of your screen setup code?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 7th Jul 2013 02:38
Is your fps above 60? This could be a result of having high fps and not having vertical-sync enabled. Sometimes this causes an issue called screen tearing, where a new frame is rendered while the display is halfway through displaying the previous frame. If this is the case, you should use set display mode <width>,<height>,<depth>,1 where the 1 is the VSync flag. That will limit the FPS to the refresh rate of your monitor so this does not happen.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 7th Jul 2013 03:08
This is NOT an anti-aliasing issue, although that has been a problem in the past. Also, the res is correct.

As for the VSync, I will try that now! I'll let you know.

It is fullscreen, 1920x1080, 32 bit (I have a res picker for this stuff), and sync rate at some number. Don't remember what I decided on the best one being.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 7th Jul 2013 03:24
Quote: "It is fullscreen, 1920x1080, 32 bit (I have a res picker for this stuff), and sync rate at some number. Don't remember what I decided on the best one being."


Alright. If this does turn out to be the problem, I would recommend keeping vsync on, using sync rate 0, and creating a timer-based system so that the code runs at a constant speed. With this setup, the program will always refresh at the correct speed for the user's display. The TBM system will handle the difference in speed between 60hz (60fps vsync), 72hz (72fps vsync), 120hz (120fps vsync), or any other monitor refresh rate. If you want, I have a timer module that does all the calculations for you, I'd upload the module if you want.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 7th Jul 2013 05:10
Quote: " If you want, I have a timer module that does all the calculations for you, I'd upload the module if you want."


Yes that'd be awesome!

VSync DID turn out to fix my problem! I will add that to the options, and make sync rate 0 at the beginning. I would love the timer one as well, as my friend's laptop runs it much quicker than my test computer.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 7th Jul 2013 05:28 Edited at: 7th Jul 2013 05:28
Alright, here's the current version of the Timer system I use. It's based on a few people's ideas and that's the best version I've been able to create so far.

To use it, simply call TBM_Init() at the start of your program, TBM_Update() at the start of your main loop, and then multiply any movement you desire to be timer-based by "TBM". Here's a simple example:



Keep in mind that this system isn't perfect. This is very simple, and just creates a multiplier based on the current loop speed. It's usable in most cases, but sometimes using timer-based systems can mess up if you're doing physics or other complicated calculations. But it should be a good solution for you. There are also two other functions in the module that might help, TBM_Curvevalue() and TBM_Curveangle(), both of which are timer-based versions of their dbpro equivalents.

If you want more knowledge on this topic, do a few forum searches - the proper way to handle timer-based systems has been debated a million times here and just by reading about it you will learn more. That's how I coded that module. And if you find an improvement, email me or post it somewhere. I'm by no means an expert, but I try to help!

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 7th Jul 2013 09:41 Edited at: 7th Jul 2013 10:03
Screen Tearing
So Vsync helped solve the problem. There is a better solution.
Vsync rests the GPU but not the CPU.

In simple terms your problem is that the frame rate is much higher than the screen can display. Vsync makes the game wait on each frame so that the frame rate isn't too high. But the CPU stays maxed out the entire time.

Use a frame limiter instead of Vsync.
Call this function before any sync command.


That's it. Simple. A simple function call before sync and your problem is solved. It will let your CPU and GPU rest if the frame rate is too high. You'll have less heat, quieter fans, and more battery life.

Further reading:
http://forum.thegamecreators.com/?m=forum_view&t=202812&b=1

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 7th Jul 2013 19:17
@thenerd and @Mage thank you very much for your help. It looks like you both have the same idea as to what I should do.

I am trying thenerd's code first.

It looks pretty good but I get one error when I compile and run it:



What should I do?
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 7th Jul 2013 19:37 Edited at: 7th Jul 2013 19:39
Hitimer() is a function from IanM's matrix1 utilities - It just provides a higher resolution timer than the dbpro default, although you could replace it with the dbpro timer() and it would work almost the same. I'd recommend installing matrix1, it's a really great plugin collection with a lot of useful functions. But again, if you don't want to download a plugin you can just switch that function to timer().

In addition, it's probably worth it to try combining Mage's frame limiter with the Timer-based system. I haven't tried his method yet but I trust his advice, he seems to have researched that topic more than I have.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 7th Jul 2013 22:04 Edited at: 7th Jul 2013 22:37
Quote: "@thenerd and @Mage thank you very much for your help. It looks like you both have the same idea as to what I should do."

Not true. They are completely different. You should do both and turn off Vsync.

I'll explain:
Your problem started because your game is drawing each frame too fast. You have a bunch of spare time you don't need and your game is just using it to draw more frames in a shorter time. The screen can't handle it and it caused the lines to appear. The solution is to make the program wait a ill bit on each frame if its too fast so the frame rate doesn't overload the screen. Vsync does this, but keeps your CPU maxed out. Only your GPU gets a break. My method is better because CPU and GPU rest. So you get less heat, the fans don't get as loud, and laptops get longer battery life. Imagine if you were getting 120 fps and my method dropped you down to a 60 fps cap. You'd be getting 60 fps and half the time the computer would be completely idle. This is a massive epic advantage.

TheNerds suggestion allows your gameplay to run at the same speed in the players eyes regardless if the frame rate is high or low. Our suggestions are two completely separate things and should both be used. His suggestion doesn't actually address your screen tearing problem, but it's a good suggestion regardless. Obviously people are going to have different frame rates. Not everyone will hit and stay at the frame rate cap. So you don't want the on-screen gameplay to be at different speeds. The solution is not to try to lock someone at a specific frame rate, you can't. Instead make the game not care what frame rate it has and still play at same speed for everyone.

Quote: "In addition, it's probably worth it to try combining Mage's frame limiter with the Timer-based system. I haven't tried his method yet but I trust his advice, he seems to have researched that topic more than I have."
Thanks. It works fantastically. Do both.

Quote: "Hitimer() is a function from IanM's matrix1 utilities - It just provides a higher resolution timer..."

I would agree, it is helpful. The case for this is better with TheNerds TBM suggestion where the extra precision can matter in some situations. In my suggestion where I am instead capping the frame rate, the fact it's really capped at 59, 60, 61 or whatever isn't that important where a PC game is concerned. The half of a frame or so is only several seconds of battery life at best.

I typically try to avoid mentioning the plugin to keep barriers low for people receiving suggestions. But it's always good if at least someone brings it up. I don't want anyone thinking that I have a hate on, since I never include HiTimer() in anything.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 9th Jul 2013 05:54
Okay thank you guys very much. Time to try both
Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 9th Jul 2013 06:07 Edited at: 9th Jul 2013 06:09
This is odd.

So just thenerd's code worked amazing on my computer. Then on my friend's (same OS) it ran 1/2 the speed and really jittery. Then I put Mage's code into mine and it worked fine but every second it paused for a frame. Then I changed the values to 32 to see what happened and it looked like my friend's computer with thenerd's code.

Daf***?

EDIT: I changed the values to 8 and it works fine on my computer. I guess 16 was too large of a check or something or other? But there is still the problem with my friend getting the jitteriness.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 9th Jul 2013 09:06 Edited at: 9th Jul 2013 09:07
Check that Sync Rate is set to 0.
Make sure VSync is off.
Make sure to also use "Sync On" when setting Sync Rate 0.

Don't use 8 it will cap your frame rate at around 120 (when working correctly).

Make sure Sync, FrameLimiter(), and TBM_Update() are being called only once per loop.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 9th Jul 2013 14:27
They are being called once. Want to see my code minus the bulk?
Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 9th Jul 2013 14:56
Here is my code:



Just one frame of lag each second it seems and I do notice it. I didn't see it in windowed mode, but that doesn't mean it isn't there.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 9th Jul 2013 15:16
Quote: "So just thenerd's code worked amazing on my computer. Then on my friend's (same OS) it ran 1/2 the speed and really jittery. Then I put Mage's code into mine and it worked fine but every second it paused for a frame. Then I changed the values to 32 to see what happened and it looked like my friend's computer with thenerd's code.
"


I'm not quite sure what you're talking about here. My code and Mage's code do two different things. The solution I originally posted to your screen tearing problem was made up or two parts: turning on vsync and then using the TBM system to ensure it ran at the same speed no matter what. Mage's system is intended to replace turning on Vsync, because it adjusts the screen fps without the wasted processor usage. So, to properly combine our systems you would keep vsync off, turn sync on with sync rate 0, and do the proper updates for both our systems.

Since there's probably a problem either in your code or ours, let's narrow down the debugging. First of all, add an indicator of the fps. Since Mage's system regulates the FPS, if there is any problem related to that, it will show up in the screen fps. If the screen fps is fine but the movement still seems glitchy, that could be related to my system which calculates a multiplier to adjust the movement speed (but doesn't affect the FPS rate).

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 9th Jul 2013 22:48
@thenerd Bottom line the change to 32 decreased the fps so much it was like my friend's comp, so your method made him lag. Your method however worked for me, so idk.

His method made me lose a frame occasionally so I will try an FPS moderator
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 9th Jul 2013 23:59
Quote: " set display mode 640,520,16,1"

I'm away from the computer at the moment so I can't look up the commands in detail. What's with the 1 on the end of this command? Is that a Vsync switch? Should be off if it is.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 10th Jul 2013 00:17 Edited at: 10th Jul 2013 00:17
Wait vsync should be OFF??

And yes it is
Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 10th Jul 2013 01:50
If its off I get tear in the screen so it has to be on.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 10th Jul 2013 02:15 Edited at: 10th Jul 2013 02:16
You should turn Vsync off and use my suggested code with the original numbers. This will correct the screen tearing. If you use 8 or what ever you mentioned above you'll see the tearing.

I'll post a working example in a few hours.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 10th Jul 2013 02:20
Quote: "You should turn Vsync off and use my suggested code with the original numbers. This will correct the screen tearing. If you use 8 or what ever you mentioned above you'll see the tearing."


Except for the fact that I still do with vsync off lol. I need it on for my computer apparently.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 10th Jul 2013 03:06
Something's wrong i'll post an example, I'm on my mobile phone at the moment.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 10th Jul 2013 09:58




Press Shift and It will introduce some lag for effect.

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 10th Jul 2013 15:25
@Mage sorry but your timer thing to limit program use just is not working for me.

I get a very smooth and nice effect with VSync and the frame timer, and no matter what I do I get tears in the screen with VSync off (even with this code). I have an extremely fast graphics card so that may be it, but I do not know. Your frame limiter, with 16, will always make me miss a few frames or something when I move the camera (My guess from the Sleep function). If this is just for computer memory then I have no use for it at this point anyway, maybe later.

As for now I will just use the frame timer and VSync.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Jul 2013 18:26
VSync must be on to stop the screen tearing.

On.

This is my current project, check it out! [href]forum.thegamecreators.com/?m=forum_view&t=204576&b=8[/href]
This is my website, check it out! [href]http:\\www.TeamDefiant.co.uk[/href]
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 10th Jul 2013 23:42 Edited at: 10th Jul 2013 23:43
Did you run the example that I posted?
I have a feeling the problem is importing the code into your project.

I've tested this code on intel and amd CPUs. Windows 7 and Windows 8.

If you are getting screen tearing then what was your frame rate at?

Master SeePlusPlus
13
Years of Service
User Offline
Joined: 30th Dec 2012
Location:
Posted: 11th Jul 2013 00:38
For my program the FPS was 60 and I got tear w/o vsync and no tear w/ vsync. IDK what FPS was for yours.. not at my computer right now.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 11th Jul 2013 01:32
Interesting I've never seen it do that at 60. Hmmm... Perhaps if you set the value down to 10 from 16 and enabled Vsync you might be able to save some of the CPU whilst keeping Vsync to time the end of the frame.

GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 11th Jul 2013 04:39 Edited at: 11th Jul 2013 04:40
I know little about the subject, but if vsync "halts" the program if it is syncing faster than the monitor can handle, but you are using a frame limiter, then theoretically vsync should never actually "halt" the program and waste CPU cycles... Plus, I think vsync does more than just the limiting thing, so I can't see why you wouldn't use all 3 suggestions, TBM, Frame Limiting, and vsync.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 11th Jul 2013 05:20 Edited at: 11th Jul 2013 05:24
Well you don't want to have Vsync stepping the frame rate down to 30 fps unless intended. There's a lot of hardware and operating system related stuff at play here to. That's why I'm a little hesitant to suggest that. It's a very small risk. Also it's not as power efficient despite giving the same fps.

Lets say at 60 fps one frame takes 16ms to draw but your program is drawing it in 6ms. So you can let the computer snooze for that remaining 10ms. The only thing is Windows doesn't return control back to the program on time. It's off by a few ms usually. Because the timing with the monitor is off he's getting screen tearing.

So theoretically you could snooze for some of the time by setting the frame limiter at maybe 70fps and enabling Vsync. Vsync would further cap frame rate down to 60. So that wait period I just mentioned would be mostly processor friendly and capped with Vsync providing final few ms to line the frame timing up correctly.

It would probably add an extra hour to battery life.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 11th Jul 2013 05:39
On second thought I suggested a bad idea. I'll recommend a processor friendly fame limiter without Vsync even if there's some screen tearing from time to time.

If you read my suggestion about I mention combining Vsync with a frame limiter. This is a terrible option since by sync isn't always 60hz and is set to the monitor refresh rate. This makes it a bad choice as a frame limiter in many situations also. Combining a processor friendly frame limiter can cause Vsync to step down to a much lower frame rate.

Your program will be a resource hog with it on and it'll be even worse at a high refresh rate. Someone with a 120hz monitor will be capped at 120fps.

I think this is why many games have settings for this stuff. Some people want max frame rate what ever it might be. Some people have overheating and fan noise issues. Some people are on mobile computers with a battery.

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 11th Jul 2013 14:55 Edited at: 11th Jul 2013 15:57
Here you go. Try this.

It starts out really fast for the first second or so, but then the limiter takes over and it runs normally.



I have tested this with a FAST Windows 7 and a slow XP computers and I do not get any tearing on the screen. Set the limiter to 30 and try it on both FAST and SLOW computer at the same time. They both should spin about the same speed. Although in my tests the faster video card spins a tad faster. This is where you could get info on the GPU speeds and factor that into the math. There are many ways on how to do this.

Hope this works out for you.

https://soundcloud.com/toraktu

Login to post a reply

Server time is: 2026-07-06 20:31:26
Your offset time is: 2026-07-06 20:31:26