How can I draw around a rectangle? - c++

I'm using openGL to draw some animation.
I want to draw the animation in an area around a rectangle.
That rectangle are should be transparent, to show whatever windows happen to be there, and leave that to regular windows MFC drawings.
I know there should be away to do it with clipping. But since whatever is in that rectangle isn't drawn with the openGL I'm not sure that will work well.
I'm using openGL with c++.

Solution:
If you are drawing over unrelated windows, you should use Stencil buffer.
This can be used as a masking layer to decide where you want to draw.
If you have an MFC window with a child window, you can create the "father" window with the following style: WS_CLIPCHILDREN

Related

Qt widget blurred semitransparent background on Linux

Working with widgets, c++ and Linux
need something kind of:
this
but no borders and custom title.
Search for a few days, but nothing.
For now, there is a widget with setWindowFlags(Qt::FramelessWindowHint); and a peace of qss for semitransparent background. How can I blur it? Is is possible at all?
I do not think this can be done with Qt. Blurring can be done using https://doc.qt.io/qt-5/qgraphicsblureffect.html but it is only limited to the widgets painted by Qt. Which the underlying background is not, even if you manage to make your widgets transparent or semitransparent. Painting the background is always the business of the operating system (or window manager) and not the business of your application Qt.
You can certainly try to do some extreme hacking like grabbing the active screen before your window is displayed (see How to capture the current screen image using Qt?) then getting certain rectangle content of the image, which corresponds to the background of your window, then paint it blurred to the background of your application and then update it everytime you move or resize your window... But anyway, even if you manage this, this background will be static and not dynamic.
I recommend that you abandon the idea of blurry background and leave this function to the window manager and the operating system.

Mouse input transparency in Qt without visual transparency

I know of Qt::WindowTransparentForInput which makes a window and all of its chilren transparent, and QWidget::mask which also visually clips the region outside. I want to draw a window with client side shadows, so I need mouse input- but not visual transparency. How is this possible?

Rendering UI with Sciter on top of the window

I have an 3d game renderer with DirectX 11 - the project also uses WinAPI.
On top of the game, I would like to render HTML/CSS UI with Sciter (it's a single, full screen game window).
So I initially draw the 3D scene with my engine->render().
And then I draw UI with Sciter (for now it's just load_file(....htm)). The problem is, the UI covers the whole window (with white background), and I cannot see the game through UI.
How can I apply transparency to "mask" between UI and what was rendered to window previously?
I have already tried SciterSetOption(*hwnd, SCITER_ALPHA_WINDOW, TRUE); but that makes white background transparent for whole window (I see what is behind the window, the desktop - not the 3D scene of mine which also is transparent :/ ).
I set html, body { background-color: transparent; } without result.
You don't need to render your UI in separate window as Sciter is capable of rendering HTML/CSS stuff directly inside DirectX 3D scene:
Check http://sciter.com/sciter-and-directx/ article.

drawing inside a qt windows

I'd like to draw a color "frame" within a QT window. So, I have
setFixedSize(WIDTH, HEIGHT);
and I'd like to draw, say, a red (filled) border within width and height. Could anyone help me out?
Depends on a couple of things:
Is it a border around an existing widget? If it's just a border around an existing widget don't go down the route of painting it yourself, it's much simpler to use Stylesheets than draw it.
If of course you need a custom or very specific style, then you're best off drawing it using the Painting System. I'd strongly suggest do it using stylesheets unless you do need specifics. The paint system can be a bit unwieldy for just adding a border to a widget.

How can I draw a selection rectangle on the screen with Qt?

How can I draw a selection rectangle on my screen with Qt in X11?
I want to be able to drag a rectangle on my screen (outside of the application) and then save the whole rectangle.
Thanks in advance.
Part of the solution will involve using the grabWindow() function of QPixmap like so:
QPixmap::grabWindow(QApplication::desktop()->winId());
Qt has an example program for this here.
There rest of the solution, drawing the area to grab, can probably be achieved by either using a full screen transparent window to render a mouse drawn rectangle and then taking the section it outlines from the grabbed desktop image or using a full screen window with the entire grabbed screen painted on it.