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

ContentTypeReader Q

Last post 04-29-2008 12:01 PM by Nick Gravelyn. 4 replies.
  • 04-29-2008 10:27 AM

    ContentTypeReader Q

    How does ContentTypeReader determine if your file is the class or whatever it's been templatized to read in?

     

    For example.

     

    Class pie {

    int cake;

    int cookie;

    }

     

    class myreader : ContentypeReader<Cookie>

     

    ok so how can I create files of type pie so that ContentTypeReader is used to read them?

  • 04-29-2008 10:35 AM In reply to

    Re: ContentTypeReader Q

    Oh wait is this reader only supposed to read things created by ContentTypeWriter?
  • 04-29-2008 10:45 AM In reply to

    Re: ContentTypeReader Q

    Sucka234:
    Oh wait is this reader only supposed to read things created by ContentTypeWriter?


    Correct.  The ContentTypeReader<>'s are used to read content from XNB files, which are created at compile-time using ContentTypeWriter<>'s.

    In the content pipeline, you have an importer and the processor, which read and translate your data, respectively.  The "output" type of the content processor, let's call it MyType, is written to the XNB file, using a class derived from ContentTypeWriter<MyType>.  At run-time, a call to Content.Load<MyType>(...) internally finds your class derived from ContentTypeReader<MyType> (which was actually defined in the ContentTypeWriter<MyType> class and stored in the XNB file as a class/assembly name) and uses it to parse the internals of the XNB file.  The XNB format itself is proprietary.
    New Microsoft DirectX/XNA MVP  (*evil laugh*)
  • 04-29-2008 11:01 AM In reply to

    Re: ContentTypeReader Q

    Awesome thanks. Slowly learning :)
  • 04-29-2008 12:01 PM In reply to

    Re: ContentTypeReader Q

    If you're interested in learning about the content pipeline, this is a good starting point: http://msdn2.microsoft.com/en-us/library/bb447745.aspx. It gives you a nice over-view of how the system was architected and how all the pieces fit together. It also links to more specific pages you can use when actually developing you content pipeline classes.

    Nick Gravelyn -- Microsoft XNA MVP
    Blog | XNA Wiki | FX-izer | EasyZip | Current Adventures | Next-Gen
Page 1 of 1 (5 items) Previous Next