Created
June 4, 2013 20:17
-
-
Save anonymous/5709180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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