[C#][XNA 3.1] How can I host two different XNA windows inside one Windows Form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • secutos
    New Member
    • Aug 2008
    • 15

    [C#][XNA 3.1] How can I host two different XNA windows inside one Windows Form?

    I am making a Map Editor for a 2D tile-based game. I would like to host two XNA controls inside the Windows Form - the first to render the map; the second to render the tileset. I used the code here to make the XNA control host inside the Windows Form. This all works very well - as long as there is only one XNA control inside the Windows Form. But I need two - one for the map; the second for the tileset. How can I run two XNA controls inside the Windows Form? While googling, I came across the terms "swap chain" and "multiple viewports", but I can't understand them and would appreciate support.

    Just as a side note, I know the XNA control example was designed so that even if you ran 100 XNA controls, they would all share the same GraphicsDevice - essentially, all 100 XNA controls would share the same screen. I tried modifying the code to instantiate a new GraphicsDevice for each XNA control, but the rest of the code doesn't work. The code is a bit long to post, so I won't post it unless someone needs it to be able to help me.

    Thanks in advance.
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I've only ever done it with one XNA object myself, so I can't really tell you exactly how, but on the topic of multiple viewports it didn't look so bad... give it a try?


    Comment

    • regalis
      New Member
      • Mar 2010
      • 9

      #3
      Help for XNA on a WinForm

      Hi Secutos,
      i found lately a working example which show how to add an xna frame on a WinForm.
      The only thing you have to do is change the SpinningTriangl eControl.cs to your liking.
      It's a custom Control which you can add to your form in the designer.
      Here is the link to the Tutorial:
      1) http://creators.xna.com/en-us/sample/winforms_series1
      2) http://creators.xna.com/en-us/sample/winforms_series2

      Hope you like it just like i do ;)

      greets regalis

      I have attached a sample preoject with a spinning Sphere and some spritebatch text ;)
      Btw.: You have to change the project options to compile for x86 processor x64 won't run ;)
      Attached Files

      Comment

      • regalis
        New Member
        • Mar 2010
        • 9

        #4
        Ops, just saw that the compiled binary is in the attached .zip
        --> SORRY about that! (Just delete it)

        Comment

        • secutos
          New Member
          • Aug 2008
          • 15

          #5
          Thanks so much for the replies everybody.

          Comment

          Working...