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

Pages: [1] 2 3
1
DotNet / Re: Tearing in clear textures.
« on: May 18, 2012, 11:53:56 am »
I'll try, the next time I'd be near that computer, but it's not a code problem - on my home desktop there's no tearing.

2
DotNet / Re: Tearing in clear textures.
« on: May 18, 2012, 08:25:18 am »
No, In the animation I keep removing the first frame and then draw the next one.

3
DotNet / Tearing in clear textures.
« on: May 17, 2012, 10:41:42 pm »
When I run an animation that involves a partly clear (invisible) texture on a slow computer, there's "static" tearing which disrupts the view. This happens regardless of Vsync or whether there's a framerate limit set. Is there a known cause for this?

Example video:


4
DotNet / Re: RenderTexture / Texture problems
« on: May 15, 2012, 06:09:27 pm »
That works. Thanks!

5
DotNet / Re: RenderTexture / Texture problems
« on: May 15, 2012, 05:30:43 pm »
Sorry, didn't notice I can skip the computations, since the values are known.

Code: [Select]
using System.Threading;
using System;
using SFML.Window;
using SFML.Graphics;
using System.Collections.Generic;

namespace Game
{
    internal enum Direction { LEFT, RIGHT, UP, DOWN, UPLEFT, UPRIGHT, DOWNLEFT, DOWNRIGHT }

    class main
    {
       

        static int Main(string[] args)
        {
            List<Direction> list = new List<Direction>{Direction.UP,Direction.UP,Direction.UP,Direction.UP,Direction.UP,
                Direction.UPLEFT,Direction.UPLEFT,Direction.UPLEFT,Direction.UPLEFT,Direction.LEFT,Direction.LEFT,
                Direction.LEFT,Direction.LEFT,Direction.LEFT,Direction.LEFT,Direction.LEFT,Direction.LEFT,
                Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,
                Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,
                Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,
                Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN};

            RenderWindow main = new RenderWindow(new VideoMode(800, 800), "main");
            List<Sprite> sprites = generateNewComplexPath(list, new Vector2f(100, 100));

            while (true)
            {
                foreach (Sprite sprite in sprites)
                {
                    main.Clear();
                    main.Draw(sprite);
                    main.Display();
                }
            }
            Console.In.ReadLine();
            return 1;
        }

        public static List<Sprite> generateNewComplexPath(List<Direction> path, SFML.Window.Vector2f position)
        {
            Vector2i entry = new Vector2i(28, 13);
            List<Sprite> list = new List<Sprite>();
            List<Sprite> newSprite = generateNewPathSprite(path, entry);
            Sprite temp;
            int count;
            RenderTexture texture;
            for (uint i = 0; i < 10; i++)
            {
                texture = new RenderTexture(33, 33);
                for (uint j = 0; j < path.Count / 10; j++)
                {
                    count = (int)(j * 10 + i);
                    if (count < newSprite.Count)
                    {
                        texture.Draw(newSprite[count]);
                    }
                }
                texture.Display();
                temp = new Sprite(texture.Texture);
                temp.Origin = new SFML.Window.Vector2f(entry.X, entry.Y);
                temp.Position = position;
                list.Add(temp);
            }

            return list;
        }

        private static List<Sprite> generateNewPathSprite(List<Direction> path, Vector2i initial)
        {
            List<Sprite> newList = new List<Sprite>();
            Texture text = new Texture("images/UI/path.png");
            Sprite temp;
            foreach (Direction dir in path)
            {
                temp = new Sprite(text);
                initial = new Vector2i(initial.X-1, initial.Y+1);
                temp.Position = toVector2f(initial);
                newList.Add(temp);
            }
            return newList;
        }

        private static Vector2f toVector2f(Vector2i initial)
        {
            return new Vector2f(initial.X, initial.Y);
        }
    }
   
}


6
DotNet / Re: RenderTexture / Texture problems
« on: May 15, 2012, 04:04:57 pm »
Sorry, couldn't parse it down to the bare minimum, so this came out a bit long.
Running this on debug mode in VS2010 opens a large window with smal green animation. After about two minutes it'll crash.

EDIT: Another run didn't crash, but began blinking white.  The one after threw a "divide by zero" exception after ten seconds. As I said, non-deterministic.

Code: [Select]
using System.Threading;
using System;
using SFML.Window;
using SFML.Graphics;
using System.Collections.Generic;

namespace Game
{
    internal enum Direction { LEFT, RIGHT, UP, DOWN, UPLEFT, UPRIGHT, DOWNLEFT, DOWNRIGHT }

    class main
    {
       

        static int Main(string[] args)
        {
            FileHandler.init();
            RenderWindow main = new RenderWindow(new VideoMode(800, 800), "main");
            List<Direction> list = new List<Direction>{Direction.UP,Direction.UP,Direction.UP,Direction.UP,Direction.UP,
                Direction.UPLEFT,Direction.UPLEFT,Direction.UPLEFT,Direction.UPLEFT,Direction.LEFT,Direction.LEFT,
                Direction.LEFT,Direction.LEFT,Direction.LEFT,Direction.LEFT,Direction.LEFT,Direction.LEFT,
                Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,
                Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,Direction.DOWNLEFT,
                Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN,
                Direction.DOWN,Direction.DOWN,Direction.DOWN,Direction.DOWN};
            List<Sprite> sprites = generateNewComplexPath(list, new Vector2f(100, 100));

            while (true)
            {
                foreach (Sprite sprite in sprites)
                {
                    main.Clear();
                    main.Draw(sprite);
                    main.Display();
                }
            }
            Console.In.ReadLine();
            return 1;
        }

        public static List<Sprite> generateNewComplexPath(List<Direction> path, SFML.Window.Vector2f position)
        {
            Area area = getPathSize(path);
            List<Sprite> list = new List<Sprite>();
            List<Sprite> newSprite = generateNewPathSprite(path, area.Entry);

            list.Clear();
            Sprite temp;
            int count;
            RenderTexture texture;
            for (uint i = 0; i < 10; i++)
            {
                texture = new RenderTexture((uint)area.Size.X, (uint)area.Size.Y);
                for (uint j = 0; j < path.Count / 10; j++)
                {
                    count = (int)(j * 10 + i);
                    if (count < newSprite.Count)
                    {
                        texture.Draw(newSprite[count]);
                    }
                }
                texture.Display();
                temp = new Sprite(texture.Texture);
                temp.Origin = new SFML.Window.Vector2f(area.Entry.X, area.Entry.Y);
                temp.Position = position;
                list.Add(temp);
            }

            return list;
        }

        private static Area getPathSize(List<Direction> path)
        {
            //TODO - no to use magic numbers.
            int xSize = 9, xPos = 4, ySize = 9, yPos = 4, x = 4, y = 4;
            foreach (Direction dir in path)
            {
                switch (dir)
                {
                    case (Direction.DOWN):
                        y++;
                        break;
                    case (Direction.DOWNLEFT):
                        y++;
                        x--;
                        break;
                    case (Direction.DOWNRIGHT):
                        y++;
                        x++;
                        break;
                    case (Direction.LEFT):
                        x--;
                        break;
                    case (Direction.RIGHT):
                        x++;
                        break;
                    case (Direction.UP):
                        y--;
                        break;
                    case (Direction.UPLEFT):
                        y--;
                        x--;
                        break;
                    case (Direction.UPRIGHT):
                        x++;
                        y--;
                        break;
                }
                if (x < 4) { xPos++; xSize++; x = 4; }
                if (y < 4) { yPos++; ySize++; y = 4; }
                if (x >= xSize - 4) { xSize++; }
                if (y >= ySize - 4) { ySize++; }
            }

            return new Area(new Vector(xPos, yPos), new Vector(xSize, ySize));
        }

        private static List<Sprite> generateNewPathSprite(List<Direction> path, Vector initial)
        {
            List<Sprite> newList = new List<Sprite>();
            Texture text = new Texture("images/UI/path.png");
            Sprite temp;
            foreach (Direction dir in path)
            {
                temp = new Sprite(text);
                switch (dir)
                {
                    case (Direction.UP):
                        break;
                    case (Direction.DOWN):
                        temp.Rotation = 180F;
                        break;
                    case (Direction.LEFT):
                        temp.Rotation = 270;
                        break;
                    case (Direction.RIGHT):
                        temp.Rotation = 90F;
                        break;
                    case (Direction.UPRIGHT):
                        temp.Rotation = 45F;
                        break;
                    case (Direction.UPLEFT):
                        temp.Rotation = 315F;
                        break;
                    case (Direction.DOWNRIGHT):
                        temp.Rotation = 135F;
                        break;
                    case (Direction.DOWNLEFT):
                        temp.Rotation = 225F;
                        break;
                }
                initial = initial.addVector(Vector.directionToVector(dir));
                temp.Position = initial.toVector2f();
                newList.Add(temp);
            }

            return newList;
        }
    }

        struct Vector
        {
            private int _x, _y;

            public Vector(int x, int y)
            {
                this._x = x;
                this._y = y;
            }

            public int X
            {
                get { return _x; }
            }

            public int Y
            {
                get { return _y; }
            }

            public Vector addVector(Vector add)
            {
                return new Vector(this._x + add.X, this._y + add.Y);
            }


            public SFML.Window.Vector2f toVector2f()
            {
                return new SFML.Window.Vector2f(Convert.ToSingle(this._x), Convert.ToSingle(this._y));
            }

            static public Vector directionToVector(Direction direction)
            {
                switch (direction)
                {
                    case (Direction.UP):
                        return new Vector(0, -1);

                    case (Direction.DOWN):
                        return new Vector(0, 1);

                    case (Direction.LEFT):
                        return new Vector(-1, 0);

                    case (Direction.RIGHT):
                        return new Vector(1, 0);

                    case (Direction.UPRIGHT):
                        return new Vector(1, -1);

                    case (Direction.DOWNRIGHT):
                        return new Vector(1, 1);

                    case (Direction.UPLEFT):
                        return new Vector(-1, -1);

                    case (Direction.DOWNLEFT):
                        return new Vector(-1, 1);

                    default:
                        throw new Exception("not valid direction found");
                }
            }
        }
       

