Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用glPolygonStipple创建一条粗对角线条纹?_C++_Opengl_Dithering_Stipple - Fatal编程技术网

C++ 如何使用glPolygonStipple创建一条粗对角线条纹?

C++ 如何使用glPolygonStipple创建一条粗对角线条纹?,c++,opengl,dithering,stipple,C++,Opengl,Dithering,Stipple,我一定不能理解glPolygonStipple位的排列。我以为它是一个简单的32x32位掩码。因此,如果我可以每行使用无符号int。例如,此代码生成(如预期的)厚垂直条纹: static unsigned int halftone[32]; for(static bool once = true;once;once=false) { for(int r = 0;r<32;r++) { halftone[r] = 65535; } } 我

我一定不能理解
glPolygonStipple
位的排列。我以为它是一个简单的32x32位掩码。因此,如果我可以每行使用
无符号int
。例如,此代码生成(如预期的)厚垂直条纹:

  static unsigned int halftone[32];
  for(static bool once = true;once;once=false)
  {
    for(int r = 0;r<32;r++)
    {
      halftone[r] = 65535;
    }
  }

我可以通过添加
cout来验证32位值中的字节是否相对于OpenGL对掩码的期望进行了交换

字节顺序由
GL\u UNPACK\u LSB\u FIRST
pixels store参数控制,默认情况下该参数为
GL\u FALSE
。由于LSB首先出现在一台小型endian机器上,这很可能就是您正在使用的机器,所以这是向后的

您可以通过更改值来修复它:

glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
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));
}
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
glPolygonStipple((GLubyte*)halftone);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);