Converting .dds to .png: is XNA really this convoluted?

前端 未结 2 763
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 06:35

I have a .dds file and I want a .png file. Although I already found out about the DevIL.NET library, the API design there of one static class does not parallelize, so I am h

相关标签:
2条回答
  • 2020-12-20 07:17

    From the top of my head (haven't used XNA for a while):

    • Conversion of datatypes is not a common scenario for XNA. It expects to get all assets preprocessed by the content pipeline.
    • XNA expects the graphics device quite often, windowless applications are out of XNAs scope.

    It seems to me that you are using the wrong tool for the job, although I couldn't tell another one except DevIL, which you already dismissed.

    0 讨论(0)
  • 2020-12-20 07:18

    If you have a command line app that needs to create an XNA graphics device, the code in this answer should be of some assistance.

    In a nutshell, you need some of the classes from the WinForms sample to avoid having to mess around creating a graphics device services and so on (specifically the classes ServiceContainer and GraphicsDeviceService).

    Then you can do this:

    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");
    

    Tada - now you have a working ContentManager that you can use to load stuff. I believe you should be able to get the actual GraphicsDevice from the GraphicsDeviceService, too.

    The form you create is never displayed. Remember to reference System.Windows.Forms.dll in your project.

    Disclaimer: This was written for XNA 3.1. I haven't tested it in 4.0, but I suspect it will work with little or no modification.

    0 讨论(0)
提交回复
热议问题