SFML community forums

Help => Graphics => Topic started by: delio on March 12, 2014, 05:05:00 am

Title: [Unsolved see lastest rep.] View problem
Post by: delio on March 12, 2014, 05:05:00 am
The picture below is when I zoom in.
(http://upic.me/i/ai/445c2.png)

The picture below is when I zoom out
(http://upic.me/i/fv/7exam.png)

When I zoom out I don't program display pink lines
display pink link only when I zoom in

How can I do it?

Thanks

Sorry for bad English
Title: Re: Zoom and View problem
Post by: G. on March 12, 2014, 01:03:45 pm
I think the documentation (http://www.sfml-dev.org/documentation/2.1/classsf_1_1View.php#a4a72a360a5792fbe4e99cd6feaf7726e) is pretty clear on what the factor should be to zoom in or out.

And a MouseMoved event inside a MouseWheelMoved event? It will never happen. :o
Title: Re: Zoom and View problem
Post by: delio on March 12, 2014, 03:44:12 pm
I think the documentation (http://www.sfml-dev.org/documentation/2.1/classsf_1_1View.php#a4a72a360a5792fbe4e99cd6feaf7726e) is pretty clear on what the factor should be to zoom in or out.

And a MouseMoved event inside a MouseWheelMoved event? It will never happen. :o
Thanks

Solved about zoom problem
It's not zoom properly. Sometimes It move the setCenter.
But It not the main problem that I care.
I've change to this
            if (event.type == sf::Event::MouseMoved)
                        {
                                posx = event.mouseMove.x;
                                posy = event.mouseMove.y;
                        }

                        if (event.type == sf::Event::MouseWheelMoved)
                        {
                               
                                if (event.mouseWheel.delta == 1)
                                {
                                        view1.zoom(0.9f);
                                }
                                if (event.mouseWheel.delta == -1)
                                {
                                        view1.zoom(2.f);
                                }
                                view1.setCenter(posx, posy);
                               
                        }
Title: Re: View problem
Post by: delio on March 13, 2014, 12:58:08 pm
Please Help :'(
Title: Re: View problem
Post by: eXpl0it3r on March 13, 2014, 01:11:59 pm
What exactly is the problem? You wrote, you've solved something, so what's remaining?

When I zoom out I don't program display pink lines
display pink link only when I zoom in
It's an optical illusion. Your brain thinks it's pink because mixing blue and red will yield in a pink/purple color, but it's actually not. It's still blue and red if you zoom in again on your posted image.

(http://i.imgur.com/K828EHt.png)

To "fix" the problem, would involve changing the colors slightly, so the optical illusion would suggest another color. ;)
Title: Re: View problem
Post by: delio on March 14, 2014, 04:45:07 am
No, I mean Red line  :-[

How to hide it when I zoom out
and
display it when I zoom in
Title: AW: View problem
Post by: eXpl0it3r on March 14, 2014, 07:49:27 am
Don't draw them if the view zoom factor reaches a certain point. How? Well I don't know your code. ;)
Title: Re: AW: View problem
Post by: delio on March 14, 2014, 04:30:09 pm
Don't draw them if the view zoom factor reaches a certain point. How? Well I don't know your code. ;)
OK, I will try it by myself first. If I can't do it. May I ask you again?  :D

and Others problem (many problem :P)
Please guide me

Problem 1
#ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib")  
#endif // SFML_STATIC


#include <SFML/Graphics.hpp>

int posx, posy;
sf::View view1;

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::View view1(sf::FloatRect(0.f, 0.f, window.getSize().x, window.getSize().y));

        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                        if (event.type == sf::Event::MouseMoved)
                        {

                                posx = event.mouseMove.x - window.getSize().x / 4;
                                posy = event.mouseMove.y - window.getSize().y / 4;
                        }

                        if (event.type == sf::Event::MouseWheelMoved)
                        {

                                if (event.mouseWheel.delta >= 1)
                                {
                                        view1.zoom(0.9f);
                                        view1.setCenter(posx, posy);
                                        window.setView(view1);
                                }
                                if (event.mouseWheel.delta <= -1)
                                {
                                        view1.zoom(2.f);
                                        view1.setCenter(posx, posy);
                                        window.setView(view1);
                                }


                        }
                        if (event.type == sf::Event::Resized)
                        {
                                sf::View view1(sf::FloatRect(0, 0, event.size.width, event.size.height));
                                sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
                                window.setView(sf::View(visibleArea));
                                window.setView(view1);
                        }
                }

                window.clear();
                window.draw(shape);
                window.display();
        }

        return 0;
}

From this code
When I resize window and zoom , my circle will be stretch.

--------------------------------------------------------------------------------------
Problem 2

(http://upic.me/i/bb/8g700.png)

In the picture(Right side)
when I zoom in or out,
I want (0,0) coordinate to be in the red text not in the blue text

I've try Coordinates conversions in tutorial but doesn't work.


-------------------------------------------------------------------------------------
Sorry for bad English

Thank you very much

 
Title: Re: View problem
Post by: delio on March 16, 2014, 04:01:05 am
Please help :'(
Title: Re: View problem
Post by: zsbzsb on March 16, 2014, 04:11:23 am
Problem #1: http://sfml-dev.org/tutorials/2.1/graphics-view.php#showing-more-when-the-window-is-resized (http://sfml-dev.org/tutorials/2.1/graphics-view.php#showing-more-when-the-window-is-resized)

Problem #2: You need to explain better about what you want exactly.  ;)
Title: Re: View problem
Post by: delio on March 16, 2014, 04:23:57 am
Problem #1: http://sfml-dev.org/tutorials/2.1/graphics-view.php#showing-more-when-the-window-is-resized (http://sfml-dev.org/tutorials/2.1/graphics-view.php#showing-more-when-the-window-is-resized)
I've copy tutorial code to my code (see my upper post).

When I resize window and zoom , my circle will be stretch.
I can't mix "Showing more when the window is resized" with my zoom code.

Problem #2: You need to explain better about what you want exactly.  ;)
Sorry for bad explanation
(http://upic.me/i/bb/8g700.png)

when I started program
(0,0) coordinate will be on upper left of circle
(like the left side of picture)

when I zoom out
I want (0,0) coordinate to be on upper left of circle(red coordinate) not upper left of window(blue coordinate)
 
I've read Coordinates conversions in tutorial page
but I don't understand how to use it.

Thanks

Title: AW: [Unsolved see lastest rep.] View problem
Post by: eXpl0it3r on March 16, 2014, 08:51:35 pm
You simply have to move your view to the right position. To do so you'll of course have to understand how the view works. If you can't figure it out by reading the official tutorial and my view tutorial on the Wiki, then I'm not sure how we could help you further. ;)