简体   繁体   中英

Setting up SFML.net 2.1?

How do you go about "properly" setting up SFML for VS 2013? While a few places have given me a bit of information how to do it, nothing quite seems to work except one thing: SFML MS2012 Extension. However, I'd like to know how to do this from scratch for VS 2013 without the need of the extension.

Here is the current process I am using without the extension:

1) Open new project in VS 2013.

2) Add References to SFML libs(dlls): sfml-audio-2, afml-graphics-2 and sfml-windows-2.

3) Add extended libs via add-existing files: csfml-audio-2, csfml-graphics-2, csfml- windows-2, libsndfile-1 and openal32.

4) Create application.

Between the extension and doing everything myself, the noticeable difference is the GUID in the assembly information, yet if I attempt the previous steps and insert the GUID from the extension project into the new project, my attempt still fails to work even though the projects end up looking exactly the same. On top of which, where does the GUID come from and how do I go about getting it?

Secondary Question: Does XNA have all of the audio/graphic/window handling as SFML does? If so would it be better to switch to XNA than use SFML.Net?

  1. Create a new C# project in Visual Studio 2012/2013/2015. It can be a Console Application or a Windows Forms Application. The only difference is, that a Windwos Forms Application generates a Form wich you can safely remove and the Console Applications shows a Console in the background.
  2. Right-click your project in the Solution Explorer and click on Add Reference…
  3. When the Reference Manager window appears, browse to the folder where you extracted the SFML.net archive and go to the lib folder. Select all the .dll files in the lib folder and Click on 'OK' in the Reference Manager to add them to your project.
  4. Once the .dll files appear in the References section of your project, right-click your project again and click on Add > Existing Item… Navigate to the extlibs folder and add all the .dll files there (you may have to select .dll files as file filter in the Open dialog box) .
  5. Once these .dll files appear on your Solution Explorer, right-click on them and select Properties (or press Alt-Enter) . In the Copy to Output Directory property, set it to Copy if newer .
  6. SFML.net is now set-up for your project. To test it you can run this example code:

     using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using SFML; using SFML.Graphics; using SFML.Window; namespace SFML_Test { static class Program { static void OnClose(object sender, EventArgs e) { // Close the window when OnClose event is received RenderWindow window = (RenderWindow)sender; window.Close(); } static void Main() { // Create the main window RenderWindow app = new RenderWindow(new VideoMode(800, 600), "SFML Works!"); app.Closed += new EventHandler(OnClose); Color windowColor = new Color(0, 192, 255); // Start the game loop while (app.IsOpen()) { // Process events app.DispatchEvents(); // Clear screen app.Clear(windowColor); // Update the window app.Display(); } //End game loop } //End Main() } //End Program } 

It should output this: 在此处输入图片说明

I have set up my SFML.Net projects in Visual Studio 2013 and 2015 through this tutorial . I used some of the text from it for this answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM