Metro Games in c# - c#

Is it possible to use DirectX in C# to create metro game for windows store? XNA isn't supported as far as i know so what are capabilities to create game for metro?

Yes is possible, you can use SharpDX, new version supports Windows store apps (WinRT).
SharpDX is open source project and you can use it in your commercial applications without a charge, more here : http://sharpdx.org/about/licensing
here is the example of usage and some tips :
http://channel9.msdn.com/coding4fun/blog/Making-Modern-UI-Managed-DirectX-Apps-with-SharpDX-Updated-for-Win-8VS2012-RTM

You can leverage your XNA investment via MonoGame which in turn relies on SharpDX. Check out Bob Familiar's blog posts to get started. (And yes, it's also free).

I you know C++, you can write the graphic part of your project in a separate Library written in C++ and using DirectX directly.

Related

c# mixing two audio files in windows phone 8.1 silverlight project

My goal is to mix 2 audio files that is one voice and one background music. For mixing I am using NAudio.
The problem is I am getting following exception while reading mp3 file using NAudio's Mp3FileReader.
DllImport cannot be used on user-defined methods
I am using NAudio in Windows Phone 8.1 Silverlight app project. I am not sure if NAudio is useable on WP Silverlight app if its useable then please help by providing a code example or suggest any other library or custom implementation to mix 2 audio files.
No, I'm afraid NAudio is not usable on Silverlight, as it makes lots of calls into Windows APIs which you can't do in Silverlight. You can take a look at the NAudio NLayer project which offers fully managed MP3 decoding. You could use that in conjunction with some of the more generic helper classes in NAudio like the MixingSampleProvider to perform the mixing you require. Of course the next issue would be what you want to do with that mixed audio. Silverlight does have a way of streaming user generated audio using the MediaElement but NAudio does not provide support for this directly.
[DllImport] requires a substantial chunk of code in the CLR, nothing very subtle about the pinvoke marshaller. That's a problem on a phone, it runs a special version of the CLR named .NETCore. Probably better known today as the codebase that spun-off the CoreCLR open source project. Keeping it small required unsubtle choices, pinvoke fell on the floor.
So no, you'll have no use at all for NAudio. You'll have to dip into the built-in support for audio. The relevant oversight MSDN page is this one. This blog post is relevant.
As you can tell, XAudio2 is your ticket with direct support for mixing. There is a learning curve of course, the language is probably the first obstacle given the question tags. Get started with this sample to get the basics.
Maybe you should consider taking the step to upgrade from WP8.1 Silverlight (WPS) project to WP8.1 (WinRT) one so that you have better access to audio APIs...
...or directly to a UWP/Win10 app (if you don't plan to release immediately to phones). If you choose that path, you could try maybe a free preview tool that converts WPS to UWP, just released from Microsoft and Mobilize.NET - https://blogs.windows.com/buildingapps/2015/09/17/initial-preview-of-silverlight-bridge-to-uwp/

Can I develop a Windows Universal Application using DirectX and C#

I've seen that there is a template to do so in Visual C++, but not in C#. Have I to stick to C++ to develop a Direct X (Universal) application ??
Can I use C#? If so, how?
Have I to stick to C++ to develop a Direct X (Universal) application?
Technically, you can use the DirectX in .NET platform by using the interop technology. SharpDX has done such kind of things for you and you can easily use the DX in you .NET project including the Window 8.1 and Windows Phone 8.1 app project. However, as I just tested, the SharpDX has not supported the Windows Universal App yet.
Since you must use C++ when calling DirectX APIs, so if you want to develop your Windows Universal Application by C# and DirectX as the same time, the best practice might be to package all the DirectX related functions in a separate C++ WinRT component. Then you can include it in any C# application.
Depending on your needs for DX, you might want to look into the Win2D project from Microsoft, its C# and lets you mix 2d and 3d.

Do games like Starcraft 2 use Windows Forms to build their UI?

This may be a dumb question...
When I log into Starcraft 2 and see that beautiful UI, I can't help but wonder if it's designed using Windows Forms (.Net or C#). Is the login box just some kind of Windows dialog or do they do their own thing - whatever that may be?
Is it possible to get that much customization within Windows Forms?
No. Games and other apps that use DirectX to take control of the video device don't use WinForms or even the Win32 API for screen output.
StarCraft 2 most likely implements its own windowing and UI system, completely independent of the Windows API or WinForms library.
Yes, you can write an app in C# to perform similar DirectX graphics output, but using DirectX is not as simple as working with WinForms. I wouldn't recommend attempting to write a DirectX app as a way to teach yourself C# unless you are already very experienced with DirectX through other languages or tools (C++, mostly).
WinForms is fine for learning C# and whatever IDE tool chain you choose to use. After you're comfortable with C# patterns and terminology, then tackle learning how to write DirectX code with C#.
No. They use DirectX. DirectX bypasses normal windows and operates at alower level.
You can customize a form to a great degree. You have full control over painting it to look however you want.

Metro App with 2D Graphics in C#

I have done some looking and I can't figure out a good way to write a 2D tile/sprite based game in C# for Win8. According to the MSDN documentation:
You can use managed code languages like C# and Visual Basic to develop 2D (and lightweight 3D) games.
The problem is that I can't figure out how to do this. The reason I would like to use C# is because I already have a lot of code written for Windows Phone that I would like to reuse.
Can anyone point me to how I would write a fairly efficient 2D tile/sprite MetroUI game for Win8? The only thing I can find uses C++ and DirectX.
[EDIT]
To clarify I do not care too much what I use (WinRT, DirectX...) so long as I can submit to the app store, and write my code in C#.
If you are familiar with the DirectX API, you can use SharpDX available via http://sharpdx.org. It is basically exposing DirectX APIs into C#. From my understanding, if you are going to upload apps to the store, the SharpDX should be fine and pass compliance, but I would look into it further before going too deep.
Also, as of this time, not all of the features are available (like Direct2d not fully certified for Win8 Metro).
If your game uses simple graphics, you can use Drawing Library for Modern UI, it exposes a GDI+ like interface to be used in XAML/C#/VB.NET Windows 8 Modern UI applications, it works by drawing to a XAML Canvas.
If you're looking for something quick and easy check out the "Physics Helper XAML" project;
http://physicshelperxaml.codeplex.com/
It's based on the farseer engine, and comes with sample apps. There are a few games already released using it.
http://www.andybeaulieu.com/Home/tabid/67/EntryID/223/Default.aspx
Have a look at:
[XAML images sample] (http://code.msdn.microsoft.com/windowsapps/0f5d56ae-5e57-48e1-9cd9-993115b027b9/sourcecode?fileId=102748&pathId=677969581)
The page and samples give some code for NineGrid and WriteableBitmap Image manipulation.
You can now use Win2D (open source, released by Microsoft for metro/WinRT apps) which provides hardware-accelerated 2D graphics rendering.

Alternative to Direct X for Video Capturing On Windows 8

I have C Static Library for Capturing Video from Camera.It uses Direct X to Interface Camera.
I wanted to create API in .Net C# for Capturing Video and do not want to use DirectX. The Target OS is Windows 8.Api Should be in Such way it should work on Both Desktop and Metro Mode of the Windows 8.
Any Help will be Appreciated.
As per comments above:
DirectX is at the heart of Windows 8 / Metro...
Several sessions on DirectX in Metro were held at BUILD - see http://www.buildwindows.com/Sessions/Tagged/DirectX
Regarding DirectX in Metro see for example http://channel9.msdn.com/Events/BUILD/BUILD2011/PLAT-766T
As the whole API (WinRT etc.) is not final right now it is sure not easy to port your code right now but from what I understand it will possible...
Another point: the Metro API is packaged as WinRT which is COM with several new aspects... this API is usable from .NET + native code (like C/C++)!

Categories

Resources