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 - Nameless

Pages: [1]
1
DotNet / Re: Background not displayed properly with multiple shapes
« on: December 24, 2012, 12:03:24 am »
Thank you for your answer.
I've just took a look at the shader example and it looks amazing!
One more stuff to learn! ^^

2
DotNet / Re: Background not displayed properly with multiple shapes
« on: December 23, 2012, 10:47:03 pm »
Tried three times, no way to install the latest beta driver. Always got an error in the install log.
Guess I have to wait until the 12.11 final release...

By the way, is the use of a buffer and then Texture.Update the fastest way to fill the whole screen with custom pixels? It's still a bit slow on 1650x1080...

3
DotNet / Background not displayed properly with multiple shapes
« on: December 23, 2012, 06:33:32 pm »
Hello everyone,

I'm new to the SFML lib, using it since two weeks or so. Very nice lib, fast and simple to understand and use.
Today I've found something weird when I try to display multiple shapes with a full background drawing.

Here is a simple piece of code to reproduce the issue:

static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(512, 512), "SFML Background Test");
            window.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPressed);
            window.Closed += new EventHandler(OnClose);
            window.Position = new Vector2i(0, 0);
            window.SetVerticalSyncEnabled(true);

            // Some circles
            Random tRand = new Random();
            CircleShape[] tCircles = new CircleShape[10];
            for (int i = 0; i < tCircles.Length; i++)
            {
                tCircles[i] = new CircleShape(20, 20);
                tCircles[i].FillColor = Color.Blue;
                tCircles[i].Position = new Vector2f(tRand.Next(0, (int)window.Size.X), tRand.Next(0, (int)window.Size.Y));
            }

            // Full Background buffer
            byte[] tBuffer = new byte[window.Size.X * window.Size.Y * 4];
            tRand.NextBytes(tBuffer);
            for (int i = 0; i < tBuffer.Length; i += 4)
                tBuffer[i + 3] = 255;
            Texture tTexture = new Texture(window.Size.X, window.Size.Y);
            Sprite tBackground = new Sprite(tTexture);

            while (window.IsOpen())
            {
                // Moving circles
                for (int i = 0; i < tCircles.Length; i++)
                    tCircles[i].Position = new Vector2f(tCircles[i].Position.X + (float)tRand.NextDouble() - 0.5f,
                                                        tCircles[i].Position.Y + (float)tRand.NextDouble() - 0.5f);

                // Changing background pixels
                for (int i = 0; i < tBuffer.Length; i += 4)
                {
                    tBuffer[i]++;
                    tBuffer[i + 1]++;
                    tBuffer[i + 2]++;
                }

                // Updating texture
                tTexture.Update(tBuffer);

                // Drawing
                window.DispatchEvents();
                window.Clear();
                window.Draw(tBackground);
                for (int i = 0; i < 1; i++) // <-- Drawing more than one == buggy background
                    window.Draw(tCircles[i]);
                window.Display();
            }
        }
 

In the previous code, if I try to display more than one circle, the background display is not correct, showing only a single color instead of a bunch of pixels.
I also noticed that if a outline is added to the circle, the background is always buggy, even with one circle only.

I'm using the latest 2.0 and know that it's still a work in progress. Should I switch to the previous released version?

Again, thank you for your amazing work!

Pages: [1]