SFML community forums

Bindings - other languages => DotNet => Topic started by: Xyro on January 01, 2011, 05:57:38 pm

Title: Drawing polygon
Post by: Xyro on January 01, 2011, 05:57:38 pm
For some reason I can't get a polygon to draw, it only shows a blank screen.

Code: [Select]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace MusicSFML
{
    class World
    {
        Shape polygon = new Shape();
        public RenderWindow renderWindow = new RenderWindow(new VideoMode(1280, 720, 32), "Look at this it may even work");

        public World()
        {
            renderWindow.Closed += new EventHandler(OnClosed);
            renderWindow.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

            polygon.AddPoint(new Vector2(10, 10), Color.Black);
            polygon.AddPoint(new Vector2(50, 10), Color.Black);
            polygon.AddPoint(new Vector2(50, 30), Color.Black);
            polygon.AddPoint(new Vector2(10, 30), Color.Black);
            polygon.Color = Color.Black;
            polygon.EnableFill(true);
            polygon.EnableOutline(true);
        }

        public void Think()
        {
            // Proccess events
            renderWindow.DispatchEvents();

            float frameTime = renderWindow.GetFrameTime();
        }

        public void Draw()
        {
            renderWindow.Clear(Color.White);
            renderWindow.Draw(polygon);
        }

        void OnClosed(object sender, EventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            window.Close();
        }

        void OnKeyPressed(object sender, KeyEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            if (e.Code == KeyCode.Escape)
                window.Close();
        }
    }
}
Title: Drawing polygon
Post by: Terrydil on January 01, 2011, 09:28:50 pm
You need renderWindow.Display() in your Draw()
Title: Drawing polygon
Post by: Xyro on January 03, 2011, 07:58:50 pm
Oke well this is weird, everything worked as expected yesterday. when I wanted to check out if this worked it just stopped working. I managed to find out that it hangs on creating renderwindow

It just opens the console and it goes to the creating of the renderwindow and just hangs there no crash no errors.

Tried removing underthings and just opening a simple window. also tried re downloading. any  suggestions ?
Title: Drawing polygon
Post by: Laurent on January 03, 2011, 08:03:55 pm
Recent ATI driver?
Title: Drawing polygon
Post by: Xyro on January 03, 2011, 08:46:50 pm
Fuck just read the other topic, I'll see if it auto updated or something. I'll probably downgrade it otherwise ...
Title: Drawing polygon
Post by: Xyro on January 03, 2011, 09:00:53 pm
Quote from: "Xyro"
Fuck just read the other topic, I'll see if it auto updated or something. I'll probably downgrade it otherwise ...


Works now downgraded !