Debugging OpenGL in a QQuickItem custom drawing environment
-
Hey there. I have a custom QQuickItem that hooks up a custom renderer to the afterRendering signal to do some fancy OpenGL work. (Which I'm having a ball of a time doing by the way; so many useful little Qt classes, it's great in here!)
The problem I'm stumped on though, is that I'm filling a relatively weird little QOpenGLTexture::R16_SNorm texture with some custom data, and while it's working perfectly on a Windows 7 machine, I'm getting absolutely nothing on a Macbook. No errors or warnings, just a black texture when I go to look it up.
I'm looking to get more information about what's happening, so I'm trying to instantiate a QOpenGLDebugLogger. Unfortunately, as I don't have access to the code that creates the OpenGL context, I can't set the debug flag, and the logger's initialize function fails. Does anyone know, for a QQmlApplicationEngine based application, where I might set that flag?
Thanks!
-
Is it using a compatible OpenGL context? On OS X there is no compatibility profile and you can't share between a core profile for your custom renderer and Qt Quick 2's default context which is OpenGL 2.1. You can request a newer OpenGL version to be used by Qt QUick 2 by calling setFormat() in the ctor of your QQuickView subclass. In there you can for example request an OpenGL 3.2 Core (or 4.1 Core if you hw supports it) context. You may have more luck with that if you're using a renderer that uses the newer core profile contexts.
Failing that, apitrace may give you some hints.
-
Not necessarily, that's a valid approach too but the same problem may occur. By default QQuickView uses an OpenGL 2.1 context.
Try subclassing QQuickView and calling setFormat() with something like this:
@
QuickView::QuickView()
: QQuickView()
{
QSurfaceFormat f = format();
f.setVersion(3, 2); // Or whatever you want
f.setProfile(QSurfaceFormat::CoreProfile);
setFormat(f);
}
@This will cause Qt Quick 2 to try to create the requested version of OpenGL context which may allow your custom renderer to share textures on OS X.
Of course it may be some totally different problem, but let's rule this out first and I have run into this issue before.