Flickering of the screen due to images and text in a loop - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Flickering of the screen due to images and text in a loop (/showthread.php?tid=2996) |
Flickering of the screen due to images and text in a loop - Delsus - 08-31-2024 Hello team! As advised on the Discord, I'm posting my whole code here. My screen is flickering when displaying images and text. It is a _DISPLAY placing issue. At the beginning of the loop, I actually have 24 cases. Code: (Select All)
In those cases are strings as well. This flickering is surely due to a wrong order of commands and a lack of _display somewhere, however, I don't know where it should be placed for my program to work. There are several DO...LOOP inside this big WHILE...WEND, and I would like to know where to put the _DISPLAY commands in order to stop the flickering. Thank you in advance for your help! RE: Flickering of the screen due to images and text in a loop - SMcNeill - 08-31-2024 Without seeing the whole code, from what you've shared, it seems to me like this would be the proper solution: Code: (Select All) While casenumber <> 25 You're going to have to have an _AUTODISPLAY in effect before the use of that INPUT. The _DISPLAY after that input will stop the screen from refreshing, so you shouldn't see any flicker, as the display would be paused until that _AUTODISPLAY triggered it right before the INPUT. Without the entire source, however, it's hard to say for certain exactly what you need. As I mentioned on discord -- is there any way you can zip up the source and resource files and share them? It's much easier to give advice when you can post the code in and compile it and see the problem in action for yourself. RE: Flickering of the screen due to images and text in a loop - Petr - 08-31-2024 Without images in ZIP archive is not possible test it. RE: Flickering of the screen due to images and text in a loop - Delsus - 08-31-2024 I have now posted an archive with all the assets. I tried some things informed on the Discord, but I am sadly still experiencing flickering. RE: Flickering of the screen due to images and text in a loop - bplus - 08-31-2024 this fixes the error line I immediately encounter in IDE after extraction from zip $ExeIcon:'./main.ico' 'very first impression after OK with above fix This is very poor organization of code, (a sample with 24 duplications) Code: (Select All) Case 9 'fire, needs 1 wood, faster with a lighter I suggest a seperate sub to call for each of those cases and get all that crap out of the main loop, so it is easier to read and fix. Give those subs names for what they do instead of goto case #num. my 30 sec first impression of code, for what it's worth... As stated already fickering is solved by _Display but using _Display and you have to _Display every single time you Print if you want user to see the stuff just printed. And _Display is toggled back off with _Autodisplay so things printed or drawn are shown without need to explicity state _Display but then you get flickering specailly with big screen CLS.'s. So depending on code needs you work under assumed _Display conditions and rules or toggle back to _Autodisplay. Yikes who wants to debug 16000 lines cold? RE: Flickering of the screen due to images and text in a loop - Petr - 08-31-2024 The source code is horribly confusing, but: Somewhere around line 14109 (I poked around, so the number may not agree with the original) you call ResetScreenCLS and then on the next line you call showbg. What's going on: According to my research, ResetScreenCLS is supposed to insert an image with handle BG&. You know about BG& being ZERO? BG& is (probably) not a global shared variable, but a local variable used by showbg itself. It's just that showbg loads the background image, places it, and immediately deletes it from memory. I assume that the exact same problem will be in ResetScreenNoCLS, there it is exactly the same, you insert an image with an invalid handle. So I would strongly recommend loading at least this specific image (bg.jpeg) into memory when the program starts and leave it there with the globally shared descriptor BG&. Look, I spent more than an hour on this, like sorry, but normally my beer warmed up between testing your code. Do you understand the sacrifice I made? RE: Flickering of the screen due to images and text in a loop - bplus - 08-31-2024 +1 @Petr what a sacrifice! LOL But you got farther along than I for sure! RE: Flickering of the screen due to images and text in a loop - Petr - 08-31-2024 Well, luckily I have some more beer in the fridge so can something to do with my appetite RE: Flickering of the screen due to images and text in a loop - Delsus - 09-08-2024 Thank you for your help, everyone! I was able to fix it now |