Skip to content

Instantly share code, notes, and snippets.

@larsXYZ
Created June 23, 2016 09:13
Show Gist options
  • Save larsXYZ/750afb868b95b7867e6502be02b82d93 to your computer and use it in GitHub Desktop.
Save larsXYZ/750afb868b95b7867e6502be02b82d93 to your computer and use it in GitHub Desktop.
#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))
{
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