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);
Bill Prin
  • 2,498
  • 1
  • 20
  • 27
  • There really is no good answer to this. The simple fact is that (especially for the older hardware) Intel's implementation of OpenGL is fairly poor. About all you can do is avoid using features that don't work. For example, you might be able to capture the other rectangle, then use it as a texture in OpenGL, and blend your rectangle with that. Of course, that might not work either (I seem to recall some problems with blending as well, but they may have been fixed). – Jerry Coffin May 18 '10 at 22:48
  • Yeah, I guess this has to be the case. I was actually developing on one old machine with crappy Intel card for another old machine with a crappy Intel card because mine replicated several issues I was having, and this was the last one that I just couldn't seem to fix. It turns out to be confined to just my test machine though, so I figure it must be a bug and I don't need to worry about it. – Bill Prin May 18 '10 at 23:38

2 Answers2

1

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

Goz
  • 61,365
  • 24
  • 124
  • 204
1

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
  • 1,669
  • 5
  • 22
  • 40
  • 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? – Bill Prin May 19 '10 at 13:34