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.

DarkBASIC Professional Discussion / Why can I not stop the flickering?

Author
Message
zeone3000
6
Years of Service
User Offline
Joined: 8th Oct 2017
Location:
Posted: 8th Oct 2017 08:49
Even when trying the most basic of code such as...



The EXE flickers like crazy!

Running Windows 10, using DBPro 9Ex, nvidia geforce GTX 560 Ti. I really starting to think it's just a compatibility issue after plucking at the other threads with a keyword 'flicker' search.
Sedit
6
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 8th Oct 2017 21:31
If I place Sync on at the start then a sync command after print it works fine.
zeone3000
6
Years of Service
User Offline
Joined: 8th Oct 2017
Location:
Posted: 9th Oct 2017 20:22
When I do that, I get a black screen.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 9th Oct 2017 21:54
Your code works ok on my side

Anyway try this:


zeone3000
6
Years of Service
User Offline
Joined: 8th Oct 2017
Location:
Posted: 12th Oct 2017 02:55
Hey, the letters are no longer flickering but the background color still is. I wonder what happens if I set a foreground color.
Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 12th Oct 2017 07:30
try this one:

Bored of the Rings
User Banned
Posted: 12th Oct 2017 10:08
yes sometimes in the past I used to have to use 2 sync commands.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
zeone3000
6
Years of Service
User Offline
Joined: 8th Oct 2017
Location:
Posted: 12th Oct 2017 19:40
Looks like the scancode is greater than 0 because it's exiting now and I don't even know what scancode is.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Nov 2017 21:57
You just need two sync commands, like this:



The reason you need two syncs is connected with the double buffering method DBPro uses. I'm not sure of the full reason it's needed but virtually all of my programs and demos start with something like:



The very first sync command in a program initialises the back buffer and then the next and subsequent sync commands display what's been specified. I think that's why you saw the black screen when you tried without the first sync. I don't know why it apparently worked for Sedit.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 9th Nov 2017 02:04 Edited at: 9th Nov 2017 02:12
I agree with this suggestion. When ever I use something like a Get Image command and realize that it might be going off before the first Sync I get a but uneasy. It is good form to Sync once after using the Set Display Mode command.

sync rate 60 - I don't like this part but it's helpful in example code. There's just better but more complicated ways of handling frame rate caps.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Nov 2017 12:52
I agree sync rate 60 isn't always appropriate - it's just a simple way to limit the frame rate in most of my examples.
Sedit
6
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 20th Nov 2017 03:50
I just relooked at this thread,

There is no Sync On command at the start of his code, I just had the same problem, Without turning sync on the project flickers. I believe a simple Sync on would fix his issues.
IBOL
Retired Moderator
19
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 9th Dec 2017 14:24
One of my users is having this problem with a game i made in AGK.
I'd love to hear more about stopping this.
Sedit
6
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 13th Dec 2017 07:21
"The very first sync command in a program initialises the back buffer and then the next and subsequent sync commands display what's been specified. I think that's why you saw the black screen when you tried without the first sync. I don't know why it apparently worked for Sedit. "

It worked for me because I placed the second Sync command like you were talking about After the print command. Personally, IDK why he seen the Black Screen when doing this since the Print command should have sent it to the backbuffer then the sync command after should have displayed it.
Sphere sphere = new Sphere(0.5f);
InsanelyRedundantJava insanelyredundantjava = new InsanelyRedundantJava(Redundancy1, Redundancy2);
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Dec 2017 14:47
Interesting. I've just tried this again and the original code posted by zeone3000 worked perfectly first time. I then checked which version I was using and it was DBProU77RC7. When I re-installed DBP9Ex the flickering returned so there's something else going on here.

When I added the two lines that Sedit suggested the exe wouldn't display at all for some odd reason . The code I used is Sedit's original suggestion with only one extra sync added plus the sync on command as he suggests, i.e.



When I added the extra sync at the beginning as I suggested earlier, i.e.



the code then worked perfectly. So I'm still baffled why Sedit's original suggestion worked. Here's what he said:

Quote: "If I place Sync on at the start then a sync command after print it works fine."


