I learning wpf/silverlight currently. I want to ask which one of them is better for graphics, 3d, ... ?
People say "Silverlight is a subset of WPF" -- what they mean is that the programming model is the same (code + XAML), but Silverlight generally has a smaller API / less features than WPF.
I think a good example would be creating a reflection. In WPF you could use a VisualBrush, but Silverlight doesn't support it. Still you can create the same effect by creating a 2nd transformed element. You can pretty much acomplish the same task in both, although for Silverlight you may have to do some processing tasks on the server.
The choice of platform depends more on whether you want to target web deployment or not and possibly performance.
3D isn't implemented in Silverlight 4 (though there are 3D libraries out there). 3D will be part of Silverlight 5. (Beta coming soon, probably at MIX, and to be released this year.)
i would sugest wpf in WPF you have all the Viewport sutff where you can do real 3d, In Silverlight you have PlaneTransformation but it is not close to real 3d
WPF 3d tutorial
The deal is more deeper as I understand.
We will speak about WPF and Silverlight 5. There are two mechanisms of 3D Graphics. Before WPF it was a single one - so named pipeline graphics. It includes DirectX, OpenGL and multiple derivative and independent realizations (XNA from DirectX, for example). Although WPF is based internally on DirectX it realizes absolutely different conception of smart graphics. What is the difference for a pipeline and smart mechanism? The pipeline mechanism consists of infinity loop of drawing objects - typically primitives like vertex, triangles. It works by initialization of so named infinity loop by calling something like OnDraw/ReDraw method.
WPF does not use ReDraw and does not draw anything until we directly detect it. It is single correct way to use it. Therefore WPF allows to draw UI Elements with internal support of hundreds events, methods and full freedom of management (like usual WPF control - textbox, for example). (Helix 3D is good library for easy way to WPF 3D) And vice versa, Silverlight 5 has some API of XNA graphics - pipeline way without UIElement support for 3D objects.
There is Kit3D library http://kit3d.codeplex.com/ as very good idea for smart graphic realization for Silverlight and there are many other realizations (Balder, Babylon) on pipeline mechanism. If you are interesting to code an application like web 3D Game - choose pipeline Silverlight 3D graphics, if you are interesting about smart 3D applications - choose WPF 3D.
Author of WPF 3D CAE system TIMO Structural.
Related
I have an industrial C#/WPF application written that needs to render thousands of 3D lines. (N.B. these are not a wireframe - they do not necessarily represent a 3D surface, so I don't want to tesselate polygons into triangles, or do lighting a shading, but I do want hardware acceleration) I've been looking at OpenGL and Direct3D but I keep seeing XNA suggested on Stack Overflow, e.g., here and here
I went to https://en.wikipedia.org/wiki/Microsoft_XNA to try to understand it but I'm still confused. Is it just a wrapper for something I should be using directly, like Direct3D? Does it give me access to the underlying graphics API? Can it even do lines? Can I run it in a WPF object like a Panel or Canvas?
Is it just a wrapper for something I should be using directly, like Direct 3D
XNA is not a 1:1 of DirectX.
Though XNA uses DirectX under the hood it's generally not correct to think of it as "just a wrapper" for DirectX. XNA does a few things that DirectX doesn't, like content pipelines; a clearly-defined separate game loop and draw point; content load and unload callbacks; and 2D sprites. (Microsoft ditched 2D drawing DirectDraw for a time and only now have released Direct2D)
XNA consists of a series of layers starting with Platform being the lowest and includes APIs such as Direct3D 9; XACT; and XInput.
Building upon Platform you'll find Core Framework; Extended Framework; and Games which abstract; encapsulate the lower layers whilst adding new features that result in "making game development easier". [1]
The end result is so far removed from DirectX (except perhaps for the shaders) you would not be aware you are using DirectX. You can have a game window up and running in a few lines of code compared to DirectX's pages and pages of code.
Does it give me access to the underlying graphics API?
If you mean can you talk directly to DirectX COM API then no, you can't. You can however write shaders that when compiled, the GPU will understand indirectly.
Can it even do lines?
Yes.
Can I run it in a WPF object like a Panel or Canvas?
Apparently so. I should point out that WPF already is hardware accelerated and uses DirectX for rendering. Even those drop shadow effects you see in WPF are actually DirectX GPU shaders.
Today
As you have probably read, XNA is deprecated and though Monogame is active is not 100% compatible with XNA (just look for the many posts on SO regarding XNA Content Pipeline issues for one).
Therefore if you are wishing to do 3D in WPF, well you don't need XNA for that.
More
[1] Cookiecups, "what is the xna framework", MSDN Blogs
I don't have much knowledge about Windows Phone 7 development. I know there exist two paths for an app development. Silverlight or XNA. Before I start I would like to know for what scenarios Silverlight is the best choice and for what kind of apps it makes more sense to use XNA?
Silverlight is designed around building applications. As such, it includes a retained graphics model (re-drawing is handled for you) and wide range of user interface elements including both interactive controls and controls that perform layout logic.
XNA is designed around building games. As such, it includes an immediate graphics model (you must draw every frame) and game-friendly features like a content pipeline for importing graphics and low level audio support.
There is nothing stopping you using Silverlight for games and XNA for applications, but unless you have a good reason for switching it around you'll find yourself fighting against the framework while trying to do simple things.
Neil Knight mentioned you can use mix them in Mango, though the mix involves using XNA in a Silverlight application and not the other way around.
Microsoft provided a handy chart just for this type of question :)
http://msdn.microsoft.com/en-us/library/ff402528(v=VS.92).aspx
Use Sliverlight if
You want a XAML-based, event-driven application framework.
You want rapid creation of a Rich Internet Application-style user interface.
You want to use Windows Phone controls.
You want to embed video inside your application.
You want to use an HTML web browser control.
Use XNA if
You want a high-performance game framework.
You want rapid creation of multi-screen 2D and 3D games.
You want to manage art assets such as models, meshes, sprites, textures, effects, terrains, or animations in the XNA Content Pipeline.
Combine Silverlight and XNA if
You want a XAML-based, event-driven application integrated with a high-performance game framework.
You want to create a multi-screen 2D or 3D game that incorporates a Rich Internet Application-style user interface.
You want to use Windows Phone controls along with art assets such as models, meshes, sprites, textures, effects, terrains, or animations in the XNA Content Pipeline.
You want to use Silverlight text rendering, including international text, instead of sprite fonts.
You want the page navigation model of a Silverlight application combined with the rich graphics power of an XNA Framework application.
Silverlight has a rich set of objects for building 2-d interfaces, especially 2-d interfaces composed of text, buttons, images. It's great for displaying data and taking in data.
XNA is meant for building out games or simulations, in particular 3-d, and gives you access to the device at a level somewhat closer to the hardware. XNA lacks the kind of objects that Silverlight does, but you get the flexibility to do more interesting things if you spend the time.
You may find this post useful further.
I'm currently in the early stages of a project and have difficulty deciding which framework to use. I hear people say WPF is dead, yet it seems to be the (only?) way to program a Microsoft Surface app. This is one of the possible future aims of the project, but not the main focus.
The main focus however is: both 2d and 3d objects in the same view (and kinect/voice support). Some of the 2d objects are SVG files. From what I have read online so far it's not easy to render SVG graphics in XNA (nor Silverlight 5 3D for that matter). I've seen some SVG to XAML converters, but could the result of this be used in a 3d view? Or vice versa?
Considering it's not going to be a game, but a business application I'm tempted to rule out XNA, but then again I also require good performance as there will be quite some graphical stuff going on and if possible support for high resolutions/video wall. Taking a video wall into consideration would maybe rule out WPF as I've read that it will only use hardware acceleration if the resolution is lower than the texture size limit of the GPU.
There is no intend to run the application in the browser or phone, as such i'm tempted to rule out Silverlight 5.
Any tips would be greatly be appreciated.
Thanks!
I wouldn't rule out XNA on the basis that it's "for games". You can simply use only the parts required for hardware-accelerated 3D rendering and ignore the rest. This is in fact what Silverlight 5 does!
So you may find that your 3D rendering code is the same between XNA and SL5 in any case.
Here is a question about SVG in XNA. Basically answer is: you have to write your own hardware-accelerated SVG renderer - a stupidly difficult task. But if your SVG files never change, you could just use an existing software renderer to render them to a texture.
If you converted your SVG to XAML, you would have to render it to a texture to use it in a SL5 3D view anyway (unless it's an overlay). So there is no big win there. I don't know how 2D-3D compositing works in WPF.
Your decision really depends on whether you would find the built-in functionality that SL5 or WPF provides for user interfaces useful? Seeing as you are basically making your own user interface, you probably would not get much use from the provided 2D interface.
The 3D API that SL5 provides is basically a cut-down version of XNA. The 3D API for WPF looks like it just renders models for you - it does not seem to buy you much over XNA. If you have a compelling reason to use XAML, then WPF may be a good choice. Otherwise I'd go with XNA.
I have a visualizing module for 2D vector graphics. All calls to drawing API are strictly isolated there. I want to be able replace one drawing API with another drawing API just by reimplementing the module. All data for visualizing are transmitted into the module through a single interface named Ixxx. I have a choice between GDI+ (via WinForms) and WPF, so why should I choose the last one? Any reason?
After some analysis of common cases of switching to WPF among friends, I have found that the primary causes are:
WPF is newer/cooler/more modern/more interesting/blah-blah-blah.
Ixxx is not designed abstract enough (for instance, raw XAML is transmitted) or it doesn't exist at all (any module draws anything, anywhen and the way it wants). Sure, if you have no own graphical description solution, it's better to use XAML than to use nothing and to share common HDC.
Again, I'm not going to "sell my soul" (see AJ&TZ for details) to any given API, I'd like just "to lease it" temporary. It means no using API for anything except drawing all data in the same place.
Regards,
Serge.
WPF was designed for vector graphics. GDI+ is meant for raster graphics.
WPF will use your computer's graphics processor. GDI+ will do everything in the CPU.
WPF has a brand new API with an emphasis ease of use. GDI+ is ancient (Windows 3.x days) and focused on performance for what we now consider extremely low-power hardware.
WPF has a brand new API that most of us don't understand. Everyone knows how to use GDI+.
Learn 2D WPF and you have a foundation for 3D WPF. After GDI+ you need to start over with Direct3D.
Note: I am not a graphics person, I write business applications. This is mostly based on marketing literature and little test programs.
WPF graphics are hardware accelerated. I would consider that a critical consideration. It is a very flexible API for 2D graphics and has a good online community.
This library could be worth a look for you to see what WPF can do: http://dynamicdatadisplay.codeplex.com/
In my company we have in mind a redesign of the user interface of an application and we would like to make it ... let say "fancy". We have in mind a simple story board but I doubt between WPF, XNA or DirectX. I prefer WPF so I'd need to know if it support the following capabilities and how difficult to implement are they:
Transparency: We'd like to display information layers on top of the main display.
3D support: We want network nodes (part of the interface is a network graphic) to be simple spheres connected with lines in a 3D enviroment, and the ability to control the camera so rotation of the screen is possible.
Effects: Such as shading, lens flare or glow to "signal" the discovery or deletion of a node.
Text animations: Specifically the ability to display the text as if it's being written... You know, the information text will be "filling" the panel top down, left to right...
Good news. WPF is the technology you want and it can handle your requirements with relative ease.
Transparency is simple.
3D support is good as well. For an example, check out Tim Sneath: Five Great WPF 3D Nuggets. You even get hardware acceleration.
Effects are definitely do-able via timeline animations.
The previous statement goes double for Text Animations.
...the hardest part would be the 3D support, but it's still going to be a lot easier than getting things done in XNA or using DirectX libraries directly.
AFAIK WPF 3.5 supports all of this, and even leverages hardware acceleration to get a decent performance.
It's possible to embed an XNA application in a WPF form so you could use XNA for the representation of your network and WPF controls for the GUI in front of it.