Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtGui/QGuiApplication>
- #include <QtGui/QImage>
- #include <QtDeclarative/QtDeclarative>
- #include <QtQuick/QtQuick>
- int main(int argc, char *argv[])
- {
- QGuiApplication a(argc, argv);
- QImage logo;
- if (!logo.load("logo.png")) {
- qFatal("Unable to load logo.png.");
- }
- QQuickView *view = new QQuickView();
- view->show();
- view->setClearBeforeRendering(false);
- view->setResizeMode(QQuickView::SizeRootObjectToView);
- view->setSource(QUrl("Test.qml"));
- QObject::connect(view, &QQuickView::beforeRendering, [=]() {
- QOpenGLContext *ctx = QOpenGLContext::currentContext();
- ctx->functions()->glUseProgram(0);
- glClearColor(1, 0, 0, 1);
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- QSGTexture *tex = view->createTextureFromImage(logo);
- tex->bind();
- glBegin(GL_QUADS);
- glTexCoord2i(0, 0);
- glVertex2i(-1, 1);
- glTexCoord2i(0, 1);
- glVertex2i(-1, -1);
- glTexCoord2i(1, 1);
- glVertex2i(1, -1);
- glTexCoord2i(1, 0);
- glVertex2i(1, 1);
- glEnd();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- });
- return a.exec();
- }
Add Comment
Please, Sign In to add comment