Sign in to follow this  
SozSurt

[.net] Making XNA work with J#, VB and C++

Recommended Posts

Hi, I've been working on a project to bring XNA to other Express languages, so far I've managed to make it work on Visual J# Express 2005, Visual C++ Express 2005 (thanks to managed c++ code) and Visual Basic Express 2005, I've re-written the Program and Game1 classes for all of these and XNA is now running on them, I even made templates for Visual Basic and Visual J#, I didn't make templates for c++ because there isn't an export template option on the menu (if anyone knows how I would appreciate if you told me). So now that XNA is running on all 4 Visual languages, I ran into a little problem (or big depending on how easy it will be to solve) which is using the Content Pipeline to handle the content and convert it to xnb files, so I'm posting this to ask for peoples help. I need to know how VC# and XNA handle the file conversion, I also need to know if there's a way for me to add that XNA Framework Content Pipeline menu to the properties menu like it shows up in VC# when checking the properties of an image or model, where it shows the properties like Asset Name, etc. Basically, I need to make VB, VC++ and VJ# convert the content files to xnb files like VC#+XNA does. I'm making this so that people who know one of the languages don't have to learn C# just to make games. (just fyi, making it work on VC++ was a real pain in the ass, mainly cause I haven't coded in C++ in ages but also because I needed to use managed c++ code, so I had to play with an extra command on the command line, but it works fine now). If you guys want the code as it is now I'll be happy to share it, but first I would like some help on what I mentioned above, so I can release the templates with support for image, model, etc content. Thanks in advance, SozSurt

Share this post


Link to post
Share on other sites
You're going to have to write a plugin. Note though that you can't write plugins for the express IDEs, so you're pretty much out of luck with them. This would only work with nonexpress versions. However, it would let you intercept build events and add options to menus.

But this is probably a moot point: you do realise that anything you do will likely only run in windows, right? Just checking. Not only would transfering binaries and content to the 360 require privileged access not available to you, but the xbox's version of the compact framework has a more limited runtime. For example, only very carefully written vb.net code will execute on it: pretty much only code that doesn't use vb.net specific features that aren't supported on the compact framework. Purely managed C++/CLR MAY run on it, but definately won't work if there's any unmanaged code at all.

On the other hand, if you only want it to work in windows, you don't need to fully duplicate the c# version. Despite claims of it making things easier (which I consider to be debatable), the only reason the content pipeline exists is that it's required by consoles. So to me, considering that you pretty much have to use c# to use the 360 anyways, the best solution is to not use the pipeline at all. Loading things like textures yourself with Xna is trivial.

[Edited by - gharen2 on November 26, 2007 5:41:33 PM]

Share this post


Link to post
Share on other sites
Yeah, I'm aware it won't work on the XBox360, I just made the code for Windows because I don't really own an XBox360 and I guessed it wouldn't work on it anyways. But since the PC is a different matter and the code worked on the other languages I gave it a go.

So, do I still need to convert the content files to xnb files for them to load or is there a way to load them as they are? My first and only idea so far is to get a program that converts files to xnb that runs on the command line, include it with the templates and find a way to convert all the content to xnb (and hope the assetname will be the same name as the name given to the file). I still have to give it a try (maybe start with compiling a simple game in VC# and then use the xnb files that are created and try to run the same game on a different language, already with the xnb files). Since I'm a student and can't really afford a version of Visual Studio other than Express (because it's free), I'll have to find a way around the problem that doesn't use plugins.

So, I'll give it a try and report my progress later. Thanks for your reply.

Share this post


Link to post
Share on other sites
The thing about the Xna framework is that it's divided into different libraries, and you don't have to use all of them. You can pick and choose what you want to use.

For example, I don't use the Game framework, but I do use the content pipeline. This is because it's incorporated into an existing engine, which the Game framework isn't designed to do. As one of the Xna devs told me, choosing to not use the Game class is perfectly reasonable. The core of Xna's graphics API is low level and equivalent to DirectX. Just as you can manually create the graphics device yourself, you can also load content yourself. I use the content pipeline in the 360 build of the engine (because I have to), but I don't use it in the windows build, so that the engine can be used in non-c# languages.

For example, look up Texture2D.FromFile. It returns a texture created from the given file, just like in Direct3D. It can be png, tga, bmp, jpg, and probably others I'm not aware of. This method only exists in windows, as the console environment doesn't allow you to do such a thing.

This also means that yes, as long as you're only working in windows, you don't need to worry about converting resources to xnb. That's strictly a console requirement.

In your case you want to use the Game class but not the content pipeline. Using the Game class template as an example:

- you'd remove the ContentManager
- remove it's creation from the Game constructor
- in LoadGraphicsContent, use Texture2D.FromFile instead of content.Load<Texture2D>()
- call Texture2D.Dispose() for each texture instead of content.Unload();

In addition, you wouldn't require any sort of plugin. You can already add images and such to a project, which will be automatically copied to where the executable is.

Now, a cautionary note: I haven't used Xna's model stuff, I use my own code for that. A cursory look suggests that you can only load models through the content pipeline. I could be wrong though. That's definately something you'll want to look up. If not you may have to write your own loader.

[Edited by - gharen2 on November 27, 2007 1:42:55 AM]

Share this post


Link to post
Share on other sites
Sorry for the bumping & double posting.

I just want to announce I finished it, I didn't create a new class to handle but I included instructions on how to do it, I also gave up on the C++ version since it runs fine, but when it's time to compile it goes crazy. I might look into it later. Anyways, I made it work on VB and VJ#. So here are the templates for anyone who wants them: http://rapidshare.com/files/72766779/XNA_1.0_Templates.zip.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this