Qt 浏览器应用程序与 opengl-es2 奇怪的行为(不工作)

发布于 2024-12-07 23:23:02 字数 1022 浏览 1 评论 0原文

我已经在 Qt/E 中启用了 opengl-es2 支持,我想制作一个浏览器应用程序,代码是:

int main(int argc, char *argv[]) {

QApplication a(argc, argv);

QGraphicsView g;
g.setScene(new QGraphicsScene(&g));
g.scene()->setItemIndexMethod(QGraphicsScene::NoIndex);

g.setAttribute(Qt::WA_DeleteOnClose);
g.setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
g.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
g.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
g.setAlignment(Qt::AlignTop | Qt::AlignHCenter);
g.setFrameStyle(QFrame::NoFrame);
g.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

g.setViewport(new QGLWidget());
g.showFullScreen();

QGraphicsWebView view;

view.load(QUrl("http://www.google.com"));
view.setGeometry(QRectF(0,0,800,400));
view.show();

g.scene()->addItem(&view);

a.exec();

}

我可以看到谷歌页面加载了几分之一秒,然后就消失了。

错误日志粘贴-bin链接==> http://pastebin.com/bgbQqd1M

I have enabled opengl-es2 support in Qt/E and I wanted to make a browser app and the code is :

int main(int argc, char *argv[])
{

QApplication a(argc, argv);

QGraphicsView g;
g.setScene(new QGraphicsScene(&g));
g.scene()->setItemIndexMethod(QGraphicsScene::NoIndex);

g.setAttribute(Qt::WA_DeleteOnClose);
g.setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
g.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
g.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
g.setAlignment(Qt::AlignTop | Qt::AlignHCenter);
g.setFrameStyle(QFrame::NoFrame);
g.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

g.setViewport(new QGLWidget());
g.showFullScreen();

QGraphicsWebView view;

view.load(QUrl("http://www.google.com"));
view.setGeometry(QRectF(0,0,800,400));
view.show();

g.scene()->addItem(&view);

a.exec();

}

I can see google page getting loaded for a fraction of second and then after it disappears.

Error log paste-bin link ==> http://pastebin.com/bgbQqd1M

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

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

发布评论

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

评论(1

丶情人眼里出诗心の 2024-12-14 23:23:02

Ashish,

您对eglfs平台插件做了哪些更改?
我还修改了eglfs插件以使其在arm板上运行。

我更改的两个地方是:

  1. 避免调用eglMakeCurrent两次,当EGLDisplay、EGLSurface(Read)、EGLSurface(Draw)、EGLDisplay不改变时---在我的板上,调用eglMakeCurrent两次将导致程序中止。

  2. 问题与您相同(QGLShader::QGLShader: 'context' 必须是当前上下文或与之共享。)

    在QtOpengl库中,有一个函数QGLWidget* qt_gl_share_widget(),它将创建一个新的QGLContext并将其设置为QPlatformGLContext。

    在bool QGLShaderProgram::bind()中,它将检查当前上下文与QGLSharedResourceGuard中的上下文。 QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext())。

为了解决这个问题。
我在 qeglplatformcontext.cpp 中添加以下代码

#include <QGLContext>

class QEGLFSContext : public QGLContext
{
public:
    bool chooseContext(const QGLContext* shareContext = 0)
    {
        QGLContext::chooseContext(shareContext);   // in QGLContext, this guy is protected
    }
};

void QEGLPlatformContext::makeCurrent()
{
    QPlatformGLContext::makeCurrent();
    QGLContext * ctx = QGLContext::fromPlatformGLContext(this);
    QEGLFSContext* eglctx = (QEGLFSContext*)ctx;
    static QEGLFSContext * s_ctx = eglctx;
    if (s_ctx != eglctx)
    {
        s_ctx->chooseContext();
    }
    //...
}

使用这些更改后,我可以运行 hellogl_es2 并显示动画以很好地显示 Qt 徽标和气泡。

但我仍然有一些问题:
QLabel、QMenu...无法显示。

您对这个问题有什么想法吗?
我也从一些人那里得到了一些想法,qws/simplegl也有这些问题。

Ashish,

What changes did you make for eglfs platform plug-in?
I also modified eglfs plugin to make it run on an arm board.

Two place that I changed are:

  1. avoid call eglMakeCurrent twice, when EGLDisplay, EGLSurface(Read), EGLSurface(Draw), EGLDisplay not change --- On my board, call eglMakeCurrent twice will cause the program abort.

  2. The problem is same as you (QGLShader::QGLShader: 'context' must be the current context or sharing with it.)

    In QtOpengl library, there is a function QGLWidget* qt_gl_share_widget(), that will create a new QGLContext and set it to QPlatformGLContext.

    In bool QGLShaderProgram::bind(), it will check the currentContext with the one in QGLSharedResourceGuard. QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext()).

To fix this problem.
I add the following code in qeglplatformcontext.cpp

#include <QGLContext>

class QEGLFSContext : public QGLContext
{
public:
    bool chooseContext(const QGLContext* shareContext = 0)
    {
        QGLContext::chooseContext(shareContext);   // in QGLContext, this guy is protected
    }
};

void QEGLPlatformContext::makeCurrent()
{
    QPlatformGLContext::makeCurrent();
    QGLContext * ctx = QGLContext::fromPlatformGLContext(this);
    QEGLFSContext* eglctx = (QEGLFSContext*)ctx;
    static QEGLFSContext * s_ctx = eglctx;
    if (s_ctx != eglctx)
    {
        s_ctx->chooseContext();
    }
    //...
}

After use these change, I can run hellogl_es2 and show the animation for show the Qt logo and bubbles well.

But I still have some problem:
QLabel, QMenu... can not show.

Do you have any idea about this problem.
I also got some idea from some guy, qws/simplegl also have these problem.

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