Qt 浏览器应用程序与 opengl-es2 奇怪的行为(不工作)
我已经在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ashish,
您对eglfs平台插件做了哪些更改?
我还修改了eglfs插件以使其在arm板上运行。
我更改的两个地方是:
避免调用eglMakeCurrent两次,当EGLDisplay、EGLSurface(Read)、EGLSurface(Draw)、EGLDisplay不改变时---在我的板上,调用eglMakeCurrent两次将导致程序中止。
问题与您相同(QGLShader::QGLShader: 'context' 必须是当前上下文或与之共享。)
在QtOpengl库中,有一个函数QGLWidget* qt_gl_share_widget(),它将创建一个新的QGLContext并将其设置为QPlatformGLContext。
在bool QGLShaderProgram::bind()中,它将检查当前上下文与QGLSharedResourceGuard中的上下文。 QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext())。
为了解决这个问题。
我在 qeglplatformcontext.cpp 中添加以下代码
使用这些更改后,我可以运行 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:
avoid call eglMakeCurrent twice, when EGLDisplay, EGLSurface(Read), EGLSurface(Draw), EGLDisplay not change --- On my board, call eglMakeCurrent twice will cause the program abort.
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
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.