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

Pages: [1]
1
Graphics / Re: sf::VertexArray strange lines
« on: May 26, 2017, 10:56:27 pm »
I like the idea you linked, however it will not work with some options i have planned to do.

I wonder if it's a common problem with the vertex array why one proper solution haven't been found. Is it impossible to have working vertex array with zooming?

2
Graphics / Re: sf::VertexArray strange lines
« on: May 11, 2017, 09:57:20 pm »
Why no one replied?
Is something unclear or just I am being ignored?

3
Graphics / sf::VertexArray strange lines
« on: May 05, 2017, 12:39:13 am »
Hello.
I'm currently working on a project. We are using vertexarray to display the titlemap. However they are bringing us quite an issue. We have managed to produce the minimal working example.
int main()
{
        sf::VertexArray vertexArray;
        int data[200][200];
        for (int i = 0; i < 200; i++) {
                for (int j = 0; j < 200; j++) {
                        data[i][j] = 0;
                }
        }

        vertexArray.resize(200 * 200 * 4);

        sf::Texture tex;
        tex.loadFromFile("MWE.png");

        for (int j = 0; j < 200; ++j) {
                for (int i = 0; i <200; ++i) {
                        int tileID = data[i][j];
                        sf::Vector2f size = sf::Vector2f((float)128, (float)128);
                        int rotation = 0;
                        int tu = tileID % (int)(tex.getSize().x / size.x);
                        int tv = tileID / (int)(tex.getSize().y / size.y);
                        sf::Vertex * quad = &vertexArray[size_t(i + j * 200)* 4];

                        quad[0].position = sf::Vector2f(std::floor((float)(i * 128)), std::floor((float)(j * 128)));
                        quad[1].position = sf::Vector2f(std::floor((float)(i * 128 + size.x)), std::floor((float)(j * 128)));
                        quad[2].position = sf::Vector2f(std::floor((float)(i * 128 + size.x)), std::floor((float)(j * 128 + size.y)));
                        quad[3].position = sf::Vector2f(std::floor((float)(i * 128)), std::floor((float)(j * 128 + size.y)));

                        quad[(0 + rotation / 90) % 4].texCoords = sf::Vector2f(std::floor((float)(tu)* 128), std::floor((float)(tv * 128)));
                        quad[(1 + rotation / 90) % 4].texCoords = sf::Vector2f((std::floor((float)(tu + 1)* 128)), std::floor((float)(tv * 128)));
                        quad[(2 + rotation / 90) % 4].texCoords = sf::Vector2f((std::floor((float)(tu + 1)* 128)), std::floor((float)((tv + 1) * 128)));
                        quad[(3 + rotation / 90) % 4].texCoords = sf::Vector2f(std::floor((float)(tu)* 128), std::floor((float)((tv + 1) * 128)));
                }
        }
        sf::RenderWindow window(sf::VideoMode(1600, 900), "My window");

        sf::View view;
        sf::RenderStates states;
        states.texture = &tex;
        view.setSize(1600, 900);
        view.setCenter(800, 450);
        window.setView(view);
        window.setFramerateLimit(60);

        // run the program as long as the window is open
        while (window.isOpen())
        {
                window.clear(sf::Color::Black);
                // check all the window's events that were triggered since the last iteration of the loop
                sf::Event event;
                while (window.pollEvent(event))
                {
                        // "close requested" event: we close the window
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Q)) {
                        view.zoom(1.1f);
                }
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::E)) {
                        view.zoom(0.9f);
                }
                //moving up
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W) && true) {
                        view.move(0, -32);
                }
                //movind down
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S) && true) {
                        view.move(0, 32);
                }
                //moving left
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A) && true) {
                        view.move(-32, 0);
                }
                //moving UP
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D) && true) {
                        view.move(32, 0);
                }
               
                window.setView(view);
                window.draw(&vertexArray[0], 200 * 200 *4, sf::Quads, states);
                window.display();
        }
        return 0;
}
 

The MWE.png file should be attached to the post as well the screenshot of the problem.

The description:
The cords in quads positions and texCords are rounded and created from integers. In the beginning there are no sings of the problem. It starts when we are zooming out (and it's especially visible when moving). It displays itself by overlapping the texture used with the pixels nearby that texture(you can see it as red lines - check the files.).

Is there a way to prevent it?
Thanks for help.
Peace.


Pages: [1]