Reputation: 8529
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
Upvotes: 0
Views: 833
Reputation: 387
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
#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.
Upvotes: 0