Skip to content

Instantly share code, notes, and snippets.

/gist:5709180

Created Jun 4, 2013
Embed
What would you like to do?
#include <SFML/Graphics.hpp>
int width = 200;
int height = 200;
sf::VertexArray varray(sf::Points);
sf::Vertex vertex;
void stripes()
{
varray.clear();
varray.resize(width * height);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
vertex.position = sf::Vector2f(x, y);
vertex.color = sf::Color::White;
if ((x % 10) == 0){vertex.color = sf::Color::Red;}
varray.append(vertex);
}
}
}
int main()
{
sf::Vector2u windowsize;
sf::RenderWindow window(sf::VideoMode(width, height), "Resize Test");
stripes();
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::Resized)
{
windowsize = window.getSize();
width = windowsize.x;
height = windowsize.y;
stripes();
window.create(sf::VideoMode(width, height), "Resize Test");
}
}
window.clear();
window.draw(varray);
window.display();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.