Welcome, Guest.
Username: Password: Remember me

TOPIC: Does the Timer returns an actual number?

Does the Timer returns an actual number? 7 months 3 weeks ago #1

  • mindu
  • mindu's Avatar
  • Offline
  • Posts: 54
or it is just "something" changing its value every millisecond? I'm trying to use it like an actual number, for example:
#if ( Timer > 100 ) { whatever; }
and it doesn't makes any difference if I set 0, 100 or 10000, it looks like the timer is not the actual number it shows in the info provided in reshade showstatistics, or am I doing something wrong?

before you ask of course is set up before calling it
uniform float Timer < source = "timer"; >;
Last Edit: 7 months 3 weeks ago by mindu.
The administrator has disabled public write access.

Does the Timer returns an actual number? 7 months 3 weeks ago #2

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2453
  • Thank you received: 1393
It does. But:
#if ( Timer > 100 ) { whatever; }
does not make sense. You are using the preprocessor here ("#if"), which attempts to evaluate that condition before compilation, but cannot find a "Timer" macro. "Timer" is a variable afterall, something the compiler parses, but the preprocessor runs before that. Now it is defined behavior what happens when the preprocessor comes across an identifier it cannot resolve: It acts like it was replaced with a zero. So the preprocessor now reads this:
#if ( 0 > 100 ) ...
Which is obviously false and thus skips entire code block up to the next "#endif".

If you want to make use of the "Timer" variable, use the actual "if" statement:
if (Timer > 100) ...
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: mindu

Does the Timer returns an actual number? 6 months 2 weeks ago #3

  • mindu
  • mindu's Avatar
  • Offline
  • Posts: 54
Excuse me but I'm new with shader language... if I write the usual if(...){...} I always get syntax error unexpected 'if' .... what are the rules to use?
Last Edit: 6 months 2 weeks ago by mindu.
The administrator has disabled public write access.

Does the Timer returns an actual number? 6 months 2 weeks ago #4

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2453
  • Thank you received: 1393
You can only use statements like "if" inside executable statement blocks aka inside functions. Not in the global scope (the compiler wouldn't know when and how to deal with the if there).

Valid:
void test()
{
    if (...) { ... }
}
Invalid:
if (...) { ... }
void test()
{
}
Cheers, crosire =)
Last Edit: 6 months 2 weeks ago by crosire.
The administrator has disabled public write access.