11
\$\begingroup\$

Wondering if there is anyway to run an XNA game with out displaying anything.

I have a working game that runs in a client server setup where one player is the host and other people can connect to his game.

I now want to be able to run the game as a host on a decicated server with no graphics card, basically I dont want to run any Draw() logic at all.

Do i really need to go through the entire game and remove all references to XNA?

How have people done this?

EDIT: The reason I want to do this is because I have a working client server setup in the game and I dont want to make a separate "headless" server program.

\$\endgroup\$
  • \$\begingroup\$ Why can't you just write code in Draw like if (headless) { return; }? \$\endgroup\$ – ashes999 Feb 4 '13 at 2:41
  • 1
    \$\begingroup\$ @asher999 Not sure if that will completely remove all draw and graphics logic from the game. A virtual server may not have any real graphics adapter at all. \$\endgroup\$ – JensB Feb 4 '13 at 11:44
  • \$\begingroup\$ Changing the output type or skipping drawing will not magically remove XNA's dependency on a graphics device. If you are loading any content that requires a graphics device (especially textures) there is a very good chance those will fail to load using either of the proposed solutions. \$\endgroup\$ – dadoo Games Feb 11 '13 at 14:14
10
\$\begingroup\$

Just make a normal C# project and include the XNA binaries. This will gain you access to the XNA data types and framework methods. My game does this and it works flawlessly.

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm guessing you wrote a wrapper that acts like XNA calling the needed methods such as Update for you? I'll give this a go, thanks. \$\endgroup\$ – JensB Feb 4 '13 at 11:46
2
\$\begingroup\$

The answer is: don't do this. If you don't need to make a game - i.e; you're not looking to take advantage of the things XNA offers, why do it? You really should be looking into developing a custom piece of software that can successfully simulate the game you wish to play - typically a console system of some sort. If you give more details, I will update my answer with a less generic response.

\$\endgroup\$
  • 1
    \$\begingroup\$ I can give you one reason: unit testing. Often you want to test a piece or section of code without having to load or draw and graphics. \$\endgroup\$ – Stephen Tierney Feb 4 '13 at 1:10
  • 3
    \$\begingroup\$ @StephenTierney I can give you one other reason: he's not trying to, he's trying to run a game server (on a dedicated machine). Please re-read the question and consider taking back your downvote. \$\endgroup\$ – Vaughan Hilts Feb 4 '13 at 1:11
1
\$\begingroup\$

Well if you simply wish to eliminate the draw calls have you tried using this : Suppress Draw

\$\endgroup\$
1
\$\begingroup\$

To build on untitled's suggestion, you can just include references to the DLLs and use them without using any of the default game loops. For examples of this you can look at the winforms tutorial series on the creators club: http://xbox.create.msdn.com/en-us/education/catalog/sample/winforms_series_2

Also if you want to get even more fancy you can replace the entire XNA game loop with your own custom one, and control the entire process. For more information on this look at https://stackoverflow.com/questions/6361691/custom-xna-game-loop-in-windows

\$\endgroup\$
1
\$\begingroup\$

If you change the Output Type of a XNA Project to "Console Application", the application will simply open an empty Console at start-up, without ever opening the actual game's window. This might be useful for what you are trying to accomplish, since you want to do tests, and you can very easily use the Console as a debug window.

\$\endgroup\$
1
\$\begingroup\$

You can also consider overriding the update and draw calls, and simply return.

Also, dont call the graphicsdevice in your main game classes, which should stop the xna window from being instanced on the game acting as your server.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.