OpenGL 多边形点画无法在不同的机器上工作

发布于 2024-09-02 05:03:48 字数 1619 浏览 2 评论 0原文

我遇到一种情况,我试图在不使用 openGL 的背景上绘制半透明矩形,因此我无法使用混合。我决定按照一些人的建议使用多边形点画来实现“纱门透明”效果。它在我的机器和其他一些机器上运行良好,但在某些具有稍微旧的英特尔显卡的机器上,它根本无法渲染矩形。如果我关闭多边形点画,它会渲染得很好(但没有点画)。我比较了许多我认为可能会影响机器之间的状态变量(参见代码),它们都是相同的,并且我没有收到任何错误。

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);

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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

意中人 2024-09-09 05:03:48

尝试在关闭过滤的情况下将点画纹理应用于多边形。

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

别再吹冷风 2024-09-09 05:03:48

如果您使用帧缓冲区,这相当简单。
创建一个帧缓冲区并在其上绘图。现在你已经有了一个带有 RGBA 信息的纹理。将该纹理的像素数据放入 CPU 上的数组中,并使用该背景的绘制命令来绘制图像。这样您就可以保留任何场景的 Alpha 信息。
问题是它可能不如其他开销更大的解决方案那么快。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文