how to Map a window to 3D - windows

I'm searching for how to render window to 3D windows Texture on D3D
for example, the windows aero-glass's preview.
a window or part of window that has a windows handler is rendered to a d3d device(i guess aero glass is maked by d3d).
my project is a 3D interective media. it is an AR project using HMD and Hand Recognizing.(Like a 3d touch interaction )My part is 3D Rendering. The WPF can do this. But i don't find the way how to do it with D3D.
Who knows the way or it is impossible on D3D? if you know, please notice me a KEYWORD that using to Google.
thanks to reading and your attention. i'm not native english user and i'm sorry that if you feel my english seems ugly.

I may suggest using dynamic textures. You first create a texture of the desired size and format. Then you get its surface, obtain HDC and pass it to a window you want be drawn. Showing a texture thru d3d device shouldn't be a problem.

Related

Common Controls on a Transparent Window?

While there are lots of variations of the question, there doesn't seem to be a specific answer to a simple case of wanting to use built-in common controls on a transparent window using Win32. I don't want the controls to be transparent, I just want the border around it to be transparent. I can't believe MS didn't update the .dll's to handle transparency when they added it, but I guess they forgot? Is there a specific method that works. A button can get close with WS_EX_TRANSPARENT, but flaky where it works most of the time but at times part of the border shows up. Edit controls, change depending on when get focus or not.
So the question is simply:
Is there a way to make common controls on transparent window so there is no white border around them?
If not, is there a good replacement library that does it via owner draw?
If some, which ones and what is the method?
Seems silly to reinvent the wheel just because of the area around the control.
TIA!!
If I am not mistaken, you can take the following steps to achieve this effect.
1.Create a GDI+ Bitmap object with the PixelFormat32bppPARGB pixel format.
2.Create a Graphics object to draw in this Bitmap object.
3.Do all your drawing into this object using GDI+.
4.Destroy the Graphics object created in step 2.
5.Call the GetHBITMAP method on the Bitmap object to get a Windows HBITMAP.
6.Destroy the Bitmap object.
7.Create a memory DC using CreateCompatibleDC and select the HBITMAP from step 5 into it.
8.Call UpdateLayeredWindow using the memory DC as a source.
9.Select previous bitmap and delete the memory DC.
10.Destroy the HBITMAP created in step 5.
This method should allow you to control the alpha channel of everything that is drawn: transparent for the background, opaque for the button.
A similar discussion: Transparent window containing opaque text and buttons

Direct2D: smooth image movement?

Im using direct2d to draw a bitmap to the window, and thats working fine, but when I move the image (continually, with joystick, key input, or just by itself), it doesn't move smoothly. It look's like the image pixels are not spread to surrounded pixels, It looks like the most dominant colors remain, and the others are discarded. I create the bitmap using WIC (windows imaging component).
I didn't want to post code cause it's just the most basic stuff, window creation, direct2d initialization, bitmap creation and drawing, all taken from msdn, most of it is just copy-paste. If you think you need any code to help me, ask, then I'll post it.
What I want:
Smooth image movement on picture.
What I've tried:
-void SetAntialiasMode(D2D1_ANTIALIAS_MODE antialiasMode); (tried all options)
-setting D2D1_BITMAP_INTERPOLATION_MODE in draw bitmap method to different modes.
Thanks in advance!

Overlay window drawing which appears in screen captures of other applications

We need to overlay a target window with a custom shape and tracks the position of the target window such that the overlay drawing always appears above it. Also, the overlay drawing should appear in screenshots taken using BitBlt or PrintClient by screen-capturing tools like Camtasia, Debut, etc. Also, moving the target window around should not leave traces of the drawing at earlier location. The target window is not made using our code.
So far we've tried several ways but each method has its problems:
1) Layered Window:
Using a layered window as the child/owned window of the target window is the easiest thing and it works. But the problem is on Windows 7 and XP, layered windows do not appear in a BitBlt done without the CAPTUREBLT flag and the screen-capturing tools may call BitBlt without the flag, thereby skipping our window from the capture.
2) Region Window:
The crude approach to support all Windows versions then is to use a region window using SetWindowRgn and make the target window its owner. However, region windows are generally very slow in rendering complex shapes and also impact the performance of other windows, sometimes to the point of freezing the application. Region window also leaves traces on dragging the application window.
3) Subclassing and Drawing on HDC:
Another approach is to sub-class the target window and draw the shape on its HDC on the OnPaint() event inside the window procedure hook. The shape can be drawn on the desktop window instead too. The problem is that applications may draw without a paint event, like when some text is selected using the cursor, and such drawing may erase a part of the custom drawing. Tracking all possible paint events is not a good way to do this.
4) Drawing continuously in a timer:
The last resort is to draw the custom shape on the target window in a timer continuously so the drawing is always above the target, even on text selection. But this may show a bit of flicker when the text is selected. Not to mention, it is very performance heavy to draw constantly.
Question
What is the best way to achieve an overlay drawing which works on all Windows versions (since XP) at the same time appearing in screen-captures. We've exhausted all approaches. Is there some method I'm missing? Can the above mentioned ways be used with some improvement? Is DirectX an option? I'm looking for methods with fast rendering capacity to achieve this. Appreciate any help!
I think the best solution to draw an overlay window, is to use a double-buffered technique GDI, just like in this example:
Overlay Drawing in CScrollView
I have myself the same task, and the only solution was that one. Hope it help you.

Skinned Window: Win32 API and DirectX

I'm trying to create a borderless window using a WS_EX_LAYERED style window. The objective is to render graphics using DirectX directly to the desktop, using alpha to blend onto the current desktop windows.
Now on my system this technique seems to work perfectly. I can set various alpha levels and achieve different levels of transparency. Unfortunately several users have reported severe performance problems and low frame rate, making this technique unusable.
The code setup is as follows:
Create a layered (WS_EX_LAYERED extended-style) window.
Initialize DirectX using the window HWND.
Create a render target using the CreateRenderTarget DirectX method.
Then during the render loop:
Render graphics to the render target using DirectX calls.
Get the HDC handle to the DirectX render target surface using GetDC method.
Update the window contents using the UpdateLayeredWindow function, specifying the DirectX surface HDC.
My question is: Am I doing something wrong? Is there a way to improve the performance of the window update. I have tried various things, like locking the render target and manually copying the bits to a DIB section to display in the window area, without success.
How big is your window? Note MSDN's documentation at http://msdn.microsoft.com/en-us/library/windows/desktop/ms633556%28v=vs.85%29.aspx says "For best drawing performance by the layered window and any underlying windows, the layered window should be as small as possible."
You may be getting a performance boost if compositing (Aero) is enabled. If Windows is already compositing, it won't have to do as much extra work to draw layered windows.
If you're not seeing any difference in performance depending on compositing, then I am probably completely off base here.

WP7 XNA + SilverLight + Touch = Wrong Coordinates?

I'm using the mixed XNA/SL programming model where the Silverlight content is rendered by UIElementRenderer. However, it appears that there is a 40 pixel offset between the screen coordinates reported by touch (GestureSample) and the actual coordinates where the contents of the page are rendering.
It appears to be space reserved for the SystemTray in Silverlight apps.
My question is: is there an API I can call to dynamically return this offset so I don't have to hard-code it?
Thanks!
I don't actually think there is any such offset. Since the GestureSample has accurate screen coordinates, your problem is probably with drawing the silverlight UI. Make sure that you don't have any view/projection transforms active on your SpriteBatch when you draw the uiRenderer texture.
If you were using a transform to draw your game scene, you might just want to end that SpriteBatch and start up a new one for screen UI.

Resources