1
Graphics / [SOLVED] Drawing an Arrow
« on: April 08, 2011, 06:28:17 pm »
Perfect, this works, thank you!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
sf::Shape Line = sf::Shape::Line(x1,y1,x2,y2,1,sf::Color::White);
sf::Shape Triangle;
float angle = 2 * PI/3;
float angle_rect = PI/2;
float d = 50;
for (int i = 0; i < 3; i++) {
Triangle.AddPoint(x2+d*sin(angle*i), y2+d*cos(angle*i), sf::Color::White);
}
App.Draw(Line);
sf::Vector2f av =Triangle.GetPosition();
App.Draw(Triangle);
sf::Shape * genSquare = new sf::Shape::Rectangle(0,0,100,100,sf::Color::Red);
sf::Shape * genSquare = new sf::Shape(sf::Shape::Rectangle(0,0,100,100,sf::Color::Red));
sf::Shape Rect = sf::Shape::Rectangle(0,0,1920,1080,sf::Color::Black);
Rect.EnableFill(true);
Rect.SetPosition(0,0);
while (theVars->App.IsOpened())
{
sf::Event event;
bool draw = false;
theVars->App.Clear();
while(theVars->App.GetEvent(event)){
if (event.Type == sf::Event::MouseButtonPressed) {
const sf::Input& Input = theVars->App.GetInput();
if (event.MouseButton.Button == sf::Mouse::Left) {
selectSquares(Input.IsKeyDown(sf::Key::LShift), event.MouseButton.X, event.MouseButton.Y);
}
}
if (event.Type == sf::Event::KeyPressed) {
keyDown(event.Key.Code);
}
if (theVars->App.GetInput().IsKeyDown(sf::Key::T)) {
draw = true;
}
}
// Set the active window before using OpenGL commands
// It's useless here because active window is always the same,
// but don't forget it if you use multiple windows or controls
theVars->App.SetActive();
display();
// Finally, display rendered frame on screen
if(draw)
theVars->App.Draw(Rect);
theVars->App.Display();
}
glDisable(GL_LIGHTING);
theVars->App.Draw(Rect);
glEnable(GL_LIGHTING);
class dumbClass{
sf::Window App;
};