我一定不明白glPolygonStipple
位的排列。我认为这是一个简单的 32x32 位掩码。因此,如果我可以使用unsigned int
每行。例如,这段代码(如预期的那样)产生了一个粗垂直条纹:
static unsigned int halftone[32];
for(static bool once = true;once;once=false)
{
for(int r = 0;r<32;r++)
{
halftone[r] = 65535;
}
}
生产:
static unsigned int halftone[32];
for(static bool once = true;once;once=false)
{
halftone[0] = 65535;
for(int r = 1;r<32;r++)
{
halftone[r] = rol(halftone[r-1]);
}
}
哪里rol
是循环位移:
template <typename INT>
constexpr INT rol(INT val) {
static_assert(std::is_unsigned<INT>::value,
"Rotate Left only makes sense for unsigned types");
return (val << 1) | (val >> (sizeof(INT)*CHAR_BIT-1));
}
我可以通过添加一个cout<<bitset<32>(halftone[r])<<endl;
我得到正确的模式来验证:
00000000000000001111111111111111
00000000000000011111111111111110
00000000000000111111111111111100
00000000000001111111111111111000
00000000000011111111111111110000
00000000000111111111111111100000
00000000001111111111111111000000
00000000011111111111111110000000
00000000111111111111111100000000
00000001111111111111111000000000
00000011111111111111110000000000
00000111111111111111100000000000
00001111111111111111000000000000
00011111111111111110000000000000
00111111111111111100000000000000
01111111111111111000000000000000
11111111111111110000000000000000
11111111111111100000000000000001
11111111111111000000000000000011
11111111111110000000000000000111
11111111111100000000000000001111
11111111111000000000000000011111
11111111110000000000000000111111
11111111100000000000000001111111
11111111000000000000000011111111
11111110000000000000000111111111
11111100000000000000001111111111
11111000000000000000011111111111
11110000000000000000111111111111
11100000000000000001111111111111
11000000000000000011111111111111
10000000000000000111111111111111
但是 OpenGL 正在产生:
GLubyte
当我传递给时,我将数组指针转换为glPolygonStipple
glPolygonStipple((GLubyte*)halftone);
我的理解有问题吗?这与某些glPixelStore
问题有关吗?