Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is redraw working properly?
#1
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.
Reply
#2
(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.
Reply
#3
(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
Reply
#4
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)