[Development] Adding 10-bit OpenGL support in QML

Gunnar Sletta gunnar.sletta at jolla.com
Wed Feb 26 20:22:12 CET 2014


On 26 Feb 2014, at 18:26, Kurt Pattyn <pattyn.kurt at gmail.com> wrote:

> Thanks for the reply.
> 
> On 25 Feb 2014, at 23:22, Gunnar Sletta <gunnar.sletta at jolla.com> wrote:
> 
>> On 26 Feb 2014, at 00:42, Kurt Pattyn <pattyn.kurt at gmail.com> wrote:
>> 
>>> We are currently looking into a way to render a 10-bit image in QML.
>> 
>> I'm going to assume we're talking about Qt Quick 2.0.
> Yes, indeed.
>> 
>> As in 10-bit grayscale or GL_UNSIGNED_INT_10_10_10_2?
> Yes, both grayscale and color 10-bit.
>> In any case, you can create a custom QSGTexture class which defines the format and contents of your texture and display that in the scene graph using a QSGSimpleTextureNode. If something more specific is needed, write your own material to do exactly what you want.
> Is it correct that we can subclass a QQuickItem and return a subclassed QSGSimpleTextureNode object from the updatePaintNode() method?

Indeed. The default texture material assumes RGBA values, though, so at least for the grayscale texture, you probably want to write a custom material to pick only the 'r' gray value. 

https://qt-project.org/doc/qt-5.1/qtquick/scenegraph-simplematerial.html

shows how to use a custom material.

>> 
>>> Our first idea is to create an OpenGL context in C++ and use that in QML.
>> 
>> You cannot create the OpenGL context for QQuickWindow, but you can request the format it should take via QQuickWindow::setFormat().
>> 
>>> QML must be able to overlay text on this 10-bit OpenGL context.
>>> 
>>> What is the best approach for this? Is it possible at all?
>>> Can we expose a QGLWidget, or something similar?
>> 
>> QQuickWindow has an QOpenGLContext and does not use QGLWidget.
> So, as I understand this is what should be done:
> QSurfaceFormat surfaceFormat;
> surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL);
> //set bitDepth on surfaceFormat
> QQuickView * view = new QQuickView();
> view->setFormat(surfaceFormat);
> 
> And then use a subclassed QQuickItem together with a subclassed QSGSimpleTextureNode.
> 
> Is this correct?

I haven't tried >8-bit target frame buffers, but if they are exposed as normal GL configs, you would be doing something like:

QSurfaceFormat format;
format.setRedDepthBufferSize(10);
format.setGreenDepthBufferSize(10);
format.setBlueDepthBufferSize(10);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);

QQuickView view;
view.setFormat(format);
...
view.show();

cheers,
Gunnar

BTW, For general questions on how to USE Qt, interest at qt-project.org is more suited. The development list is for developing Qt itself.

> 
> Cheers,
> Kurt
>> 
>> 
>> cheers,
>> Gunnar
>> 
> 




More information about the Development mailing list