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

Author Topic: [Unsolved see lastest rep.] View problem  (Read 3886 times)

0 Members and 1 Guest are viewing this topic.

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
[Unsolved see lastest rep.] View problem
« on: March 12, 2014, 05:05:00 am »
The picture below is when I zoom in.


The picture below is when I zoom out


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
« Last Edit: March 16, 2014, 01:46:41 pm by delio »

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Zoom and View problem
« Reply #1 on: March 12, 2014, 01:03:45 pm »
I think the documentation 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

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: Zoom and View problem
« Reply #2 on: March 12, 2014, 03:44:12 pm »
I think the documentation 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);
                               
                        }
« Last Edit: March 12, 2014, 03:55:48 pm by delio »

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: View problem
« Reply #3 on: March 13, 2014, 12:58:08 pm »
Please Help :'(

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10817
    • View Profile
    • development blog
    • Email
Re: View problem
« Reply #4 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.



To "fix" the problem, would involve changing the colors slightly, so the optical illusion would suggest another color. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: View problem
« Reply #5 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10817
    • View Profile
    • development blog
    • Email
AW: View problem
« Reply #6 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: AW: View problem
« Reply #7 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



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

 

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: View problem
« Reply #8 on: March 16, 2014, 04:01:05 am »
Please help :'(

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: View problem
« Reply #9 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

Problem #2: You need to explain better about what you want exactly.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: View problem
« Reply #10 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
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


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

« Last Edit: March 16, 2014, 04:26:56 am by delio »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10817
    • View Profile
    • development blog
    • Email
AW: [Unsolved see lastest rep.] View problem
« Reply #11 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/