Perhaps he thought he'd mentioned the first sync - but hadn't?

Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 18th Dec 2017 03:47
such things occurs due to the double buffering of the screen. When Dbpro controls sync it will seemingly automatically flip buffers for you, so when DB hits the wait key command, it sits in a busy loop.. The loop will check messages (for input) and if you've not enabled manual sync control it will periodically flip the screen buffers. So front becomes back and vice versa, this will make the display seem to flicker (on machines that can page flip) as when you draw, you're drawing to the current screen back buffer (which flips between two or more buffers), so on one version of the screen the message is printed and on the other is blank.


one way to counter this would be to render the same sequence to both buffers. So draw the scene call SYNC, then draw the scene again call SYNC. This will seed both buffers with the same image and it no longer matters when DB flips the buffers, as the user sees the same input regardless.


ie.




What you really should do though is enable manual SYNC and then you control when the FRONT / BACK buffers are swapped.



PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Dec 2017 12:26
Very true - and essentially the point I made in an earlier post.

However, any idea why I see nothing at all when I compile the following code using Rudolpho's DBP9Ex version of DBPro? The bizarre thing is that I literally see nothing other than the editor window, not even the taskbar. Yet the exe is running because I get a lot of fan noise and can't get control back until I press a key.



Kevin, I tested your code with DBP9Ex and that also flickers unless you add sync on at the beginning. DBPU77RC7, which doesn't flicker. and DBP9Ex, which does, seem to handle this situation differently which is a touch confusing.
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 18th Dec 2017 15:33 Edited at: 18th Dec 2017 15:43
It may well have implement Triple buffering to remove the dead time in syncing the last drawn frame

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Dec 2017 17:57
I guess Rudolpho would know the reason.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Dec 2017 18:26
Alas I do not; your code displays a (albeit black due to the buffer swapping as described above) window just fine for me. What OS and DBP9Ex versions are you using?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Dec 2017 19:17 Edited at: 18th Dec 2017 20:03
Hmm? I'm using W10 Home, Version 1709, Build 16299.125 on my laptop. I'll try it again on my Desktop.

I thought I was using the latest version of DBP9Ex, i.e. DBPro9Ex_20170122. I've just checked and that is NOT the most recent version, sorry!

Anyway, I've now tested that snippet with your latest update and I get exactly the same result as I described before. I'll test this on my desktop and report back asap.

Edit: Well this is weird. I get exactly the same problem using my desktop (same OS, version and build). I even get the same when I change the snippet to



In the above snippet I've tried to capture a screenshot when you press a key. Here's the saved image:



However, I do not see that! I just see the editor or folder and the DBP exe icon in the taskbar, nothing else. Nothing shows to indicate the exe is running except the task bar icon, other than an apparently non-responsive system till I press a key to exit.


Edit2: I shouldn't worry too much about this if I am the only one who sees this behaviour - everything else seems fine when you follow the usual advice about using two syncs, etc.

Incidentally, KP's code flickers using DBPro9Ex V1.009 on my desktop as well.

Attachments

Login to view attachments
Sedit
6
Years of Service
User Offline
Joined: 3rd Sep 2017
Location: Ghetto of NJ
Posted: 20th Dec 2017 20:16
"It may well have implement Triple buffering to remove the dead time in syncing the last drawn frame"

Very very possible considering Direct X uses whats known as the Swap Chain, Its I believe 4(but maybe 3 dont quote me on that) buffers to speed up the rendering process. In C++ you have to set the swap chain up yourself but DBPro more then likely does all of that for you.

I will go see which version of DBPro I am running because perhaps that has something to do with why it worked for me and not him.

I noticed in the past if I had a wait command to close to my sync it did not have time to display and making it sleep for 100 ms would allow it to show up.

Sphere sphere = new Sphere(0.5f);
InsanelyRedundantJava insanelyredundantjava = new InsanelyRedundantJava(Redundancy1, Redundancy2);

Login to post a reply

Server time is: 2024-03-29 01:50:46
Your offset time is: 2024-03-29 01:50:46