openglpolygonstipple

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, 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,};

Solution

  • 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.