SFML community forums

Bindings - other languages => DotNet => Topic started by: The Phantom on July 27, 2012, 10:51:54 pm

Title: Using SFML with Visual C#
Post by: The Phantom on July 27, 2012, 10:51:54 pm
I’m trying to use SFML with Visual C# 2010 Express. Here’s what I did:(I found out about the last two steps in this thread (http://en.sfml-dev.org/forums/index.php?topic=7674.0).)

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();
         }
      }
   }
}
Title: Re: Using SFML with Visual C#
Post by: zsbzsb on July 28, 2012, 01:23:39 am
Everything you are doing is correct, except one minor detail. You are using SFML 1.6. SFML 1.6 contains an ATI graphics card bug that causes issues. That I is probably your trouble with the window not showing. To fix it download the SFML.Net 2.0 RC and try that. It should fix all of your trouble  ;)
Title: Re: Using SFML with Visual C#
Post by: The Phantom on July 28, 2012, 09:50:21 am
Thank you, SFML 2.0 RC soved the problem!