1

I have a mostly complete C# winform app (it is huge, so I can't really rewrite it from scratch), and I want to add an sdl.net window to it, so as to show some of what my app does in a complex graphical manner (the sdl.net window must in some way get steady flow of data from my app, so i can't just make another project).

The problem is how do I do it? Are there any common practices for this kind of thing? Or a tutorial where something similar is done?

In a nutshell, can I add sdl.net window to a C# winform app, and if so then how?

j0k
  • 22,600
  • 28
  • 79
  • 90

1 Answers1

0

You could create your own sdl.net window class that will make use of the SdlDotNet.Graphics.Video.SetVideoMode() method when created, handle graphical operations internally and provide public methods to be called from your winform app.

Something like that:

using System.Drawing;
using SdlDotNet.Graphics;

public class SdlWindow
{
    private Surface screen; // the display Surface

    /* ctor */
    public SdlWindow(Size size)
    {
        screen = Video.SetVideoMode(size.Width, size.Height);   // create a new sdl Surface and its own window container
        Video.WindowCaption = "Sdl Window";
    }

    /* your methods */
    public void DrawRectangle(Rectangle rect)
    {
        screen.Fill(rect, Color.Red);
        screen.Update();
    }

    /* cleanup a bit */
    public void Dispose()
    {
        if (screen != null)
            Video.Close();
    }
}

Don't forget to add a reference to the SdlDotNet.dll library in your project.

Hope this helps!

Olivier
  • 858
  • 8
  • 17