Can someone explain to me how a SlimDx viewport would work in WPF?
Assuming one could render an image using SlimDX to a D3DImage and then used that D3DImage as a source for a WPF image, does that imply that the original image would first have to be rendered in SlimDX and then subsequently also be rendered in WPF? ie Are there two rendering process that must be completed?
If so does that mean that any speed advantages of using SlimDX rendering be negated because it would have to go through the WPF rendering rendering process as well?
Or am I just not understanding the process?
Related
Here's what I am trying to accomplish - To create an MDI application in WPF, which can host child web applications. I am using WPF webbrowser control to render web applications. WPF inherently doesn't seem to support MDI applications, so after a bit of searching, I found this project, which uses UI controls to simulate windows and manages them inside a WPF canvas. This approach seems to work reasonably well until I start adding webbrowser control object as an MDI child.
When I add webbrowser control as an MDI child, it always appears on top of other WPF elements including other MDI child controls (as shown below). From what I understand, webbrowser control always appears on top of any other WPF object except for window (and popup). Assuming that's true, I think I need to use actual WPF window to avoid overlapping issue.
The only solution i can think of right now is to wrap WPF window inside an HwndHost object and then add that as an MDI child. However it appears that a child window cannot have title bar. That means that i need to have a window that has a dummy title bar area (just like actual window title bar) and actual content area (which will show webbrowser control) as shown below (Red border is HwndHost object).
This approach seems to solve the overlapping issue. The next thing i need to try is to let users click on the dummy title bar and drag the MDI window inside the canvas element.
Questions -
Is my understanding about WPF webbrowser control overlapping behavior right? If not, what am i missing?
Is the second approach a step in right direction for accomplishing what i want? If yes, how do i implement the drag behavior for HwndHost?
Is there any other alternate solution i can try?
Note:
Although many consider MDI not an elegant solution, I do not have a choice. (We tried alternate solutions like tabbed windows/dockable
windows, but were not well received)
I am quite new to interop programming, and do not understand the
concepts well. Please correct me if i am misunderstanding things.
Thanks!
I have to show stereoscopic 3D graphics on a WPF control.
I already have the code which create two DirectX-9 textures to show, one texture for each eye.
I want to use 3D Vision (not anaglyph).
I considered the following ways to show the two pictures as 3D stereo:
Using OpenGL or DirectX 11.1 Stereo API.
Using NvAPI_Stereo_SetActiveEye as described here:
http://www.nvidia.com/docs/IO/40505/WP-05482-001_v01-final.pdf
Using NVidia stereo signature as described here:
NV_STEREO_IMAGE_SIGNATURE and DirectX 10/11 (nVidia 3D Vision)
Trying rendering the two picture one-after-one, hoping that CompositionTarget.Rendering not loosing too much VSyncs, and synchronizing if single VSyncs are lost. In addition turning on the 3D Vision emitter by some invisible control rendering a fictive stereoscopic image.
Rendering 3D scene and letting NVidia driver to make it stereoscopic automatically.
Rendering to some real Windows control (such as Winform control), and using WPF host (such as WinFormHost) to show the content.
The problems with the above methods are:
1-3: One of the first three ways seem to be the straight-forward solution, but are not possible in WPF since I cannot create the Device/Context and control the way that the picture is rendered.
4: With CompositionTarget.Rendering I get only about ~60Hz instead of 120Hz. I guess the problem is that EndScene() is called twice - one in my rendered scene and the other in WPF rendering mechanism, but am not sure. Anyway even if will work - that solution seems to be unstable.
5: Rendering 3D scene is not possible in my case for some technical reasons which forces me to render the two images for the two eyes by myself.
6: The problem with WinFormHost and its friends is that it is not a WPF control and it has unexpected behavior in terms of WPF controls. For example the WinForm control will hide WPF controls which are higher on the logical tree, it cannot be rotated using RotateTransform and more.
For now I chose the last solution - using WinFormHost. Does anyone know a solution for that unbreakable wall with making stereoscopic 3D within real WPF control?
I have a WPF application that uses an HwndHost to display DirectX 9 content. I'm trying to use the PIX for Windows graphics profiler (which comes bundled with the DirectX SDK) to see render states and debug shaders in this DirectX window.
The problem I'm running into is that when I try to do a single-frame capture by pressing F12 in PIX, I sometimes don't get all the draw information for an entire frame. Also, when I try clicking on a DrawPrimitive call in PIX I get an error message saying "A call that previously succeeded failed during playback."
I think the reason for these problems is that WPF also uses DirectX to render all the WPF widgets. It does this on the WPF render thread which is hidden from the user in WPF. It looks like PIX uses calls to IDirect3DDevice9::Present to determine when a frame has ended. The WPF render thread is making calls to IDirect3DDevice9::Present in the middle of a frame of my render, causing PIX to get confused and truncate that frame (and errors when I try to look at DrawPrimitive calls).
Here's a little more information about how my application is set up: I have a WPF application with an HwndHost inside the main window that I use to show some 3D content. In the HwndHost::BuildWindowCore function, I create a window using CreateWindowEx which gives me an hwnd. I then initialize the DirectX 9 device using this hwnd. I then return the hwnd to the HwndHost. I hook up to the CompositionTarget.Render event which calls my unmanaged render function to draw everything in the scene.
I've tried getting this working using the D3DImage control to display my DirectX surface, but I run into the same problem.
It seems to me like the only way to solve this problem is to make sure that the WPF render thread has completely finished before doing a frame capture in PIX. That way, PIX won't be thrown off by any WPF DirectX calls. However, I don't see that there is any way to determine that WPF has finished rendering everything. There is a good post here that explains how to use the Dispatcher.Invoke function to determine when a single WPF element has completed rendering, but I need to know when everything has finished rendering.
I'm wondering if anybody has successfully set up a WPF application with their own DirectX window and was able to get PIX to work properly. Any help would be appreciated.
I am working on a WPF application where the user can print multipage reports. I am using the DocumentPaginator which is working well for the most part. That is until I introduce any sort of effect such as the built in dropshadow or a brightness/contrast effect I have. I am guessing it has something to do with the lack of pixelshader built into printers. Any suggestions for a fix or workaround?
You could render the UI to a bitmap and then print an Image that refers to the bitmap.
Pardon me, if it is a silly question.
Can you anyone tell me how the WinForms are rendered (the background mechanism)
Also how is WPF Form are rendered.
In simple, i want to know the rendering mechanism of WinForms and WPF Forms.
For WPF there is the WPF Rendering Overview or WPF Rendering Steps which states
Render all children.
Process OpacityMask.
Process Opacity
BitmapEffect
Clip geometry
GuidelineSet
Transforms
Windows Forms renders its Forms using GDI+, while WPF renders its Windows using DirectX.