SFML community forums

Help => Graphics => Topic started by: Mercurialol on January 05, 2013, 07:49:59 am

Title: Texture size when drawing
Post by: Mercurialol on January 05, 2013, 07:49:59 am
Hey all. I'm sorry if the question was already answered, but I couldn't find it using search.

I took a 600x600 px texture and tried to draw it in the default view of a render window of size 600x600 and it was cropped. After a bit of testing, it fit perfectly in a render window with the 750x750 size. I've tried setting the sprite textureRect to 600x600 but nothing changed (probably since the sprite default textureRect is the whole rect).

Render window documentation says video mode size includes title bar and borders, but 150px sounds too much for both.

1.Is the viewCoordinates/pixel ratio 1:1, and if YES what else could be the problem?
2.If the video mode size includes borders and title bar, why does getDefaultView().getSize().x/y return the videoMode size? Shouldn't view show the drawable area size only ? Or the titlebar and borders are also drawable :) ?

Thanks in advance

Mercurial
Title: Re: Texture size when drawing
Post by: Laurent on January 05, 2013, 08:50:55 am
Can you show your code please (a minimal and complete one if possible)?

Quote
Render window documentation says video mode size includes title bar and borders
I'm pretty sure it says the opposite. If not, then it must be corrected.
Title: Re: Texture size when drawing
Post by: cire on January 05, 2013, 11:57:30 am
    /// \brief Construct a new window
    ///
    /// This constructor creates the window with the size and pixel
    /// depth defined in \a mode.

It's not exactly crystal clear.
Title: Re: Texture size when drawing
Post by: Laurent on January 05, 2013, 12:53:16 pm
It is of course more detailed in the tutorials

Quote
The first argument, the video mode, defines the size of the window (the inner size, without the titlebar and borders)
Title: Re: Texture size when drawing
Post by: Mercurialol on January 07, 2013, 05:26:10 pm
Yeah my bad about that one. About mapping pixel to coordinates 1:1, I will have to find out what exactly happened... Since when I draw everything on the default view of the render window it was just fine. Before, I had something like (pseudo code):
setView(view1);
drawSomeStuff();
setView(view2);
drawSomeOtherStuff();
and view1 had width of lets say 3/4 of screenSize.width and view2 the left 1/4 and the position was set correctly, but it looked weird and like it didn't map 1:1 pixel to coords. My past experience are some other engines that use views basically as containers which you position, and add sprites as subviews, so maybe I misunderstood the logic here.

 I'm not sure what exactly happened, but I'll try to reformulate my question as soon as I find out.

Mercurial

Title: Re: Texture size when drawing
Post by: Laurent on January 07, 2013, 05:47:02 pm
The view defines the part of the world that you see, not where it is located in the window. To change the latter, set the view's viewport property.
Title: Re: Texture size when drawing
Post by: eXpl0it3r on January 07, 2013, 06:34:05 pm
If you've problems understanding how sf::Views work, then maybe my tutorial can give you some intuition: Using sf::View (https://github.com/SFML/SFML/wiki/Tutorial:-Using-View)
Title: Re: Texture size when drawing
Post by: Mercurialol on January 07, 2013, 08:39:53 pm
Yeah, that's what it was. The last view I have set - I have basically defined the part of the world I see.

Sorry for that.

Mercurial