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

Author Topic: Texture size when drawing  (Read 1872 times)

0 Members and 1 Guest are viewing this topic.

Mercurialol

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Texture size when drawing
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture size when drawing
« Reply #1 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.
Laurent Gomila - SFML developer

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Texture size when drawing
« Reply #2 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture size when drawing
« Reply #3 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)
Laurent Gomila - SFML developer

Mercurialol

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Texture size when drawing
« Reply #4 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


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Texture size when drawing
« Reply #5 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.
Laurent Gomila - SFML developer

eXpl0it3r

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

Mercurialol

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Texture size when drawing
« Reply #7 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