Evgenii Legotckoi
Evgenii LegotckoiJan. 27, 2017, 7:53 a.m.

QPainter OpenGL Core Profile Context Support

As many people know, QPainter has a multi-backend architecture and has two main rendering implementations under the hood of Qt 5: The raster rendering engine and an OpenGL2 engine that targets OpenGL ES 2.0.

GL Paint Engine

While the bitmap rendering engine is one of Qt's gems, let's talk about the other half: the GL rendering engine, which is used when QPainter is opened on:


Problems

What about modern OpenGL?

What problems started showing up early: Around Qt 5.0, for those who needed a main profile context while creating a custom OpenGL rendering that ended up working quite often. Components like Qt Quick couldn't work with such contexts in the beginning due to the need to rely on deprecated/removed functionality (e.g. client-side pointers), missing vertex array object, GLSL version of shaders which support is not required for such contexts.

In some cases, choosing a compatibility profile has been a viable workaround. However, Mac OS X / macOS notoriously lacks support for this: there is a choice between OpenGL 2.1 or the main profile context 3.2+. Attempting to solve this problem by, for example, rendering a texture in one context and then using the texture in another context through resource sharing is often futile, as some platforms tend to reject resource sharing across different version/profile contexts.

Progress

Fortunately, during the Qt 5 life cycle, these things were improved: Firstly Qt Quick, and then other, less custom GL-based components, were patched to function with both core and compatibility contexts.

As of Qt 5.8, there is one big exception: the GL rendering engine for QPainter.

Last missing piece

The good news is, this restriction will be lifted soon. Thanks to the contribution of Krita , see here for reference , QPainter is now able to function in the main contexts profile. Functionally, this will not bring any changes, rendering is still done using the same methods as before.

In addition to fixing the original patch, this has also been integrated with a regression testing system called Lancelot. This means that in addition to bitmap (with different QImage formats) and OpenGL 2, it will also run with the main profile context from now on to ensure that QPainter exits without regression between Qt releases.

In general, this means that the code snippet below will function as expected.

class Window : public QOpenGLWindow {
  void initializeGL() override {
    QSurfaceFormat fmt;
    fmt.setVersion(4, 5); // or anything >= 3.2
    fmt.setProfile(QSurfaceFormat::CoreProfile);
    setFormat(fmt);
  }
  void paintGL() override {
    QPainter p(this);
    p.fillRect(10, 10, 50, 50, Qt::red);
    ...
  }
  ...
};

When?

Qt 5.9.

The patch is now merged into qtbase in the "dev" branch. Will be added to Qt 5.9 soon.

Источник Qt blog

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
i
innorwallNov. 14, 2024, 7:03 a.m.
How to make game using Qt - Lesson 3. Interaction with other objects what is priligy tablets What happens during the LASIK surgery process
i
innorwallNov. 14, 2024, 4:09 a.m.
Using variables declared in CMakeLists.txt inside C ++ files where can i buy priligy online safely Tom Platz How about things like we read about in the magazines like roid rage and does that really
i
innorwallNov. 12, 2024, 6:12 a.m.
Django - Tutorial 055. How to write auto populate field functionality Freckles because of several brand names retin a, atralin buy generic priligy
i
innorwallNov. 12, 2024, 2:23 a.m.
QML - Tutorial 035. Using enumerations in QML without C ++ priligy cvs 24 Together with antibiotics such as amphotericin B 10, griseofulvin 11 and streptomycin 12, chloramphenicol 9 is in the World Health Organisation s List of Essential Medici…
i
innorwallNov. 11, 2024, 11:50 p.m.
Qt/C++ - Lesson 052. Customization Qt Audio player in the style of AIMP It decreases stress, supports hormone balance, and regulates and increases blood flow to the reproductive organs buy priligy online safe Promising data were reported in a PDX model re…
Now discuss on the forum
i
innorwallNov. 14, 2024, 8:39 a.m.
добавить qlineseries в функции Listen intently to what Jerry says about Conditional Acceptance because that s the bargaining chip in the song and dance you will have to engage in to protect yourself and your family from AMI S…
i
innorwallNov. 11, 2024, 6:55 p.m.
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
9
9AnonimOct. 25, 2024, 4:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks