Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Can you use integers as bools in HLSL just like in C++?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 14 October 2012 - 04:00 PM

In C++ you can have:

int a = 5;
if(a)
{
for(int i = 0;i < a: i++)
{
DoSomething();
}
}

Can you do the same in HLSL?If you could,it would be really convenient to both check if an effect is enabled to begin with and to serve as a parameter to the said effect.

Sponsor:

#2 Daniel_RT   Members   -  Reputation: 478

Like
0Likes
Like

Posted 14 October 2012 - 05:20 PM

Anything that isn't null is true. I still don't understand why you'd want to do that.

#3 MJP   Moderators   -  Reputation: 11786

Like
0Likes
Like

Posted 14 October 2012 - 09:44 PM

There is no such thing as "null" in HLSL. Integers used as conditionals work similarly to how they do in C/C++, where non-zero values equate to a value of "true".

#4 Muzzy A   Members   -  Reputation: 694

Like
0Likes
Like

Posted 14 October 2012 - 10:12 PM

In C++ you can have:


int a = 5;
if(a)
{
for(int i = 0;i < a: i++)
{
DoSomething();
}
}

Can you do the same in HLSL?If you could,it would be really convenient to both check if an effect is enabled to begin with and to serve as a parameter to the said effect.


it works perfectly, but i would still do the additional

if(a != 0)
// readability

#5 Daniel_RT   Members   -  Reputation: 478

Like
0Likes
Like

Posted 15 October 2012 - 03:23 AM

null = 0, you know what I meant.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS