Author Topic: Screen flicker when switching active monitor  (Read 3213 times)

0 Members and 1 Guest are viewing this topic.

Offline Ophelius

  • Newbie
  • Posts: 15
    • View Profile
Screen flicker when switching active monitor
« on: August 09, 2020, 09:36:00 pm »
I have software I made that I use primarily on my 2nd monitor in full screen. When I click away to my main monitor, my program flickers black for 1/4 of sec, and flickers again when clicking back into it. Any way around this? It's not the end of the world, but it's slightly annoying.

Here's how I declare and render:

Init:
Code: QB64: [Select]
  1.    
  2.     SCREEN _NEWIMAGE(ScreenW, ScreenH, 32)
  3.  
  4.     VPage = _NEWIMAGE(ScreenW, ScreenH, 32)
  5.    
  6.     BG = _NEWIMAGE(ScreenW, ScreenH, 32)
  7.  
  8.  
  9.  

Mainloop:
Code: QB64: [Select]
  1.  
  2.     _DEST VPage
  3.     _PUTIMAGE , BG, VPage
  4.  
  5.     'main loop code
  6.  
  7.     _PUTIMAGE , VPage, 0
  8.  
  9.     _LIMIT 60
  10.  
  11.  

Any help would be appreciated. Thanks

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Screen flicker when switching active monitor
« Reply #1 on: August 09, 2020, 10:32:30 pm »
_DISPLAY is usually the cure for flickers but that's usually used in a loop and whenever you want to update the _DISPLAY of the screen. You have to remember when using it, that you have to use _DISPLAY every time you want to show some printing or new drawing.

Turn it off with _AUTODISPLAY default mode that draws or prints things immediately.
« Last Edit: August 09, 2020, 10:34:04 pm by bplus »

Offline Ophelius

  • Newbie
  • Posts: 15
    • View Profile
Re: Screen flicker when switching active monitor
« Reply #2 on: August 09, 2020, 11:01:41 pm »
Thank you, but there's no flickering when the program is active, only for a brief moment when clicking away from the program onto my main monitor, and once more when clicking back into it.

I tried this example from the help:
Code: QB64: [Select]
  1. CONST MenuHeight = 200
  2.  
  3. SCREEN _NEWIMAGE(640, 480, 32)
  4. 'SLEEP 1
  5.     _LIMIT 30
  6.     DisplayMenu
  7.     k = _KEYHIT
  8.     IF k <> 0 THEN PRINT k,
  9. LOOP UNTIL k = 32 OR k = 27
  10.  
  11. SUB DisplayMenu
  12. STATIC init, MS_HW AS LONG
  13. IF NOT init THEN
  14.     init = -1
  15.     MS = _NEWIMAGE(640, MenuHeight, 32) 'MenuScreen image
  16.     D = _DEST: _DEST MS
  17.     CLS , &HFFAAAAAA 'background color gray
  18.     _PRINTSTRING (20, 2), "Menu Test" 'image text
  19.     MS_HW = _COPYIMAGE(MS, 33) 'create the MenuScreen_HardWare image
  20.     _FREEIMAGE MS
  21.     _DEST D
  22. _PUTIMAGE (0, 0)-(640, MenuHeight), MS_HW
  23. END SUB  
  24.  

and it does the same thing, so there's probably nothing I can do. It doesn't do this with other full screen programs when I click back and forth between monitors, so I thought it might of been how I was rendering. Thanks

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Screen flicker when switching active monitor
« Reply #3 on: August 09, 2020, 11:39:02 pm »
Yeah when you said 2 monitors I said "Oh boy!"

You might enjoy Options > Code Layout > Indent Subs and Functions.