Can Viewport3D control in WPF work with OpenGL?
The WPF's something Viewport3D can't do (there are lots of thing it can't do), whole WPF is DirectX based. This also means DirectX is generally much better supported in WPF.
However you can use OpenTK's WinForms viewport and use WinFormsHost to put it in your application. OpenTK is a very nice .Net wrapper for OpenGL.
However you will not be able to use XAML, bindings and other WPF-specific stuff. You will have to do the OpenGL calls manually from code. All the interop does is that is places the viewport in your application and lets you do .Net calls on it.
You may also want to have a look at this project.
It cannot, in the sense that you can merge 3D content from OpenGL to Viewport3D seemlessly (with correct Z testing and all).
Related
Recently I have been working on a small WPF project involving the visualization and manipulation of 3d objects. For 2d ojects, this can be easily achieved with a Canvas warpped in a ViewBox or some nice 3rd party controls. But I can't find any free, ready-to-use solution for 3d objects. There is a likely one in WpfToolKit from XceedSoftware(https://github.com/xceedsoftware/wpftoolkit), but no information is given.
I know WPF has some 3D support, like ViewPort3D and other classes in Media3D namespace, and I did find a book, '3D Programming for Windows'(http://www.charlespetzold.com/3D/index.html), by Charles Petzold introducing the concept and basic knowledge. However, many tricky tasks like adjusting camera according to mouse and keyboard input is not presented. So before I start building my own control, I want to at least confirm that I'm not wasting my time doing something already perfectly done. And how to properly config the mouse and keyboard events to make the control behaves as if using some professional CAD softwares?
In short:
1.Any free 3d control for WPF
2.How to build my own ones
Can anyone help me?
I would like to write a simple ray tracer using WPF. It is a learning project and thus I favour configurability over performance (otherwise I'd go for C++).
I still want relatively fast pixel drawing. A previous question on StackOverflow contains code to achieve this in WPF, by obtaining a GDI bitmap. From the relatively little I know about Windows programming,
GDI is slow
DirectX is fast
WPF uses DirectX underneath (not sure which parts of WPF though)
Is it possible to obtain pixel-level access using DirectX (not GDI) through the WPF Canvas (or similar)?
I will also consider suggestions for incorporating DirectX API calls within a WPF window (alongside other WPF controls) if that is possible.
Thanks in advance.
Interesting, but with raytracing, writing the pixels to the screen will (should) not be the slow part. You can use WriteableBitmap for the purpose, though. It's certainly quick enough for what you want.
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx
(For info, I use it in this emu/IDE - http://0x10c-devkit.com/ - and it can refresh a low res display with great performance. There's the source to that on the github repository, the LEM1802 plugin.)
Ah, this bit: https://github.com/kierenj/0x10c-DevKit/blob/master/PluginAPI/NyaElektriska.LEM1802/GPU.cs - see UpdateDisplay.
Another solution is WriteableBitmapEx. It extends the builtin WriteableBitmap.
There is an open Source Project Called Direct Canvas wich is A hardware accelerated, 2D drawing API that supports vector graphics, multimedia files, extensible pixel shaders, blending modes and more!
http://directcanvas.codeplex.com/
Demo http://www.youtube.com/user/jdollah69#p/u
I'm working on creating a basic application that will let a user draw (using a series of points) and I plan to do something with these points.
If this were Java, I think I would probably use a canvas object and some Java2D calls to draw what I want.
All the tutorials I've read on C#/Drawing involve writing your own paint method and adding it to the paint event for the form. However, I'm interested in having some traditional Form controls as well and I don't want to be drawing over them. So, is there a "Canvas" object where I can constrain what I'm drawing on?
Also, is WinForms a poor choice given this use case? Would WPF have more features that would help enable me to do what I want? Or Silverlight?
A Bitmap will work fine, display it with the PictureBox.Image property. Use Graphics.FromImage() to get the Graphics object you'll need to draw on the bitmap. Use PictureBox.Invalidate() to let the PB know that it needs to update the image on the screen.
Well, there is a control called 'canvas' in WPF which may suite you. If you are using Windows Forms, i think the best choice will be to draw on a panel control. Windows forms are in no way a poor choice. Indeed, when using them you can even develop a cross-platform applications. However, WPF is more 'rich' in some way. I think that if you are not aiming at any other platforms, and you don't have to stick with .NET 2.0 WPF is a preferred choice (especially, if you are going to use some graphics in your application, because WPF uses hardware acceleration).
I am currently developing a 3d game using C#/SlimDX (The target is Direct3D 9). I've been looking for a suitable Game UI toolkit for a while, but I was unable to make up my mind.
The Game UI will be for a roleplaying game, so it'll be fairly complex and will involve quite a few controls (text boxes, inventory grids, list boxes, select boxes, scrollable areas, etc.).
I previously (When i was still using C++/OpenGL) looked at GameSWF and very much liked the idea, but for my current game it's out of the question.
Does anyone know a good GUI toolkit for use with SlimDX?
I would be especially interested in using WPF/Silverlight for this, since there are good IDEs available for both. But a quick google search didn't reveal any information on embedding these.
You can use WPF (but not Silverlight) for this.
The way to go about this is to use SlimDX in conjunction with D3DImage. You then let WPF handle all of your final composition, including overlaying the WPF UI over the top of your SlimDX scene.
SlimDX basically just renders to a brush in this situation, which can be used on any WPF element. (This doesn't work for Silverlight, as Sliverlight doesn't support D3DImage.)
I have a C# winforms project and I want to add a bit of jQuery or iPhone style animation flash to it.
Nothing too fancy just an easy way to slide and expand panels, perhaps a bit of rotation.
Is there a library out there that would do this all for me?
You can also inject WPF controls into your WinForms apps if you're wanting to add stuff in to an existing project. Here's a good tutorial on how it's done.
I'm not sure if it would work for drawing 3D or rotating (although it might), but you can def use WPF in your WinForms. I haven't tried using the expander myself, but other controls I've used worked just fine.
If you're using .NET 3.5 you can use WPF to achieve animations.