问题描述
我想知道glcolor3b()
和glcolor3ub()
之间的区别是什么.
I was wondering what the difference is between glcolor3b()
and glcolor3ub()
.
似乎glcolor3b(255, 0, 0);
并未将颜色设置为红色,而是将其设置为黑色. glcolor3b(48, 160, 64)
将其设置为深紫色,而不是绿色. glcolor3ub()
,但是按预期工作.
此外, 和 glcolor3ub()
完全相同,除了"u":
It appears that glcolor3b(255, 0, 0);
does not set the color to red, but rather it sets it to black. glcolor3b(48, 160, 64)
sets it to dark purple, not green. glcolor3ub()
, however works as expected.
Additionally, the documentation for glcolor3b()
and glcolor3ub()
are exactly the same, except for the "u":
public static void glColor3(u)b(byte red,
byte green,
byte blue)
有人知道这是为什么吗?
Does anybody know why this is?
推荐答案
glColor3b()
采用字节参数,范围从 -128 到 127 .glColor3ub()
采用无符号字节参数,范围从 0 到 255 .在glColor3b()
中使用大于127的值会导致算术溢出.
glColor3b()
takes byte parameters with a range from -128 to 127.glColor3ub()
takes unsigned byte parameters with a range from 0 to 255.Using values greater than 127 with glColor3b()
leads to an arithmetic overflow.
这篇关于glcolor3b和glcolor3ub之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!