Old 08-18-2019, 11:51 AM   #1
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default JSFX: variable value not printed by gfx_printf

Here's a mystery:



The sprintf is using the correct value for timespan. But the gfx_printf is not - the displayed value is the previous value of timespan (changed by mousewheel-scrolling over the button).

gfx_printf("%s",#time) does not update it either.

Any ideas?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 08-19-2019 at 03:23 AM.
DarkStar is offline   Reply With Quote
Old 08-20-2019, 11:29 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Strange. Perhaps it's because the gfx runs in a separate thread? Something could be changing the value between the execution of the two print statements?
IXix is offline   Reply With Quote
Old 08-22-2019, 02:10 AM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

But both printf statements are in @gfx, so I'd guess they are both executed from the GUI thread.

Anyway, I've tried to isolate the issue, but I was unsuccessful i.e. this seems to work fine:

Code:
desc:Left-click to increase timepan

@gfx

lmb = mouse_cap & 1;
lmb && !old_lmb ? timespan += 1;
old_lmb = lmb;

gfx_r = gfx_g = gfx_b = gfx_a = 1;
gfx_x = gfx_y = 8;
sprintf(#time, "%02d", timespan);
gfx_printf("%02d", timespan);
Tale is offline   Reply With Quote
Old 08-22-2019, 03:58 AM   #4
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by Tale View Post
But both printf statements are in @gfx, so I'd guess they are both executed from the GUI thread.
I mean the value of timespan could be changed by the audio thread inbetween the execution of the two calls in the gfx thread. Can't think of any other reason why those two calls wouldn't produce the same output.


The atomic functions were added to cover that kind of thing so they might be worth a try if DS still has the problem.
IXix is offline   Reply With Quote
Old 08-22-2019, 04:01 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

It could even be an actual JSFX bug. It's certainly very wrong.
IXix is offline   Reply With Quote
Old 08-22-2019, 04:55 AM   #6
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
Default

Problem solved. My mistake

The only place where "timespan" is changed is also in @gfx. But, part of handling that change was switching to an off-screen buffer to redraw a grid based on the timespan. And I did not switch back to the main screen until later. So my "gfx_prinf()" above was going into the off-screen buffer.

When I added the missing "gfx_dest =-1;" the problem was resolved.

Sorry for wasting your time.
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-22-2019, 06:07 AM   #7
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by DarkStar View Post
Sorry for wasting your time.
Well, it resulted in you finding/fixing the problem, so I wouldn't consider my time wasted.
Tale is offline   Reply With Quote
Old 08-23-2019, 01:21 AM   #8
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by DarkStar View Post
Sorry for wasting your time.
I like a good mystery.
IXix is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.