Timeline for Why does the setPosition function in SFML require the x and y arguments both floating-point numbers, not integers?
Current License: CC BY-SA 4.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 26, 2022 at 14:58 | comment | added | Mangata | @ĐạtPhạm To some extent this is general knowledge. As another answer said, some high-level APIs(such as SFML) for 2D games simplify this process, they adjust the scaling so that 1 unit of world coordinate measurement is exactly equal to 1 pixel. Maybe a book focused on SFML doesn't mention this concept to reduce complexity, which is beneficial. Some general game programming books, or books on low-level APIs (such as OpenGL) will definitely mention this concept. | |
| Jul 26, 2022 at 14:57 | comment | added | Vaillancourt♦ | @ĐạtPhạm Check how SFML implements its API: it's over OpenGL, which also relies partially on the OS API. OS windows are using integers because windows can't use half pixels, that's how the OS is designed. Within the OpenGL API, though, this limitation is no longer there, so we can use whatever coordinates we want. | |
| Jul 26, 2022 at 13:31 | comment | added | Đạt Phạm | What sources or books did you read that from? Could you share them with me? I've just touched on game programming. | |
| Jul 26, 2022 at 9:10 | comment | added | Mangata | Um... Is this answer answering the question, or as a supplement to the question? You can edit the question directly. World space and screen space are not the same, world space uses floating point coordinates, screen space uses pixel coordinates, the conversion relationship between them depends on the camera, in 2d games, it depends on the width of the orthographic camera. | |
| Jul 26, 2022 at 5:58 | history | answered | Đạt Phạm | CC BY-SA 4.0 |