mirrorman:
quote:
Can anyone tell me why the bitwise-OR operator | is used in statements such as:
// Set the cooperative level
hRet = G.lpDD->SetCooperativeLevel(G.hWnd, DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN);
DDSCL_EXCLUSIVE and DDSCL_FULLSCREEN are flags which can be added together to get a new flag that contains all the information from the original flags.
I don''t know specifically what bits are set in these flags, so I''ll use a simple example.
Suppose that variable A = 0000 0001 and variable B = 0000 0010 (I''ve separated each byte into two ''nibbles'' for better readability).
Then, C = A | B = (0000 0001) | (0000 0010) = (0000 0011)
As you can see, the variable C = (0000 0011) now contains the information (ie, the set bits) from variables A and B.