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
Evgenii Legotckoi
Evgenii LegotckoiNov. 1, 2024, 12:37 a.m.
Django - Lesson 064. How to write a Python Markdown extension Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
A
ALO1ZEOct. 19, 2024, 6:19 p.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 5:51 p.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 9:02 p.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
k
kmssrFeb. 9, 2024, 5:43 a.m.
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
Now discuss on the forum
Evgenii Legotckoi
Evgenii LegotckoiJune 25, 2024, 1:11 a.m.
добавить qlineseries в функции Я тут. Работы оень много. Отправил его в бан.
t
tonypeachey1Nov. 15, 2024, 5:04 p.m.
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
NSProject
NSProjectJune 4, 2022, 1:49 p.m.
Всё ещё разбираюсь с кешем. В следствии прочтения данной статьи. Я принял для себя решение сделать кеширование свойств менеджера модели LikeDislike. И так как установка evileg_core для меня не была возможна, ибо он писался…
9
9AnonimOct. 25, 2024, 7:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks