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

Pages: [1]
1
DotNet / Re: Vertex Or Sprite Batching in Csharp
« on: June 01, 2023, 11:28:47 pm »
I'm thinking of making everything a sprite , then cycle trought all of them every frame then put it into a vertexarray , but i dont know if it is a good idea ,

VA = new VertexArray();
foreach(sprites){

vertex = new Vertex();
vertex.position = sprites.getPosition();
vertex.texture.position = sprite.GetTexturePosition();

VA.AddVertex(vertex);
}

window.Draw(VA,Renderstates);

something around those lines would work i think.

2
DotNet / Vertex Or Sprite Batching in Csharp
« on: June 01, 2023, 10:48:51 pm »
I'm trying to do a hell-bullet game , so more than maybe 2000-5000 entities in the screen but i can't find a good way to do batching.

I found some c/c++ code to make SFML batching but i'm no genius so i dont understand how to translate it into C# code !

Others things the documentation show off some C++ way to extend SF::Drawable and SF::Transformable.

I can't find C# documentation , if anyone could tell me how to batch eitheir Vertex or Sprite in C# in a good way.

As of now the vertex batching i made , make it hard to apply rotation or animation , when I apply rotation to a renderstates it make my vertex texture dissapear i don't know why !

I'm ready to pay for some help if anyone has clue on how to fix this  in C sharp , her my discord :: https://discord.gg/srzchsKDEq


3
Graphics / Re: Vertex Texture and Vertex Color not working in C#
« on: March 19, 2023, 09:04:57 pm »
After Looking at others question on the forum i found out that  some Vertex constructor put Vertex.Color to White.  So it seems that white color do little or no effect on the texture . Have a nice day !

4
Graphics / Vertex Texture and Vertex Color not working in C#
« on: March 19, 2023, 06:27:23 pm »
Hi , i can't find out how to use Vertex  Texxcord in c# without using vertex.Color ! which is slightly modifying the images color !

i saw this page : https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php in C++ but it seems to behave differently than C# equivalent.

I cant draw/render  unless i use a color on my vertex , i dont know why ! Any clue is appreciated !

using SFML.Window;
using SFML.Graphics;
using SFML.System;

namespace TestingVertexQuad
{

    public class Program
    {
        static void Main(string[] args)
        {

            RenderWindow myRenderWindow = new RenderWindow(new VideoMode(1024, 800), "SMFL QUADS TESTING");
            Texture texture = new Texture("C:\\Users\\yolan\\source\\repos\\TestingVertexQuad\\RPG_Character.png");
            texture.Smooth= true;
            RenderStates myRenderState = new RenderStates(texture);
           
            myRenderWindow.Closed += OnClose;
            myRenderWindow.KeyPressed += myKeyPress;
            myRenderWindow.KeyReleased += myKeyReleased;

            VertexArray vertArray1 = new VertexArray(PrimitiveType.Quads, 4 * 1000);
     

            Vertex ver1 = new Vertex();
            Vertex ver2 = new Vertex();
            Vertex ver3 = new Vertex();
            Vertex ver4 = new Vertex();

            ver1.Position = new Vector2f(700f, 700f);
            ver1.TexCoords = new Vector2f(0f, 0f);
            ver1.Color = new Color(255,255,255,255);
            ver2.Position = new Vector2f(750f, 700f);
            ver2.TexCoords = new Vector2f(50f, 0f);
            ver2.Color = new Color(255, 255, 255, 255);
            ver3.Position = new Vector2f(750f,775f);
            ver3.TexCoords = new Vector2f(50f, 75f);
            ver3.Color = new Color(255, 255, 255, 255);
            ver4.Position = new Vector2f(700f,775f);
            ver4.TexCoords = new Vector2f(0f, 75f);
            ver4.Color = new Color(255, 255, 255, 255);
            Sprite sprite = new Sprite(texture);
           
            vertArray1.Append(ver1);
            vertArray1.Append(ver2);
            vertArray1.Append(ver3);
            vertArray1.Append(ver4);

            while (myRenderWindow.IsOpen)
            {

                myRenderWindow.DispatchEvents();


                myRenderWindow.Clear(Color.White);

                myRenderWindow.Draw(sprite);
                myRenderWindow.Draw(vertArray1, myRenderState);
                myRenderWindow.Display();
            }


        }
        internal static void OnClose(object sender, EventArgs e)
        {
            // Close the window when OnClose event is received
            RenderWindow window = (RenderWindow)sender;
            Console.WriteLine(e.GetType());
            window.Close();

        }

