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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - BinarySpike

Pages: [1]
1
DotNet / SFML C# with OpenGL.net
« on: August 16, 2017, 09:26:59 am »
I'm trying to integrate SFML C# with OpenGL.net.  Unfortunately, whenever I call any Gl calls, the "window.clear" simply ceases to work.  I just want proof that they are working together properly before I move on to my next stage.

If I set it to clear red with SFML, it works fine until I add a "Gl" call.

Here is my current test code broken by "Gl.Initialize()":
class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {

            // Create the main window
            RenderWindow window = new RenderWindow(new VideoMode(640, 480), "SFML window with OpenGL");
            window.SetVerticalSyncEnabled(true);

            // Setup event handlers
            window.Closed += new EventHandler(OnClosed);
            window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
            window.Resized += new EventHandler<SizeEventArgs>(OnResized);

            Gl.Initialize();

            // Start the game loop
            while (window.IsOpen)
            {
                // Process events
                window.DispatchEvents();

                window.Clear(Color.Red);
                window.Display();
            }
        }

        /// <summary>
        /// Function called when the window is closed
        /// </summary>
        static void OnClosed(object sender, EventArgs e)
        {
            Window window = (Window)sender;
            window.Close();
        }

        /// <summary>
        /// Function called when a key is pressed
        /// </summary>
        static void OnKeyPressed(object sender, KeyEventArgs e)
        {
            Window window = (Window)sender;
            if (e.Code == Keyboard.Key.Escape)
                window.Close();
        }

        /// <summary>
        /// Function called when the window is resized
        /// </summary>
        static void OnResized(object sender, SizeEventArgs e)
        {
            Gl.Viewport(0, 0, (int)e.Width, (int)e.Height);
        }
    }

Pages: [1]