开发者

OpenGL polygon stipple

i'm wondering how a array of 32x32 is mapped to a bitmap. The following arrays represents a bitmap. I know that each row of the array represents row of the bitmap. The first row of the array is the last row of the bitmap, and so on, up to the last row of the array that is the first row of the bitmap, but how this works?

GLubyte myInitial[] = {
    0xff, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
    0xff, 0x01, 0xff, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x0开发者_JAVA百科1,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01,
    0xff, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,};


That stipple pattern isn't formatted that well. It should look like this:

0xff, 0x01, 0x00, 0x01,  // #########               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0x00, 0x01, 0x00, 0x01,  //         #               #       
0xff, 0x01, 0xff, 0x01,  // #########       #########       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0x00, 0x01, 0x01, 0x01,  //         #       #       #       
0xff, 0x00, 0xFF, 0x01,  // ########         ########       
0x00, 0x00, 0x00, 0x00,  //
0x00, 0x00, 0x00, 0x00,  //
0x00, 0x00, 0x00, 0x00   //

That is a 32x32 1-bit-per-pixel bitmap. As you can see, if you were to draw a 32x32 pixel screen quad in white on a black background it would render PE.


Each input byte consists of 8 bits. While rendering the pattern is tiled across the triangle surface. Wherever the pattern has a 1 bit the pixel will be drawn.

See the documentation, as well as an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