XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

Winforms sample - best way to load Effect?

Last post 05-28-2008 11:56 PM by Shawn Hargreaves. 7 replies.
  • 04-18-2008 2:00 AM

    Winforms sample - best way to load Effect?

    I have a winforms project based on the 2nd winforms sample (content loading).  I don't want to dynamically run the content importer at run time - at least for most things - like my .fx files - I'd rather have it put at compile time into the .xnb file (I think?) like a normal game.

    What's the best way to go about doing that given that my project doesn't really know about content like a regular xna game project does?  Is there a way to "add that functionality" (e.g. the Content folder) to my project?

  • 04-18-2008 2:50 AM In reply to

    Re: Winforms sample - best way to load Effect?

    The easiest way is to add a "Windows Game Library" project to your solution. This contains a Content project that you can use to import and compile your assets. Set the project's output folder to the same as your Winforms project.

    Note: This will create a dll and pcb file for the project which you can just delete after build.

    --
    Ruina et Stragos
    XNA SA
    --
  • 04-18-2008 10:09 AM In reply to

    Re: Winforms sample - best way to load Effect?

    Thanks!

    I ended up making a new library project, and putting the content in there - and then the winforms project uses that library. 

    And somehow the library's content files are being copied to the output directory of the winforms project when I build - not sure how/why that's happening, but it's good.

  • 04-18-2008 11:34 AM In reply to

    Re: Winforms sample - best way to load Effect?

    You can do this the same way we did for the spritefont in the sample. The section in the sample doc titled "Loading Content" explains how we set this up.
    XNA Framework Developer - blog - homepage
  • 05-28-2008 1:26 PM In reply to

    Re: Winforms sample - best way to load Effect?

    I've tried this and it just adds the 'Content.contentproj' as a file.
  • 05-28-2008 6:04 PM In reply to

    Re: Winforms sample - best way to load Effect?

    You need to choose the "Add Project" menu on your solution root. You probably did "Add Item" on your project node.
    XNA Framework Developer - blog - homepage
  • 05-28-2008 10:39 PM In reply to

    Re: Winforms sample - best way to load Effect?

    So you just use the Content control in the second game project? The doc made it sound like there was a way to copy over the content control to the real game project.
  • 05-28-2008 11:56 PM In reply to

    Re: Winforms sample - best way to load Effect?

    You can add a .contentproj directly to your solution: you don't need a game library or game project to do this. As the sample doc puts it:
    First, you must build the content alongside your project. This is done by adding an XNA Framework content project to your solution. There is no direct way to create a content project. You can make one by creating a temporary "Windows Game" project, then copy the resulting .contentproj file into the same directory as your WinForms application and add it to the solution. The .contentproj extension is not recognized by the Add Existing Project dialog box, so you must type in the entire project file name (including extension). You can now add content files, such as the Arial.spritefont used in the sample, to this content project. To ensure the content project will always be built before you run the program, right-click the main project, choose Project Dependencies, and check the content project. To make sure the output content files are placed in the right directory, open the properties for the content project, and set its Build / Output path property to the correct location (make sure you do this for both the Debug and Release project configurations).
    Have you followed those steps? If so which specific part of that is not working for you?
    XNA Framework Developer - blog - homepage
Page 1 of 1 (8 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG