Does the Timer returns an actual number?

  • mindu
  • Topic Author
More
8 years 2 days ago - 8 years 2 days ago #1 by mindu Does the Timer returns an actual number? was created by mindu
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: 8 years 2 days ago by mindu.

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 2 days ago #2 by crosire Replied by crosire on topic Does the Timer returns an actual number?
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) ...
The following user(s) said Thank You: mindu

Please Log in or Create an account to join the conversation.

  • mindu
  • Topic Author
More
7 years 10 months ago - 7 years 10 months ago #3 by mindu Replied by mindu on topic Does the Timer returns an actual number?
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: 7 years 10 months ago by mindu.

Please Log in or Create an account to join the conversation.

  • crosire
More
7 years 10 months ago - 7 years 10 months ago #4 by crosire Replied by crosire on topic Does the Timer returns an actual number?
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()
{
}
Last edit: 7 years 10 months ago by crosire.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.