How can I make the background of my DirectX window invisible? - c++

For example, I am drawing images on the DirectX11 window. I do not want to show the black background of the window, only the image being drawn. A good example would be of pretty much any MMORPG launcher window.
As you can see in the image above, the World of Warcraft launcher alphas out the black background of the DirectX window, and only shows the launcher part of the window.
How would I do this in DirectX c++?

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.

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.

How can I draw around a rectangle?

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

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.

Need transparent overlay window to draw lines on top of window drawing video? ::MFC,C++,windows::

How do you create a transparent window that can be placed over another window that is actively having streaming video drawn to it. I want to create a window on top of the video window that I can draw on without video constantly drawing back over it.
I can create a window from a transparent dialog resource and set its z-order using SetWindowPos(...) but it doesn't seem to have any effect. Having the dialog set as a WS_CHILD style or WS_POPUP also appears to have no effect.
I'm using a media (video) framework another development group in my company developed and am providing a window handle to that code. That handle is being used by their rendering plugin in the pipeline that uses Direct3d for rendering the video on that window surface.
Video is rendered to a hardware overlay in the video adapter. You'll need to create your own to overlay that overlay. I think DirectX provides that capability, you can also get it by using the WS_EX_LAYERED window style and the SetLayeredWindowAttributes(). Which you'll need to set the transparency key. Not so sure that's a slam-dunk btw, I've seen this behave oddly.