Wednesday 6 November 2019

Monday 21 October 2019

OBS Studio with dual graphics

Here is how to set any app to always run on a particular GPU: https://www.tenforums.com/tutorials/103965-set-preferred-gpu-apps-windows-10-a.html. A well-hidden feature. Set OBS Studio to always run on Intel. By default it runs on NVidia, which makes it not work — lagging for minutes, not showing capture, etc.

Friday 11 October 2019

Getting along with qwt on Qt

Smooth experience with Qwt on Windows with Visual Studio.
  1. Build qwt on Windows: https://www.qtcentre.org/threads/66576-Installing-Qwt-with-MSVC-2015-64bit-compiler-on-Windows-(complete-instructions) — that works on VS-2019 as well.
  2. You will need QtDesigner with VS. Install a plugin: copy from qwt-6.1.4\plugins\designer\ to qt\5.13.1\msvc2017_64\plugins\designer\. Run qt\5.13.1\msvc2017_64\bin\designer.exe and see this at Help → About Plugins:
  3. You also need a plugin at QtCreator. It is a 32-bit app :( So you compile qwt for 32-bit, keep it fully separately from 64-bit one (i.e. unzip your qwt downloadable to a separate folder again, name it qwt-x86-6.1.4). Copy qwt-x86-6.1.4/plugins/designer/qwt_designer_plugin.dll to qt/Tools/QtCreator/bin/plugins/designer. Create a Widget application, go to a form and find this in the panel:
  4. Create a VS Qt project, then export a QtCreator project from it. Use both.

Friday 4 October 2019

Initialization in modern C++

Initialization in C++ is unreasonably hard. There are 19 ways to initialize an int, leading to quite different results depending on the case. Copying initialization is a bogus. Move semantics makes all that ever more harder: https://www.youtube.com/watch?v=PNRju6_yn3o.

There are improvements coming in C++20 though: https://habr.com/ru/company/jugru/blog/469465/ related to homogenizing curly-braced and parenthesis initializations. This funny stuff is also fixed: https://youtu.be/AgatxxXNwBM?t=390 (in a funny way as well).

My own rule of thumb so far:
  • always avoid copy initialization,
  • use curly-braced initialization everywhere,
  • don't use parenthesis initialization.
That shall remain even with the coming of (args) and {args} homogenization in C++20, as {} prevents narrowing conversions which you usually don't want.

Saturday 28 September 2019

C++ craftsman named arguments

We try to compensate for lack on named arguments in so many ways. Check one the lastest takes on a subject: https://www.youtube.com/watch?v=Grveezn0zhUCppCon 2018: Richard Powell “Named Arguments from Scratch”. The recent C++20 "designated initialization" doesn't help much, as you must remember the order of fields as declared in a corresponding struct. Other people try things around it, as well, such as calling functions using curly syntax: https://www.youtube.com/watch?v=L8eeDzTWEtU, or allowing default parameters in the middle of args list https://github.com/joboccara/Defaulted. So, there's a lot, and more: https://www.codeproject.com/Articles/1171605/Named-Cpp-Function-Parameters , https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/ etc.

But let's pull back. What if: