纹理在 Intel 芯片组上的 C# opengl/Tao 中无法工作

发布于 2024-07-27 13:46:59 字数 2281 浏览 2 评论 0原文

我在 C# .NET 3.5 sp1 应用程序中有很多 OpenGL 渲染代码。 一些代码可以在这个问题中找到。

巨大的问题:代码根本无法在英特尔芯片组上运行,例如 915M 或 Q35。 这些芯片组的规格是运行 opengl 1.4,我的代码都是 2 的幂,等等。 我已尝试更新到戴尔或英特尔的最新驱动程序,具体取决于机器。

崩溃失败有两种类型:

  1. glActiveTextureARB 失败。 915M 显然不将其包含在其扩展中。
  2. 着色器加载失败,即 glGenProgramsARB。

尝试在 XP 中的 915M 或 Windows 7 中的 Q35 上调用这些函数会导致冻结或崩溃,具体取决于机器当前的情况。

还有另一个更严重的故障,那就是显示器没有解决前面的问题,即,渲染的显示器看起来像是显示 8 位数据,而实际上应该显示 16 位数据。这种情况发生在 Q35 芯片组、最新的戴尔驱动程序、运行 XP 的系统上。

对此有什么想法吗? 我正在考虑回到 glDrawPixels,因为即使它很慢,它也能工作。

编辑:更多代码! 以下代码在使用 Q35 芯片组的 Windows XP 和 Windows 7 计算机上失败并出现 GL_INVALID_VALUE 错误:

    const int mSize = 256;
    ushort[] theImage = new ushort[mSize * mSize];
...
 //datasetup
        int x, y, i = 0 ;
        for (x = 0; x < mSize; x++) {
            for (y = 0; y < mSize; y++) {
                theImage[(y * mSize) + x] =  (ushort)i++;
            }
        }
...
 //onpaint
        int theTexName;
        Gl.glGenTextures(1, out theTexName);
        Gl.glBindTexture(Gl.GL_TEXTURE_2D, theTexName);
        Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_LUMINANCE16, mSize, mSize,
            0, Gl.GL_LUMINANCE, Gl.GL_UNSIGNED_SHORT, theImage);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
        //theMagBuffer = null;


        Gl.glDisable(Gl.GL_BLEND);


        Gl.glEnable(Gl.GL_TEXTURE_2D);
        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL);
        Gl.glColor4d(1.0, 1.0, 1.0, 1.0);
        Gl.glPushMatrix();

        Gl.glBindTexture(Gl.GL_TEXTURE_2D, theTexName);
        Gl.glBegin(Gl.GL_QUADS);
        Gl.glTexCoord2f(0, 1);
        Gl.glVertex2f(0, mSize);
        Gl.glTexCoord2f(0, 0);
        Gl.glVertex2f(0, 0);
        Gl.glTexCoord2f(1, 0);
        Gl.glVertex2f(mSize, 0);
        Gl.glTexCoord2f(1, 1);
        Gl.glVertex2f(mSize, mSize);
        Gl.glEnd();

        Gl.glDisable(Gl.GL_TEXTURE_2D);
        Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB);

        Gl.glPopMatrix();
        GetGLError("MAG");
        Gl.glFinish();

I've got a lot of OpenGl rendering code in a C# .NET 3.5 sp1 application. Some of the code can be found in this question.

Huge problem: The code is not running at all on intel chipsets, such as the 915M or the Q35. These chipsets are spec'd to run opengl 1.4, and my code is all power-of-two nice and so forth. I've tried updating to the latest drivers from either Dell or Intel, depending on the machine.

There are two types of crash failures:

  1. Failing on glActiveTextureARB. 915M apparently does not include that in its extensions.
  2. Failing on shader loading, namely glGenProgramsARB.

Trying to call these functions on the 915M in XP or the Q35 on Windows 7 causes either a freeze or a crash, depending on what the machine is feeling like at the moment.

There's another worse failure, and that's that the display is not fixing that previous question, ie, the rendered display looks like it's showing 8 bit data when it should be showing 16. That's happening on the Q35 chipset, latest dell drivers, running XP.

Any thoughts on this? I'm considering going back to glDrawPixels, because even while that's slow, it works.

EDIT: more code! The following code fails with an GL_INVALID_VALUE error on both a windows xp a windows 7 machine with the Q35 chipset:

    const int mSize = 256;
    ushort[] theImage = new ushort[mSize * mSize];
...
 //datasetup
        int x, y, i = 0 ;
        for (x = 0; x < mSize; x++) {
            for (y = 0; y < mSize; y++) {
                theImage[(y * mSize) + x] =  (ushort)i++;
            }
        }
...
 //onpaint
        int theTexName;
        Gl.glGenTextures(1, out theTexName);
        Gl.glBindTexture(Gl.GL_TEXTURE_2D, theTexName);
        Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_LUMINANCE16, mSize, mSize,
            0, Gl.GL_LUMINANCE, Gl.GL_UNSIGNED_SHORT, theImage);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
        //theMagBuffer = null;


        Gl.glDisable(Gl.GL_BLEND);


        Gl.glEnable(Gl.GL_TEXTURE_2D);
        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL);
        Gl.glColor4d(1.0, 1.0, 1.0, 1.0);
        Gl.glPushMatrix();

        Gl.glBindTexture(Gl.GL_TEXTURE_2D, theTexName);
        Gl.glBegin(Gl.GL_QUADS);
        Gl.glTexCoord2f(0, 1);
        Gl.glVertex2f(0, mSize);
        Gl.glTexCoord2f(0, 0);
        Gl.glVertex2f(0, 0);
        Gl.glTexCoord2f(1, 0);
        Gl.glVertex2f(mSize, 0);
        Gl.glTexCoord2f(1, 1);
        Gl.glVertex2f(mSize, mSize);
        Gl.glEnd();

        Gl.glDisable(Gl.GL_TEXTURE_2D);
        Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB);

        Gl.glPopMatrix();
        GetGLError("MAG");
        Gl.glFinish();

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

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

发布评论

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

评论(1

夕色琉璃 2024-08-03 13:46:59

干杯,

遗憾的是,您对崩溃无能为力,这些芯片组似乎不支持有问题的扩展。 您的应用程序与它们不兼容,故事结束。 为了确保这一点,请使用 glGetString(GL_EXTENSIONS) 来查看有哪些扩展。 您甚至可以在应用程序启动时执行此操作,并显示一个漂亮的消息框,告诉用户硬件不支持运行所需的某些扩展,而不仅仅是崩溃。

至于8位/16位问题,使用LUMINANCE16并不能真正保证将使用16位纹理,许多驱动程序使用8位纹理“模拟”这种格式而不告诉你。 这是用来提高兼容性的,尽管它很烦人。

如果您想要真正的 16 位,请使用 8 位 LUIMNANCE_ALPHA ,它应该在任何地方都受支持,并将两个 8 位组件打包到着色器内的单个数字中。

Cheers,

sadly, you cannot do anything about the crashes, it seems like the extensions in question are not supported on those chipsets. Your app is not compatible with them, end of story. Just to make sure, use glGetString(GL_EXTENSIONS) to see what extensions are there. You can even do that in your application on startup and display a nice message box telling the user that some extensions that are required to run are not supported by the hardware, instead of just crashing.

As for the 8bit / 16bit question, using LUMINANCE16 doesn't really guarantee that 16 bit texture will be used, many drivers "emulate" this format using 8 bit textures without telling you. This is used to improve compatibility, as annoying as it is.

If you want true 16 bit, use 8 bit LUIMNANCE_ALPHA which should be suported pretty much anywhere and pack the two 8 bit components to a single number inside shader.

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