Skip to content

Instantly share code, notes, and snippets.

Created June 4, 2013 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5709180 to your computer and use it in GitHub Desktop.
Save anonymous/5709180 to your computer and use it in GitHub Desktop.
#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