resource files shortfalls
Recently I had the pleasure of wrestling with a bear.
I also had the more painful experience of dealing with standard microsoft way of thinking.
My problem is with resource files. You know, .bmp files for example.
Now it SEEMS there are some neat ways to include them in your XNA project. You can add a folder using the solution explorer, and put your images in there all nice and in one place for easy references. Or, you can go to Project->(name)Properties, click the resources tab, and add a resource that way. Or you can dump all your images in the same directory as your source files. Ugh. Why would you want to do that when theres so many other nifty ways to do it huh? Plus, you could have up to eleventy image files in your game!!
So lets see about loading a texture resource. You have a file named image.bmp in the same directory as your source code. One way that works is :
imageTex = content.Load<Texture2D>("image");
And this works fine. Predictable. Reliable. Linux-like.
"image" by the way is not the filename!! Its the 'asset name'. Right click your image in solution explorer, and if your build action == "content", you can see this asset name. So, .bmp is not required, and in fact will throw an exception if you use it here. Makes perfect sense right, have it seem to be a filename, and throw an error they cant solve until they realize 'asset name' != 'file name'.
So lets add image.bmp as a resource instead, using the handy dandy Project Properties GUI for it. Go to Project->(name)Properties, Resource tab, and Add Resource->Existing File. Compile and run.
IF (big if here): your image.bmp is in the same spot as before, that is, in your source code folder, it works. In fact, its pulling that file from that directory, NOT from a resource of some kind. The Project->Properties GUI DOES NOTHING! (the goggles... they do nothing!) For proof, place the file somewhere else, or change the properties of the image.bmp in solution explorer to "build action = Embedded Resource", and you get file not found errors. It suddenly cant find the file. Even if you change "Copy to output directory" to "Copy Always" *it cant find image.bmp*. So whats the use of using this GUI if you get the same results by not using it? And whats the use of "build action" if only "content" will work?
Similar things happen if you use solution explorer to add a folder, than add your image in it. Heres the really fun part : no amount of file path finangling will let you navigate to that image in that folder. What seems at first to work like a file path is not. Nice tripwire microsoft.
The only way I have ever been able to add an image successfully was having it reside in the same directory as the source files, (build action == content) which is poopy if you ask me. We have these other toys to play with, but cant use them.
Now its 99% possible Ive missed something, and in a matter of seconds after hitting Submit some guy with a red or orange color in his name will come by and wtfpwn me. In fact, I hope Ive missed something, because as it is now, some features definetly feel broken, which leads me to suspect all of VS(EE) / XNA is prone to buggering, and maybe not worth the effort. (Hey Im here as a hobbyist).
Proof in the documentation that this is screwy :
In the XNA Tutorial 1 : Displaying a Model on the Screen :
myModel = content.Load<Model>( "Content\\Models\\p1_wedge" );
WILL NOT WORK! Good luck with dealing with the frustration it brings, mr hobbyist game programmer.
use this instead :
myModel = content.Load<Model>( "Content/Models/p1_wedge" );
In the XNA Tutorial 1 : Displaying a Model on the Screen :
myModel = content.Load<Model>( "Content\\Models\\p1_wedge" );
WILL NOT WORK! Good luck with dealing with the frustration it brings, mr hobbyist game programmer.
use this instead :
myModel = content.Load<Model>( "Content/Models/p1_wedge" );
Too right, but if you think that's bad, try using directx 8, the documentation doesn't tell you how to use the resource texture loading functions at all, no matter how carefully you read the wording. They might as well have not bothered to implement them.
I'm more than happy for people to voice their opinions on the MS technologies, but lets keep it clean and civilized.
Regarding XNA's content loaders and pipeline - I've not really bothered with XNA:GSE yet but I have sat in on a few livemeetings and presentations on the topic. I get the impression that, due to the multi-platform nature there are various compromises as a result. I don't know if it's the case here, but maybe the abstracted file system is due to the differences between XBox360 and PC's?
As for the DX8 resource loaders - yes, the documentation has never been particularly good for these. I know I got it working in one project, only to find out the bloat it added to my .exe (couldn't be bothered to create seperate components just to store content [rolleyes]) really hurt performance. Have you searched for examples (both DX8 and DX9) online? There must be a fragment somewhere that demonstrates correct usage [smile]
Cheers,
Jack
Regarding XNA's content loaders and pipeline - I've not really bothered with XNA:GSE yet but I have sat in on a few livemeetings and presentations on the topic. I get the impression that, due to the multi-platform nature there are various compromises as a result. I don't know if it's the case here, but maybe the abstracted file system is due to the differences between XBox360 and PC's?
As for the DX8 resource loaders - yes, the documentation has never been particularly good for these. I know I got it working in one project, only to find out the bloat it added to my .exe (couldn't be bothered to create seperate components just to store content [rolleyes]) really hurt performance. Have you searched for examples (both DX8 and DX9) online? There must be a fragment somewhere that demonstrates correct usage [smile]
Cheers,
Jack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement