Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: C# and SFML getting setup?  (Read 19619 times)

0 Members and 1 Guest are viewing this topic.

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
C# and SFML getting setup?
« on: October 04, 2009, 10:12:51 pm »
Hi guys, i wanted to try using SFML with C# so i downloaded the .Net version of the SFML assemblies, added references to them in my project but i get a (what would be in C++) linker error saying it cannot locate the csfml-graphics.dll.

Im a beginner C# programmer having only had a little experiance with the language and creating very basic projects that are quite useless :)
but perhaps someone who has experiance with C# can rectify my problem and also tell me if im doing something else wrong in my code.

Heres the code i have for my form.
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace Windows_CSharp
{
public partial class Form1 : Form
{
SFML.Graphics.RenderWindow Window;
SFML.Graphics.Shape Rectangle;

public Form1()
{
InitializeComponent();
Window = new SFML.Graphics.RenderWindow(this.Handle);
Rectangle = SFML.Graphics.Shape.Rectangle( new SFML.Graphics.Vector2( 10, 10 ),
  new SFML.Graphics.Vector2( 400, 200 ),
  new SFML.Graphics.Color( 255, 40, 40 ) );

SFML.Window.Event Event = new SFML.Window.Event();
while (Window.IsOpened())
{
// How do i monitor events sent to the window?
Window.Clear();
Window.Draw(Rectangle);
Window.Display();
}

}
}
}


It is structured as close as possible to how i would go about creating the same application in C++ (my primary language being C++)

PS: Why are there no tutorials on .Net(mainly C#) / SFML Development?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #1 on: October 04, 2009, 10:52:02 pm »
SFML.Net is a binding, which means that it requires the C binaries to work. They are provided in the archive that you downloaded ;)

Quote
PS: Why are there no tutorials on .Net(mainly C#) / SFML Development?

The .Net API is 99% the same as the C++ API.
Laurent Gomila - SFML developer

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
C# and SFML getting setup?
« Reply #2 on: October 04, 2009, 11:17:33 pm »
Quote from: "Laurent"
SFML.Net is a binding, which means that it requires the C binaries to work. They are provided in the archive that you downloaded ;)

Quote
PS: Why are there no tutorials on .Net(mainly C#) / SFML Development?

The .Net API is 99% the same as the C++ API.


Yeah i managed to link against them, apparently they need to go in the "bin" folder of your project, anywho im now faced with another problem, how do i create a main loop because whats above doesnt work.

I tried setting the main loop to run when Idle.. but that doesnt work either (its weird and slow)

Ok i found a way to do it that works.. but imo it kinda sucks that it has to be done this way..
http://code.dawnofthegeeks.com/category/c/

Although im not quite sure how SFML window events are handled in C# could i get an example perhaps?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #3 on: October 05, 2009, 08:31:54 am »
Why don't you look at the samples provided in the SDK? They show everything that you need.
Laurent Gomila - SFML developer

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
C# and SFML getting setup?
« Reply #4 on: October 06, 2009, 12:46:05 am »
Quote from: "Laurent"
Why don't you look at the samples provided in the SDK? They show everything that you need.


Ah right, i thought they were in C++..

By the way, when trying to download the .NET bindings, only the direct download gives you the correct files, i usually get the mingw version from sourceforge..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #5 on: October 06, 2009, 08:48:37 am »
Quote
By the way, when trying to download the .NET bindings, only the direct download gives you the correct files, i usually get the mingw version from sourceforge..

Sorry I don't get it. What do you mean?
Laurent Gomila - SFML developer

Hayloe

  • Newbie
  • *
  • Posts: 1
    • View Profile
C# and SFML getting setup?
« Reply #6 on: May 27, 2010, 10:22:00 am »
I dont mean to necro, Just wanted to ask a few things...

I have the binaries in the lib folder referenced, but im still missing 2 others, I'm trying to compile the OpenGL sample.

Tao.FreeGlut
and Tao.OpenGl

anything im doing wrong?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #7 on: May 27, 2010, 12:00:26 pm »
Download and install Tao.
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
C# and SFML getting setup?
« Reply #8 on: May 27, 2010, 07:51:21 pm »
Note that you do not NEED Tao to use SFML, it just allows you to interact with OpenGL directly.

Maybe in the future, it would be good to remove the Tao dependency from the sample projects. That thing hasn't been updated for a good 5 years and their site has been down for months. If you want, Laurent, I could try and rewrite the sample projects for you.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #9 on: May 27, 2010, 08:55:15 pm »
If it's not Tao, what should I use for the OpenGL and Window samples?
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
C# and SFML getting setup?
« Reply #10 on: May 27, 2010, 10:32:06 pm »
The Window sample seems to only use it to perform the rendering, so maybe just draw a 2d sprite instead? And I guess the OpenGL sample has to use some kind of binding since the point of it is to show how to work with OpenGL directly instead of through SFML, so I guess not much can be done there except use a different library (which doesn't help much). So if you can't get rid of all of it, guess its not really worth it. Would be nice if Visual Studio allowed you to have projects in a solution unloaded by default.

How about just a simple little header on the OpenGL.cs and Window.cs files stating what Tao is (briefly), the link to download it, and that SFML does not require it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #11 on: May 27, 2010, 11:08:16 pm »
Quote
The Window sample seems to only use it to perform the rendering, so maybe just draw a 2d sprite instead?

The Window sample demonstrates the use of the window package, not the graphics one. The only purpose of the window package is to provide a valid window for using OpenGL directly, so it wouldn't make sense to have a sfml-window sample with no OpenGL :)

Quote
And I guess the OpenGL sample has to use some kind of binding since the point of it is to show how to work with OpenGL directly instead of through SFML, so I guess not much can be done there except use a different library (which doesn't help much). So if you can't get rid of all of it, guess its not really worth it.

That's the point of this sample, showing how to mix with OpenGL. And I had the impression that Tao was the most "standard" OpenGL binding for .Net, that's why I'm using it.
So... what's the problem actually? It doesn't prevent from properly compiling and running the other samples, right?

Quote
How about just a simple little header on the OpenGL.cs and Window.cs files stating what Tao is (briefly), the link to download it, and that SFML does not require it.

People who know nothing about Tao will most likely not be interested in this sample.
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
C# and SFML getting setup?
« Reply #12 on: May 28, 2010, 12:16:42 am »
Ah that makes sense then. I obviously didn't check the samples out too well. ;)

But reason I mentioned that was when I was first checking out SFML, it took quite a while to get things working. Thinking I needed Tao (who's site was still down back then) was the first obstacle. There was also the problem with running the .NET bindings on a x64 machine when they were built for Any CPU which gives a quite confusing error message. The last issue I can think of was just working with the build process since you have to manually copy over the binaries to the build directory (or resources over to the \bin\ for each project). The Tao one can probably be fixed with just a little header comment on the projects using Tao, the second we talked about in another thread, and the third by just setting the project output directories.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
C# and SFML getting setup?
« Reply #13 on: May 28, 2010, 08:58:08 am »
Quote
The last issue I can think of was just working with the build process since you have to manually copy over the binaries to the build directory (or resources over to the \bin\ for each project)

On my computer it's properly set up, I don't have to copy anything. What files did you have to copy exactly?
Laurent Gomila - SFML developer

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
C# and SFML getting setup?
« Reply #14 on: May 28, 2010, 09:14:54 am »
Sorry, I guess I was thinking of 1.5 with the resource copying. But you still have to copy over the csfml-*.dll files into \samples\bin\ to get them to run.