NaaLaa Forum
Is redraw working properly? - Printable Version

+- NaaLaa Forum (http://www.naalaa.com/community)
+-- Forum: NaaLaa (http://www.naalaa.com/community/forumdisplay.php?fid=1)
+--- Forum: Linux specific (http://www.naalaa.com/community/forumdisplay.php?fid=6)
+--- Thread: Is redraw working properly? (/showthread.php?tid=10)



Is redraw working properly? - Tomaaz - 02-04-2018

The result of this code is a black screen:

Code:
set window 10, 10, 256, 256
set redraw off
for x = 0 to 255
    for y = 0 to 255
        set color x, y, 255 - x
        set pixel x, y
    next
next
redraw
wait keydown

To make it work I need to add wait 100 just before redraw. Should it work like that or is it something wrong? Notice, that wait 10 doesn't make it work properly.


RE: Is redraw working properly? - kcfb - 02-05-2018

(02-04-2018, 09:41 PM)Tomaaz Wrote: The result of this code is a black screen:

Code:
set window 10, 10, 256, 256
set redraw off
for x = 0 to 255
    for y = 0 to 255
        set color x, y, 255 - x
        set pixel x, y
    next
next
redraw
wait keydown

To make it work I need to add wait 100 just before redraw. Should it work like that or is it something wrong? Notice, that wait 10 doesn't make it work properly.

I wonder if this may be computer related as the above code works correctly without modification on both my Windows and Linux laptops. Both laptops are over 5 years old, and therefore slower than some newer hardware. I do not have anything newer to try the code on unfortunately. Regards - Kevin.


RE: Is redraw working properly? - Marcus - 02-05-2018

(02-05-2018, 06:51 AM)kcfb Wrote:
(02-04-2018, 09:41 PM)Tomaaz Wrote: The result of this code is a black screen:

Code:
set window 10, 10, 256, 256
set redraw off
for x = 0 to 255
    for y = 0 to 255
        set color x, y, 255 - x
        set pixel x, y
    next
next
redraw
wait keydown

To make it work I need to add wait 100 just before redraw. Should it work like that or is it something wrong? Notice, that wait 10 doesn't make it work properly.

I wonder if this may be computer related as the above code works correctly without modification on both my Windows and Linux laptops. Both laptops are over 5 years old, and therefore slower than some newer hardware. I do not have anything newer to try the code on unfortunately. Regards - Kevin.

I've seen that behaviour too. On Windows, the content of the window seems to be preserved (by Windows), but on Linux it's not. Even when the code above does work on Linux, if you move another window in front of your running program the content will be gone when you bring the program back to front.

I think what you see is related to that. Maybe there's some delay before the window actually shows and its initial content never gets a chance to be seen.

In a game loop, this is of course not a problem, because you update the window 60 times or so every second.

Maybe I can fix this by blitting the backbuffer to the window every now and then during 'wait' and 'wait keydown', but I'm pretty sure there might be some bad side effects since it's not the expected behaviour.

Gonna have to think some more about this Smile


RE: Is redraw working properly? - Tomaaz - 02-05-2018

I'm pretty sure it's something that happens only in case of very specific code and is easy to avoid. So, no big deal. Just wanted to make sure that everyone is aware of that. Wink And yes - I'm pretty sure too that it may behave differently on different Linux distributions.


RE: Is redraw working properly? - johnno56 - 02-28-2018

I run with Linux Mint (64 bit quad core) and I too received a "black" screen but the wait 100 fixed it... Cool image!

J


RE: Is redraw working properly? - cvirus - 03-01-2018

I run Ubuntu 64bits 16.04 and no modifications needed, the code runs fine without the wait command.


RE: Is redraw working properly? - johnno56 - 03-01-2018

I wonder why the difference? After all Mint as based on Ubuntu... Weird huh?


RE: Is redraw working properly? - Tomaaz - 03-04-2018

Different versions of the kernel and different desktop environments make the difference, IMO.


RE: Is redraw working properly? - Tomaaz - 04-11-2020

A bit of archaeology here.  Big Grin  On 64bit Solus it work without problems.