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

Author Topic: mapPixelToCoords  (Read 1152 times)

0 Members and 1 Guest are viewing this topic.

Kebab85

  • Newbie
  • *
  • Posts: 3
    • View Profile
mapPixelToCoords
« on: December 21, 2019, 04:23:02 pm »
Hello.

I'm pretty new at this and having a hard time trouble shoot this my self and i can't find the information i need on the board.

For some reason the mapPixelToCoords function doesn't seem to exist for me, i use version 2.5.1-1.
I'm not sure where i could be wrong but i try to use this from a window.  obj just as shown in your tutorial.

g++ output: ”class sf::Window” doesn't have a member with the name ”mapPixelToCoords”
(Sry bad translated from my native language)

Do i forget to declare something? Missing something when compiling? Version problems?

Sry if i explain things bad, i'm not schooled for programming and don't know all terms and bad english.

Best regards
Kebab

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: mapPixelToCoords
« Reply #1 on: December 21, 2019, 04:57:51 pm »
It's part of RenderTarget and as such part of RenderWindow and RenderTexture, but not part of sf::Window. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kebab85

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: mapPixelToCoords
« Reply #2 on: December 21, 2019, 05:36:23 pm »
Tyvm :D

Not sure i understand the answer but ill dig some more with that in mind :)

I assume this inheritance is what you describe to me.
https://www.sfml-dev.org/documentation/2.5.1-fr/classsf_1_1RenderWindow.php

To me the tutorial looked like i should create a RenderWindow named window then access it.
But i need to somehow access this function earlier in the chain.

sf::RenderWindow::mapPixelToCoords seems to show the function, would it be correct to just use it like this?

If so, any idea why i fail to understand that tutorial?
I don't see anything there that explains that.

Again tyvm for the help.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: mapPixelToCoords
« Reply #3 on: December 27, 2019, 11:21:28 pm »
If you not doing any rendering, you aren't using any view co-ordinates so there are none to convert to and from pixel positions. If you are using sf::Window, you refer to positions in the window by their pixels. One common usage for mapPixelToCoords is for mouse position. If you are using just sf::Window, the mouse position is in pixels and you can use that position directly.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*