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

Author Topic: New to SFML .NET -- Some questions.  (Read 5641 times)

0 Members and 1 Guest are viewing this topic.

Fernando

  • Newbie
  • *
  • Posts: 4
    • View Profile
New to SFML .NET -- Some questions.
« on: February 27, 2015, 11:26:43 am »
Hello Everyone.

I'm very interested in using SFML in my Game project but I need first to clear some things out of my mind.

1 - Since my game's engine is used also through an editor, I need to know how can I bind SFML's device to a panel or through any other mean that will allow me to anchor its display area and resize it on-the-fly.

2 - I see a Network namespace in other versions of SFML but I can't  find it.NET version. Where is it?

3 - I added the .NET version DLLs of SFML to my project by referencing them on it. Is there anything else I need to do? What are the cfsml dlls? Do I need to copy them to my project's output path?

4 - It seems SFML can also handle time but I can't find a way of using it in .NET version. Where is the SFML's Time object?

Sorry about these potential stupid questions -- I'm just a newbie. And thanks for any possible help regarding these topics!
« Last Edit: February 27, 2015, 11:28:53 am by Fernando »

Fernando

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: New to SFML .NET -- Some questions.
« Reply #1 on: February 27, 2015, 02:26:41 pm »
Correct me if I'm wrong but I think point 2 and 4 were left out on purpose because the user has better control over them through .NET itself?

Nonetheless, it would be rather nice to have delta time automatically calculated in SFML. :)

Fernando

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: New to SFML .NET -- Some questions.
« Reply #2 on: February 27, 2015, 03:34:42 pm »
Ok. I've been searching the forum for any info on my topics and I developed this code (more like copy&pasted it):

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SFML.Graphics;
using SFML.Window;

namespace SFML
{
    public partial class EFile_SFMLRenderWindow : UserControl
    {
        public SFML.Graphics.RenderWindow renderwindow;
       
        public EFile_SFMLRenderWindow()
        {
            InitializeComponent();
            renderwindow = new SFML.Graphics.RenderWindow(this.Handle);
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            System.Windows.Forms.Application.DoEvents();
            renderwindow.DispatchEvents();
            renderwindow.Clear(SFML.Graphics.Color.Green);
            renderwindow.Display();
        }

        protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
        {
           
        }

        private void EFile_SFMLRenderWindow_Load(object sender, EventArgs e)
        {

        }
    }
}

The problem is that it throws an exception when I try to add it to a form. The errors points to this line:
renderwindow = new SFML.Graphics.RenderWindow(this.Handle);

---------------------------
Microsoft Visual Studio
---------------------------
Failed to create component 'EFile_SFMLRenderWindow'.  The error message follows:

 'System.DllNotFoundException: Unable to load DLL 'csfml-graphics-2': Impossível localizar o módulo especificado. (Exception from HRESULT: 0x8007007E) (...)
---------------------------
OK   
---------------------------

Why is it unable to locate the mentioned DLL? I can use SFML from that very form I'm trying to add this control in.


« Last Edit: February 27, 2015, 05:00:22 pm by Fernando »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: New to SFML .NET -- Some questions.
« Reply #3 on: February 27, 2015, 05:48:56 pm »
The error is pretty clear: the CSFML DLLs cannot be found. They must be in the same folder as your executable, or in a directory which is in the PATH environment variables.

The system module (and time handling) is now part of SFML.Net, I don't remember if it is already in 2.1 or only in the upcoming 2.2 though.
Laurent Gomila - SFML developer

Fernando

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: New to SFML .NET -- Some questions.
« Reply #4 on: February 27, 2015, 08:44:23 pm »
The CSDML DLLs are in the same folder where the excutable is and I can successfully open a SFML window and print text on it. But for some reason, the Custom Control that is part of this very project, doesn't find such DLLs.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: New to SFML .NET -- Some questions.
« Reply #5 on: February 27, 2015, 10:39:56 pm »
It shouldn't change anything. Unless this specific class uses a SFML module that is not used anywhere else in your project.
Laurent Gomila - SFML developer

Jackieryder

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: New to SFML .NET -- Some questions.
« Reply #6 on: March 23, 2015, 02:39:32 am »
Laurent, I'm pretty sure that's not it.

I'm having the exact problem, I can't create a user control by dragging it into the form.

The csfml-window are in both my debug folder and in the source folder. And like Fernando said: i am able to run SFML normally on the form just fine/able to create sfml RenderWindow on its own without using form just fine.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: New to SFML .NET -- Some questions.
« Reply #7 on: March 23, 2015, 12:30:26 pm »
Laurent, I'm pretty sure that's not it.

Yes it is it, when you are using the visual designer for winforms the current working directory is generally the IDE's installation folder.

For example, when I am working with the designer the working path is "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common/IDE".

You can test it by dropping the following code into your user control's constructor and then reloading the designer (after recompile of course).

MessageBox.Show(System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]));

So you must do as Laurent said, put the CSFML dlls in the working path (not recommended if it is your IDE's installation directory) or add them to a path that is defined in the system PATH variable.

Another option is to disable SFML's rendering at design time, so you need to check if you are currently in design mode.

And the third option is to avoid using the designer for custom controls that use SFML for rendering, instead add them in your own code in the form constructor after InitializeComponent() has been called.
« Last Edit: March 23, 2015, 12:35:18 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor