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

Pages: 1 2 [3]
31
Solved, didn't look far enough into http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php it fixed my problem :)

32
I have done that, but I haven't been able to get the drawing going. I've set the points, but It doesn't do it correctly, I cant see what i'm doing wrong.

33
Ok, I've got that working now, just I added it to my loops for my tile map, and it draws it all, but this happens.


This is the loop being to draw it, doing x*x instead of x+x crashes with a First chance exception.
        for (int x = 0; x < 250; x++){
                for (int y = 0; y < 250; y++){
                        sf::VertexArray lines(sf::Quads, 4);
                        lines[0].position = sf::Vector2f(x, y);
                        lines[1].position = sf::Vector2f(x, y+y);
                        lines[2].position = sf::Vector2f(x+x, y+y);
                        lines[3].position = sf::Vector2f(x+x, y);

                        lines[0].texCoords = sf::Vector2f(0, 0);
                        lines[1].texCoords = sf::Vector2f(0, 16);
                        lines[2].texCoords = sf::Vector2f(16, 16);
                        lines[3].texCoords = sf::Vector2f(16, 0);
                        window.draw(lines, &t_grass);
                }
        }
 

Did I type something wrong?
Cheers

34
Ohh, I thought I was forgetting something :)

35
Graphics / VertexArray displaying Dominant color, not the actual image
« on: April 06, 2014, 11:34:34 am »
Hi, I've recently learn't how to use VertexArray's as I read that it was much faster than loading each image individually.

I have my code for the VertexArray working, just when I goto load the image to display as a the 'tile' it shows the most dominant color used in the image, which is green, not the image.

Can you explain why it's doing this?

sf::Texture t_grass;//Called when program is initialized

        while (window.isOpen()){
                sf::Event event;
                while (window.pollEvent(event)){
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                t_grass.loadFromFile("images/grass.png");//Loads the image
                window.clear();

                sf::VertexArray lines(sf::Quads, 4);
                lines[0].position = sf::Vector2f(0, 0);
                lines[1].position = sf::Vector2f(0, 50);
                lines[2].position = sf::Vector2f(50, 50);
                lines[3].position = sf::Vector2f(50, 0);
                window.draw(lines, &t_grass);
                window.display();
        }
 

The image loads fine, so I'm lost with all of it.
Cheers

Pages: 1 2 [3]