just do "if (Mode & MODE1)" without the " == MODE1" part. So the first if statement would look like this:
if (Mode & MODE1)
{cout << "Mode 1 ";}
and you would modify the rest of them accordingly.
Very, very simple/stupid question...
Turt99, I use a char, because I only need 8 modes, but there''s nothing like ''byte'' that MSVC++ used exept an unsigned char.
If I want to use mode 1 and 3 this is how I would enable them:
Ofcourse it''s a stupid example, but it''s a lot clearer than posting my program...
Thanx, Marty
If I want to use mode 1 and 3 this is how I would enable them:
0: Mode = 0;1: Mode = (Mode | MODE1);2: Mode = (Mode | MODE3)this is what should happen with Mode''s bits:0: 000000001: 000000012: 00000101that''s a 5, right?Then what this program should do: if (Mode&MODE1 = MODE1) bits: if (00000101 & 00000001 = 00000001) if (Mode&MODE2 = MODE2)bits: if (00000101 & 00000010 = 00000010) if (Mode&MODE3 = MODE3)bits: if (00000101 & 00000100 = 00000100) if (Mode&MODE4 = MODE4)bits: if (00000101 & 00001000 = 00001000)etc.so that is true, false, true, falseAnd it should write: "Mode1 Mode2 Mode3 Mode4 "
Ofcourse it''s a stupid example, but it''s a lot clearer than posting my program...
Thanx, Marty
_____ /____ /|| | || MtY | ||_____|/Marty
March 19, 2003 01:07 PM
I think the level of the questions gets very very low lately. This is more like read a C book.
This question has nothing to do with OpenGL anyway.
Is this newsgroup moderated by someone?
This question has nothing to do with OpenGL anyway.
Is this newsgroup moderated by someone?
Ahhh, I see, Makes sence to me now, and with out the equals in the if statement I can see how it works, if none of the bits match then it would return 00000000 which is 0 or false
Interesting
Interesting
Your if statement
>if (Mode & MODE1 == MODE1)
Does not function like you would expect. The == operator takes priority over the & operator. So your == condition will be checked first and it''ll return true. Now your variable Mode is checked for != 0 and that returns true as well.
Your if statement should read as follows:
if ((Mode & MODE1) == MODE1)
And because you only work with flags you can remove the == MODE1, resulting in:
if (Mode & MODE1)
This should work.
Lyve
_____________________________________
Visit http://www.nilsschneider.de for finest trance music, studio, bio, guestbook and more!
>if (Mode & MODE1 == MODE1)
Does not function like you would expect. The == operator takes priority over the & operator. So your == condition will be checked first and it''ll return true. Now your variable Mode is checked for != 0 and that returns true as well.
Your if statement should read as follows:
if ((Mode & MODE1) == MODE1)
And because you only work with flags you can remove the == MODE1, resulting in:
if (Mode & MODE1)
This should work.
Lyve
_____________________________________
Visit http://www.nilsschneider.de for finest trance music, studio, bio, guestbook and more!
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.
Here''s an idea. When you''re in your development environment, hit F1. This will bring up something called help. READ IT. Now, buy a book on C++. READ IT. Then, when you get an error message like ''missing ; after )'', you''ll be informed enough to find a ) that is missing the ;
Have a nice day!
CMNSNS - GO USA!!!!
Have a nice day!
CMNSNS - GO USA!!!!
CMNSNS - GO USA!!!!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement