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

Pages: [1]
1
Very odd.  I have coded in C# for years but I rarely use structures for anything.  Thanks for the response  :)

2
Hi Laurent,

All you have to do is substitute:

                RenderStates renStates = new RenderStates(tex);

for:
      RenderStates renStates = new RenderStates ();
             renStates.Texture = tex;

If you do that with the posted code you won't see any texture on the screen.

3
Hello,

I have just started using the SFML.Net Bindings and I appear to be having an issue with the VertexArray and binding the texture.  In the code below I am loading a ship image.  I set up the VertexArray with Texture and Vertex Coords.  When I call display with the Vertexarray and the RenderStates I get a black screen.  Am I doing something wrong or is it a bug?  Thanks in advance.

EDIT:  Below code now works by calling RenderState(<texture>).

 public void Run()
                {
                        _gamewindow = new RenderWindow( new VideoMode(800,600),"Simple2D Game                  Window",Styles.Default);
                        _gamewindow.Closed += new EventHandler(OnClosed);
                        _gamewindow.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);

                        int prevtime = 0;
                        int currtime = 0;
                        int elapsedtime = 0;
                        int totalelapsedtime = 0;

                        Texture tex = new Texture (@"Ship.png");

                        VertexArray array = new VertexArray ();
                        array.PrimitiveType = PrimitiveType.Quads;

                        Vertex vert1 = new Vertex ();
                        vert1.Position = new Vector2f (10, 10);
                        vert1.Color = Color.White;
                        vert1.TexCoords = new Vector2f (0, 0);
                        array.Append (vert1);


                        Vertex vert2 = new Vertex ();
                        vert2.Position = new Vector2f (90, 10);
                        vert2.Color = Color.White;
                        vert2.TexCoords = new Vector2f (80, 0);
                        array.Append (vert2);

                        Vertex vert3 = new Vertex ();
                        vert3.Position = new Vector2f (90, 93);
                        vert3.Color = Color.White;
                        vert3.TexCoords = new Vector2f (80, 83);
                        array.Append (vert3);

                        Vertex vert4 = new Vertex ();
                        vert4.Position = new Vector2f (10, 93);
                        vert4.TexCoords = new Vector2f (0, 83);
                        vert4.Color = Color.White;
                        array.Append (vert4);

                        RenderStates renStates = new RenderStates (tex);

                        while (_gamewindow.IsOpen())
                        {
                                currtime = Environment.TickCount;
                                elapsedtime = currtime - prevtime;
                                prevtime = currtime;
                                totalelapsedtime += elapsedtime;

                                _gamewindow.DispatchEvents();

                                if(totalelapsedtime>=15)
                                {
                                        Update (totalelapsedtime);
                                        totalelapsedtime=0;
                                }

                                _gamewindow.Clear(Color.Black);
                                _gamewindow.Draw (array,renStates);
                                _gamewindow.Display();
                        }
                }


 

So, after downloading the source for the .Net Bindings.  I saw there was a constructor that takes a Texture parameter.  I created the renderstate by passing my texture to the constructor and this works.  For some resaon the Constructors aren't showing up in my IDE(Xamarin, but that's another issue.)

It seems that when you assign values to the RenderStates structure they don't get assigned or kept internally for some reason.

Pages: [1]