how can i use content manager in console aplicatio

2019-08-27 18:42发布

how can i use content manager in console application to load a new Model?

I want to load mesh data without any display ?

标签: c# xna
1条回答
Juvenile、少年°
2楼-- · 2019-08-27 18:59

Check out my answer to this question. It contains code for getting a ContentManager working in a console application.

To duplicate it here briefly:

You need the ServiceContainer and GraphicsDeviceService classes from the WinForms sample. Then just use this code:

Form form = new Form(); // Dummy form for creating a graphics device
GraphicsDeviceService gds = GraphicsDeviceService.AddRef(form.Handle,
        form.ClientSize.Width, form.ClientSize.Height);

ServiceContainer services = new ServiceContainer();
services.AddService<IGraphicsDeviceService>(gds);
content = new ContentManager(services, "Content");

And, of course, include the necessary references (System.Windows.Forms.dll).

查看更多
登录 后发表回答