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

Author Topic: SFML.Net 2.0 RenderTexture bug - flickering  (Read 3058 times)

0 Members and 1 Guest are viewing this topic.

SymegPL

  • Newbie
  • *
  • Posts: 13
    • View Profile
SFML.Net 2.0 RenderTexture bug - flickering
« on: July 01, 2013, 12:09:47 am »
@EDIT I updated my graphics driver and problem now doesn't occurs!
Probably this problem is caused by my graphics card (GF 7300 GT)
It's very strange because when i minimize and restore app this problem doesn't occurs!


Hello.
Sorry for my bad English.

I am clearing and drawing some vertices on RenderTexture every frame and i am drawing RenderTexture result on RenderWindow.
The image "flashes" every 10 frame.

When i am drawing directly to RenderWindow this problem doesn't occurs.

I downloaded SFML.Net 2.0 directy from the site of course.

The following video shows a bug:


Source code which i am used to make video:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML;
using SFML.Window;
using SFML.Graphics;

namespace sfmltest
{
    class Program
    {
        static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "sfml test");
            window.Closed += (s, e) => { window.Close(); };

            RenderTexture renderTexture = new RenderTexture(800, 600);

            Sprite sprite = new Sprite(renderTexture.Texture);

            Vertex[] circle = BuildCircle();

            while (window.IsOpen())
            {
                window.DispatchEvents();

                window.Clear();

                renderTexture.Clear(new Color(0, 0, 0, 0));
                renderTexture.Draw(circle, PrimitiveType.TrianglesFan);
                renderTexture.Display();

                window.Draw(sprite);

                window.Display();
            }
        }

        static Vertex[] BuildCircle()
        {
            Vertex[] circleVertices = new Vertex[36 + 2];

            circleVertices[0] = new Vertex(new Vector2f(400, 300), Color.Green);

            float currentDir = 0f;
            float dirStep = 360f / (circleVertices.Length - 2);
            for (int i = 1; i < circleVertices.Length - 1; i++)
            {
                Vector2f pos = new Vector2f();
                pos.X = (float)Math.Cos(Math.PI / 180 * currentDir) * 250f;
                pos.Y = (float)-Math.Sin(Math.PI / 180 * currentDir) * 250f;
                pos += new Vector2f(400, 300);

                circleVertices[i].Position = pos;
                circleVertices[i].Color = new Color(192, 255, 64, 64);

                currentDir += dirStep;
            }

            circleVertices[circleVertices.Length - 1] = circleVertices[1];

            return circleVertices;
        }
    }
}
 
« Last Edit: July 01, 2013, 10:58:28 pm by SymegPL »

 

anything