        internal struct Area
        {
            private readonly Vector _entry; //the top left of the shape
            private Vector _size;


            internal Area(Vector entry, Vector size)
            {
                this._entry = entry;
                this._size = size;
            }

            internal Vector Size
            {
                get { return _size; }
            }

            public Vector Entry
            {
                get { return _entry; }
            }

        }
   
}

7
DotNet / RenderTexture / Texture problems
« on: May 15, 2012, 01:07:54 pm »
At some point after creating a RenderTexture, drawing to it, displaying & saving the texture in a sprite, some odd transformation happen - When I'll try to display the sprite, I'll get an error message - either a "tried to divide by zero" after the inner texture's parameters change (sometimes to 0,0, sometimes to impossibly large numbers), or a "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

This happens at a non-deterministic stage, and not at the first time the texture is displayed, and I failed to find a definite result to it. Could this be connected to garbage collection of the RenderTexture after it left operational scope, and something in it's destructor changing it's texture afterwards?

8
DotNet / Re: Image.createMaskFromColor
« on: May 11, 2012, 01:26:10 pm »
thank you very much.

laurent - how can UI set it back? Image.Pixels is readonly, and the array doesn't have x,y coordinates to use in Image.setPixel.

omeg - I'm not certain I know what you're talking about. Can you please explain?

9
DotNet / Re: Image.createMaskFromColor
« on: May 09, 2012, 10:34:53 am »
is this function a reasonable replacement, or is there a more efficient way?

            for (uint i = 0; i < img.Size.X; i++)
            {
                for (uint j = 0; j < img.Size.Y; j++)
                {
                    if (img.GetPixel(i, j).Equals(Color.White))
                    {
                        img.SetPixel(i,j,new Color(0,0,0,0));
                    }
                }

            }

10
DotNet / Image.createMaskFromColor
« on: May 08, 2012, 05:34:08 pm »
When I try to use the command, I get the error message "Unable to find an entry point named 'sfImage_createMaskFromColor' in DLL 'csfml-graphics-2'.". This happens with the 2.0 RC version.

this happens even with

        static int Main(string[] args)
        {
            SFML.Graphics.Image img= new SFML.Graphics.Image(10, 10, SFML.Graphics.Color.White);
            img.CreateMaskFromColor(SFML.Graphics.Color.White);
            return 1;
        }

for now I just iterate over the pixels, but if the function could be fixed, it'll help. Thanks!

11
DotNet / Re: Sprite draw crash.
« on: April 20, 2012, 09:47:26 am »
So, to explain why I failed to find a minimal working problem - apparently it's not the Texture, or the original images - Sprites made from both are running. There's no discernible cause for this, no condition that I could isolate through prints, etc. Frankly, at the level of information open to me, I can't discern any difference between the Sprites that crash (and they're very few) and those that don't.

The only thing I know is that sometimes, when calling line 165 in Sprite.Draw, states.Transform *= Transform, the "right" variable will be null. Since this.Transform isn't null, but is Matrix(System.Single)[], I don't really understand what is happening.

12
DotNet / Re: Sprite draw crash.
« on: April 19, 2012, 11:01:44 pm »
I'm still looking at reducing the code, but now I've noticed that the only null part of the Sprite is myInverseTransform, and that under InverseTransform there's a message "'((SFML.Graphics.Transformable)(sprite)).InverseTransform' threw an exception of type 'System.AccessViolationException'   SFML.Graphics.Transform {System.AccessViolationException}".

Is this a hint towards what happened?

EDIT: I now see that every object has it as null. So I don't see what do I get the null exception on - the Sprite's definitely not a null, and I can't seem to reduce this to a minimal case that wtill pops the error.

13
DotNet / Re: Sprite draw crash.
« on: April 19, 2012, 09:46:14 pm »
Do you really need the same complexity to reproduce it? I mean, if it's a bug in SFML then it can probably be reproduced easily. If not, then the problem is caused by your program, and there's nothing I can do.

Oh, I don't know what I need to reproduce it. Currently it's very complex, and I'll try to focus on the minimal needed to reproduce it.

eXpl0it3r - I don't use OpenGL, but I do set it to Active(false) on the thread it's created.

14
DotNet / Re: Sprite draw crash.
« on: April 19, 2012, 11:17:48 am »
Argh. This is a problem that spans the interaction between several objects and threads. I can try to minimise it, but will it still be worthwhile if the code I'll upload will be quite long?

15
DotNet / Re: Sprite draw crash.
« on: April 19, 2012, 07:07:44 am »
Yes, I didn't run the OpenGL example program. I tried once and errors popped ("output path not defined"), and since I wasn't interested in OpenGL didn't bother with it.

There's no global sprite. There's one that is created before the window, but it gets displayed well - it's the background, and the program runs and displays stuff (and the background) before crashing. It happens when drawing new sprites.

Pages: [1] 2 3
anything