I’m trying to use SFML with Visual C# 2010 Express. Here’s what I did:
- I created an empty project and added a source file;
- I copied the contents of the example from the documentation file provided with SFML;
- I renamed the namespace in that example, and I commented out the parts for a sprite and a music file;
- I replaced "arial.ttf" with an absolute path, to be sure it can find it;
- In Solution Explorer, I right-clicked the project, chose Add Reference, and on the Browse tab selected the sfmlnet-audio.dll, sfmlnet-graphics.dll and sfmlnet-window.dll from SFML’s lib folder;
- I added csfml-audio.dll, csfml-graphics.dll and csfml-window.dll from SFML’s extlib folder to the project, and in their properties I changed Copy to Output Directory to Copy if newer.
(I found out about the last two steps in
this thread.)
The problem is, only a blank console window appears. Although this problem
is mentioned in the thread linked above, no solution to it seems to be provided. So I’m asking, what’s wrong here?
Here’s the entire code:
using System;using SFML.Audio;using SFML.Window;using SFML.Graphics;namespace SFMLTest
{ 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
(string[] args
) { // Create the main window RenderWindow app
= new RenderWindow
(new VideoMode
(800,
600),
"SFML window"); app
.Closed += new EventHandler
(OnClose
); // Load a sprite to display // Image image = new Image("cute_image.jpg"); // Sprite sprite = new Sprite(image); // Create a graphical string to display Font arial
= new Font
(@"C:\Users\The Phantom\Documents\Necessary\arial.ttf"); String2D text
= new String2D
("Hello SFML.Net", arial
); // Load a music to play // Music music = new Music("nice_music.ogg"); // music.Play(); // Start the game loop while(app
.IsOpened()) { // Process events app
.DispatchEvents(); // Clear screen app
.Clear(); // Draw the sprite // app.Draw(sprite); // Draw the string app
.Draw(text
); // Update the window app
.Display(); } } }}