Possible CLS improvement - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Possible CLS improvement (/showthread.php?tid=2075) Pages:
1
2
|
Possible CLS improvement - TerryRitchie - 10-09-2023 Quite often I find the need to clear an image other than the current screen or _DISPLAY and have to do this: oDest& = _DEST _DEST MyImage& CLS _DEST oDest& Perhaps CLS could be modified: CLS [method%][, bgColor&][, ImageHandle&] so this could be done: CLS , , MyImage& Just a thought. If you have a better way of handing a situation like this than I'm doing let me know. RE: Possible CLS improvement - SMcNeill - 10-09-2023 Dim Shared ClearScreen As Long ClearScreen = _NEWIMAGE(_Width,_Height,32) _DontBlend ClearScreen ....stuff _PutImage , ClearScreen, Dest ^^ From what I recall, the above is faster than CLS usually. RE: Possible CLS improvement - TerryRitchie - 10-09-2023 (10-09-2023, 04:51 PM)SMcNeill Wrote: Dim Shared ClearScreen As LongAs usual a simple solution I've overlooked. Thanks for the tip Steve. RE: Possible CLS improvement - James D Jarvis - 10-09-2023 don't forget the cursor position isn't going to be reset (which is good or bad depending on what you are doing). In a really crude test CLS was still about twice as fast but the _putimage method is certainly a great idea for clearing the image at a handle. RE: Possible CLS improvement - TerryRitchie - 10-09-2023 (10-09-2023, 05:36 PM)James D Jarvis Wrote: don't forget the cursor position isn't going to be reset (which is good or bad depending on what you are doing). In a really crude test CLS was still about twice as fast but the _putimage method is certainly a great idea for clearing the image at a handle.That's a good point about the cursor position. Like Steve, I thought _PUTIMAGE would be faster too. Thanks for testing. RE: Possible CLS improvement - SMcNeill - 10-09-2023 Another idea that might work: SCREEN _NEWIMAGE(1280, 720, 32) PCOPY 0,1 'copy blank screen ... stuff PCOPY 1, 0 'restore blank screen RE: Possible CLS improvement - TerryRitchie - 10-09-2023 (10-09-2023, 06:36 PM)SMcNeill Wrote: Another idea that might work:Doh! I completely forgot about the PCOPY command. I haven't used that since my Tandy 1000 days. RE: Possible CLS improvement - mnrvovrfc - 10-10-2023 I was going to propose something with `_COPYIMAGE` but it has been iffy in one of my programs. Allocate `LONG` variable, create graphics screen and right afterward, use `_COPYIMAGE` to replicate it. Then use `_PUTIMAGE` to recall that handle. `PCOPY` is a more elegant solution, though. Usually no more than two screens are needed, which on a 32-bit system would have gobbled a lot of RAM. RE: Possible CLS improvement - TerryRitchie - 10-10-2023 I tested all the various methods pointed out in this thread and by far LINE is faster than anything else. I created a subroutine called CLSI (CLS Image) that can be used for my intended purpose. The code is below with a speed tester to show the slight improvement over CLS. Code: (Select All) ' RE: Possible CLS improvement - Jack - 10-10-2023 on my PC running Windows 11 the difference is 0.001 the time varies too much between runs to get a good estimate |