问题描述
screen = SDL_SetVideoMode(1000,1000,32, SDL_HWSURFACE | SDL_FULLSCREEN);
|
c $ c> SDL_HWSURFACE | SDL_FULLSCREEN ? (我试过谷歌这个,但google不接受特殊字符..)
What does the |
do in SDL_HWSURFACE | SDL_FULLSCREEN
? (I tried googling this but google wont accept special characters..)
推荐答案
其他答案解释说,您可能想知道它是如何工作的:
The other answers have explained it's a bitwise OR, but you probably want to know how that works:
标志以二进制数形式传递,如00001000或01000000,每个位表示一个单独的标志。所以第一位(0)表示HW_SURFACE关闭,第二位(1)表示FULLSCREEN打开。 (注意这些是例子,我不知道实际的位。)
The flags are passed as a binary number, like 00001000 or 01000000, and each bit represents an individual flag. So the first bit (0) means HW_SURFACE is off, and the second bit (1) means FULLSCREEN is on. (Note that these are examples, I'm not sure about the actual bits.)
所以,按位OR函数是通过比较每个位和说这是位还是这位1?如果任何一个为1,它将结果设置为1.这将提供结果01001000,可以由SDL解析设置相应的标志。
So what the bitwise OR function does is combine those two flags by comparing each bit and saying "Is this bit OR this bit 1?" and if either is 1, it will set the result to 1. This will provide the result 01001000 which can be parsed by SDL to set the appropriate flags.
这篇关于C ++ SDL什么是|做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!