        internal static void OnResize(object sender, SizeEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            FloatRect visibleArea = new FloatRect(0, 0, e.Width, e.Height);
            window.SetView(new View(visibleArea));
        }
        internal static void myKeyPress(object sender, KeyEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            //Player pl = Player.getInstance();
            // Close the window when OnClose event is received
            if (e.Code == Keyboard.Key.W)
            {
                //pl.IsMovingUp = true;

                Console.WriteLine(" TEST " + e.Code);
            }
            if (e.Code == Keyboard.Key.A)
            {
                //pl.IsMovingLeft = true;

                Console.WriteLine(" TEST " + e.Code);
            }
            if (e.Code == Keyboard.Key.S)
            {
                //pl.IsMovingDown = true;

                Console.WriteLine(" TEST " + e.Code);
            }
            if (e.Code == Keyboard.Key.D)
            {
                //pl.IsMovingRight = true;

                Console.WriteLine(" TEST " + e.Code);
            }

        }
        internal static void myKeyReleased(object sender, KeyEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            //Player pl = Player.getInstance();
            // Close the window when OnClose event is received
            if (e.Code == Keyboard.Key.W)
            {
                //pl.IsMovingUp = false;

                Console.WriteLine(" TEST " + e.Code);
            }
            if (e.Code == Keyboard.Key.A)
            {
                //pl.IsMovingLeft = false;

                Console.WriteLine(" TEST " + e.Code);
            }
            if (e.Code == Keyboard.Key.S)
            {
                //pl.IsMovingDown = false;

                Console.WriteLine(" TEST " + e.Code);
            }
            if (e.Code == Keyboard.Key.D)
            {
               // pl.IsMovingRight = false;

                Console.WriteLine(" TEST " + e.Code);
            }

        }
        internal static void myMouseKeyPressed(object sender, MouseButtonEventArgs e)
        {
            RenderWindow window = (RenderWindow)sender;
            //Player pl = Player.getInstance();
            Vector2i pixelPos = Mouse.GetPosition(window);

            // convert it to world coordinates
            Vector2f worldPos = window.MapPixelToCoords(pixelPos);


            // convert it to world coordinates

            // Close the window when OnClose event is received
            if (e.Button == Mouse.Button.Left)
            {

                //pl.IsLeftMousePressed = true;

               // pl.MousePositionX = worldPos.X;
               // pl.MousePositionY = worldPos.Y;


            }
            if (e.Button == Mouse.Button.Right)
            {
               // pl.IsRightMousePressed = true;


            }

        }
        internal static void myMouseReleased(object sender, MouseButtonEventArgs e)
        {

            //Player pl = Player.getInstance();
            // Close the window when OnClose event is received
            if (e.Button == Mouse.Button.Left)
            {

               // pl.IsLeftMousePressed = false;

            }
            if (e.Button == Mouse.Button.Right)
            {
                //pl.IsRightMousePressed = false;

            }

        }
        internal static void myMouseKeyMoving(object sender, MouseMoveEventArgs e)
        {


            RenderWindow window = (RenderWindow)sender;
            //Player pl = Player.getInstance();
            Vector2i pixelPos = Mouse.GetPosition(window);

            // convert it to world coordinates
            Vector2f worldPos = window.MapPixelToCoords(pixelPos, window.DefaultView);
            //pl.MousePositionX = worldPos.X;
            //pl.MousePositionY = worldPos.Y;

        }
    }
   
}
 

Pages: [1]