-
-
Save larsXYZ/a5d626c97de5ad416daea587681cddc9 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> | |
#include <SFML\Main.hpp> | |
#include <SFML\Window.hpp> | |
#include <SFML\System.hpp> | |
int main() | |
{ | |
sf::RenderWindow window; | |
sf::Event event; | |
const int LIGHT_NUMBER_OF_VERTECES = 25; | |
window.create(sf::VideoMode(500, 500), "", sf::Style::Default); | |
sf::VertexArray vertexArr(sf::TrianglesFan, LIGHT_NUMBER_OF_VERTECES); | |
vertexArr[0] = sf::Vertex(sf::Vector2f(250,250), sf::Color::Red); | |
double deltaAng = 6.283 / ((double)LIGHT_NUMBER_OF_VERTECES); | |
double ang = 0; | |
for (int nr = 0; nr < LIGHT_NUMBER_OF_VERTECES; nr++) | |
{ | |
sf::Vector2f pos(250 + cos(ang) * 300, 250 + sin(ang) * 300); | |
vertexArr.append(sf::Vertex(pos, sf::Color::Transparent)); | |
ang += deltaAng; | |
} | |
while (window.isOpen()) | |
{ | |
while (window.pollEvent(event)) | |
{ | |
//LUKKER VINDUET | |
if (window.hasFocus()) | |
{ | |
if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) window.close(); | |
} | |
else if (event.type == sf::Event::Closed) window.close(); | |
} | |
window.clear(); | |
window.draw(vertexArr); | |
window.display(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment