views:

42

answers:

2

I have a situation where I am trying to draw a semi-transparent rectangle over a background that is not using openGL and so I can not use blending. I decided to use polygon stippling for a 'screen door transparency' effect as recommended by some. It works fine on my machine and some others, but on some machines with slightly old Intel graphics cards it's failing to render the rectangle at all. If I turn off polygon stipple, it renders fine (but without the stipple). I have compared many of the state variables that I thought might affect it (see code) between machines and they are all the same, and I get no errors.

static const GLubyte stipplePatternChkr[128];  //definition omitted for clarity
                                               //but works on my machine

 // stipple the box
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        glColor4ubv(Color(COLORREF_PADGRAY));
    glEnable(GL_POLYGON_STIPPLE);
    glPolygonStipple(stipplePatternChkr);
        CRect rcStipple(dim);
        rcStipple.DeflateRect(padding - 1, padding - 1);
        glBegin(GL_QUADS);
            glVertex2i(rcStipple.left, rcStipple.bottom);
            glVertex2i(rcStipple.right, rcStipple.bottom);
            glVertex2i(rcStipple.right, rcStipple.top);
            glVertex2i(rcStipple.left, rcStipple.top);
        glEnd();
    glDisable(GL_POLYGON_STIPPLE);  

       int err = glGetError();
       if (err != GL_NO_ERROR) {
        TRACE("glError(%s: %s)\n", s, gluErrorString(err));
       }

    float x;
    glGetFloatv(GL_UNPACK_ALIGNMENT, &x);
    TRACE("unpack alignment %f\n", x);
    glGetFloatv(GL_UNPACK_IMAGE_HEIGHT, &x);
    TRACE("unpack height %f\n", x);
    glGetFloatv(GL_UNPACK_LSB_FIRST, &x);
    TRACE("unpack lsb %f\n", x);
    glGetFloatv(GL_UNPACK_ROW_LENGTH, &x);
    TRACE("unpack length %f\n", x);
    glGetFloatv(GL_UNPACK_SKIP_PIXELS, &x);
    TRACE("upnack skip %f\n", x);
    glGetFloatv(GL_UNPACK_SWAP_BYTES, &x);
    TRACE("upnack swap %f\n", x);
+1  A: 

Try applying a stippled texture to the polygon with filtering turned off.

Goz
Thanks I will give this a try.
FranticPedantic
+1  A: 

This is fairly simple if you use frame buffers. Create a frame buffer and draw on it. Now in it you have a texture with RGBA information. Get that texture's pixel data into a array on CPU and use that background's draw commands to draw the image. This way you can preserver alpha information for any scene.
The problem is that it might not be just as fast as other more overhead sollutions.

Sanctus2099
This sounds a little complicated but I will investigate. By frame buffers do you mean frame buffer objects? Wouldn't I need it to support an extension it may not support?
FranticPedantic