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

Pages: [1]
1
Graphics / Re: texture coordinates in vertex for any shape
« on: February 28, 2015, 01:00:25 pm »
Solved. I didn't understood the source but now i got it. Thanks anyway.

2
Graphics / Re: Own vertex shape and texture
« on: February 28, 2015, 10:58:13 am »
Thanks for your answer. I wrote it too complicated. I need a function to set texture coordinates for any vertices/shape like in any sfml shape.

Here's how i did for rectangle:

int main()
{

        sf::Texture texture;
        texture.loadFromFile("test.png");

        sf::RenderWindow window(sf::VideoMode(900, 800), "Test");

        sf::Vertex* a = new sf::Vertex[4];

        a[0].position = sf::Vector2f(1, 1);
        a[1].position = sf::Vector2f(100, 1);
        a[2].position = sf::Vector2f(100, 100);
        a[3].position = sf::Vector2f(1, 100);

        sf::Vector2u size = texture.getSize();

        a[0].texCoords = sf::Vector2f(0, 0);
        a[1].texCoords = sf::Vector2f(size.x - 1.0f, 0);
        a[2].texCoords = sf::Vector2f(size.x - 1, size.y - 1);
        a[3].texCoords = sf::Vector2f(0, size.y - 1.0f);


        window.draw(a, 4, sf::PrimitiveType::TrianglesFan, &texture);
        window.display();

        delete[] a;

        while (window.isOpen())
        {
        }
}
 

But when i add more vertices and make it convex the texture doesn't display correctly. I understand why it can't work and would like to know how it's done in sfml-shape.

3
Graphics / [Solved][Trash] texture coordinates in vertex for any shape
« on: February 27, 2015, 04:32:41 pm »
How do I set the texture coordinates in sf::Vertex automatically for any shape like sfml do it?

Pages: [1]