Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - normaldeveloper

Pages: [1]
1
I have two RectangleShape objects and I want to rotate them by some angle around the same point. What's the best way to do it?

2
Graphics / Re: Strange behaviour when drawing convex shape figure in SFML
« on: September 14, 2016, 11:32:39 am »
Your shape is not convex, thus you can't expect sf::ConvexShape to render it correctly.

I see. Thank you.

3
Graphics / Strange behaviour when drawing convex shape figure in SFML
« on: September 14, 2016, 11:06:34 am »
I'm drawing a convex shape figure using SFML library:

#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
  RenderWindow window(VideoMode(400, 400), "SFML window");

  ConvexShape convex;

  convex.setPointCount(8);
  convex.setPoint(0, sf::Vector2f(0, 0));
  convex.setPoint(1, sf::Vector2f(180, 0));
  convex.setPoint(2, sf::Vector2f(180, 90));
  convex.setPoint(3, sf::Vector2f(100, 90));
  convex.setPoint(4, sf::Vector2f(100, 180));
  convex.setPoint(5, sf::Vector2f(30, 180));
  convex.setPoint(6, sf::Vector2f(30, 90));
  convex.setPoint(7, sf::Vector2f(0, 90));
  convex.setPosition(100, 100);

  while (window.isOpen())
  {
    sf::Event event;
    while (window.pollEvent(event))
    {
      if (event.type == sf::Event::Closed)
        window.close();
    }
    window.clear();
    window.draw(convex);
    window.display();
  }
  return EXIT_SUCCESS;
}

The points defined in clockwise order and everything is ok!


But when I change two coordinates a little bit I'm getting something that I really don't expect:

#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
  RenderWindow window(VideoMode(400, 400), "SFML window");

  ConvexShape convex;

  convex.setPointCount(8);
  convex.setPoint(0, sf::Vector2f(0, 0));
  convex.setPoint(1, sf::Vector2f(180, 0));
  convex.setPoint(2, sf::Vector2f(180, 90));
  convex.setPoint(3, sf::Vector2f(100, 90));
  convex.setPoint(4, sf::Vector2f(100, 200));   // CHANGED 180 to 200
  convex.setPoint(5, sf::Vector2f(30, 200));    // CHANGED 180 to 200
  convex.setPoint(6, sf::Vector2f(30, 90));
  convex.setPoint(7, sf::Vector2f(0, 90));
  convex.setPosition(50, 50);

  while (window.isOpen())
  {
    sf::Event event;
    while (window.pollEvent(event))
    {
      if (event.type == sf::Event::Closed)
        window.close();
    }
    window.clear();
    window.draw(convex);
    window.display();
  }
  return EXIT_SUCCESS;
}

I'm getting the following window:


Why this situation take place?

Pages: [1]