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

Pages: [1]
1
Graphics / Vertex Array giving coluor to texture
« on: May 18, 2016, 04:39:27 am »
Hello ,

I know that you can add colour to the vertex but if i want to use a texture atlas . Is it possible to only change colour of it . Lets say i want to add green colour to brick instead of changing the texture itself in photoshop

Regards Ashley

2
Graphics / Re: using vertexArray drops fps massively
« on: April 03, 2015, 10:21:55 pm »
You draw the vertex array 40*40 = 1600 times per frame. The whole point of using vertex arrays is to reduce draw calls, however.

That is, build it with all the quads you need, but draw it only once. If you're unsure, refer to the tutorial, there's a good example.
Sorry for the late reply i found a tutorial in learn section. tried what u said but the results where still the same
int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 800), "SFML works!");
        sf::VertexArray Tquad(sf::Quads, 40*40*4);
        int size{ 20 };
        for (int x = 0; x < 40; x++)
        {
                for (int y = 0; y < 40; y++)
                {
                        sf::Vertex* quad = &Tquad[(x + y * 40) * 4];
                        quad[0].position = sf::Vector2f(x, y);
                        quad[1].position = sf::Vector2f(x*size, y);
                        quad[2].position = sf::Vector2f(x*size, y*size);
                        quad[3].position = sf::Vector2f(x, y*size);
                }
        }
       
        while (window.isOpen())
        {
                sf::Event event;
               

                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
               
                window.clear();
                window.draw(Tquad);
                window.display();

        }

        return 0;
}
Still get the same amount of fps

3
Graphics / using vertexArray drops fps massively
« on: April 03, 2015, 01:37:40 pm »
Hello, ı was looking for a way to draw tile in game dynamically(edit or change at run time). I though of is i use vertexarray it can be done. Well it does the job excellently but fps drops very quick.
Commended vertex code (release ) = 2000+-
UnCommended vertex code (release) = 21+-1

There is massive difference in fps

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 800), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);
        sf::VertexArray quad(sf::Quads, 4);
       
        while (window.isOpen())
        {
                window.clear();
                sf::Event event;
                int size{ 20 };

                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                for (int x = 0; x < 40; x++)
                {
                        for (int y = 0; y < 40; y++)
                        {
                                quad[0].position = sf::Vector2f(x, y);
                                quad[1].position = sf::Vector2f(x*size, y);
                                quad[2].position = sf::Vector2f(x*size, y*size);
                                quad[3].position = sf::Vector2f(x, y*size);
                                window.draw(quad);
                        }
                }
               
                window.display();
        }

        return 0;
}

The code is pretty much the one from tutorial with the vertex just added. I know the for loops in combine call 40*40 time but i didnt expect it to fall this quick. Is there a alternative way to do it ?

Pages: [1]
anything