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

Author Topic: Drawing polygon  (Read 4173 times)

0 Members and 1 Guest are viewing this topic.

Xyro

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Drawing polygon
« 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();
        }
    }
}

Terrydil

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Drawing polygon
« Reply #1 on: January 01, 2011, 09:28:50 pm »
You need renderWindow.Display() in your Draw()

Xyro

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Drawing polygon
« Reply #2 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 ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Drawing polygon
« Reply #3 on: January 03, 2011, 08:03:55 pm »
Recent ATI driver?
Laurent Gomila - SFML developer

Xyro

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Drawing polygon
« Reply #4 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 ...

Xyro

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Drawing polygon
« Reply #5 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 !