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 - person

Pages: [1]
1
General / Re: Drawing Dots on an Image - Image Disappears
« on: February 16, 2016, 09:07:59 pm »
Thanks for the tips. I'll use them.

2
General / Re: Drawing Dots on an Image - Image Disappears
« on: February 13, 2016, 05:53:10 pm »
Thank you very much. Appresciate your answer and your time.

3
General / Drawing Dots on an Image - Image Disappears
« on: February 12, 2016, 12:36:36 pm »
[Hi. I started learning SFML in the last week. If you think my question could be answered by reading the tutorials, please give me a link. Also if I'm doing something in an unecesserily complicated way, I'll appreciate it if you tell me. Thank you!]

I was trying display an image on the screen, and then put dots where the user pressed. Here's my code:

 //This is a type I defined. For this question, it's enough to know that it has a Texture member.
   static void create(imageAndButtons& myImage)

   {
      sf::Texture image(myImage.texture);
      sf::Sprite mySprite(image);


      sf::RenderWindow myWindow;
//Make window size match image size.      
      myWindow.create(sf::VideoMode(image.getSize().x,image.getSize().y),"screen");      
      myWindow.draw(mySprite);
      myWindow.display();
            
      sf::VertexArray point(sf::Points, 1);
      sf::Event event;
      while (true)
      {
         while (myWindow.pollEvent(event))
            if (event.type == sf::Event::MouseButtonPressed)
            {
            point[0].position.x = event.mouseButton.x;
            point[0].position.y = event.mouseButton.y;
            myWindow.draw(point);   
            myWindow.display();
            }
      }

The very strange (to me) result of this code was that each time the user presses the mouse button the image disappears and reappears alternately, while the dots are added to the screen and remain all the time.

I'll be happy to know what I should change in my code. Also I'd very much like to understand why the image disappears, and what makes it to reappear (We never left the while loop!)

Pages: [1]
anything