Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
sf::Texture getSize() crashes the program
Print
Pages: [
1
]
Author
Topic: sf::Texture getSize() crashes the program (Read 2125 times)
0 Members and 1 Guest are viewing this topic.
lorence30
Full Member
Posts: 124
sf::Texture getSize() crashes the program
«
on:
April 12, 2016, 08:57:38 pm »
Hello, i have a problem
my problem gets crashed whenever i get the size of square, even in circle and other shapes
int
main
(
)
{
sf
::
RectangleShape
square
(
sf
::
Vector2f
(
50
,
50
)
)
;
std
::
cout
<<
square.
getTexture
(
)
-
>
getSize
(
)
.
x
;
}
Logged
AlejandroCoria
Jr. Member
Posts: 68
Re: sf::Texture getSize() crashes the program
«
Reply #1 on:
April 12, 2016, 09:47:36 pm »
If you do not set a texture to a Shape, getTexture return nullptr.
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11034
AW: sf::Texture getSize() crashes the program
«
Reply #2 on:
April 13, 2016, 08:04:27 am »
And nullptr can't be accessed (it points to nothing), thus the crash.
What you actually want to use are local or global bounds.
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
lorence30
Full Member
Posts: 124
Re: sf::Texture getSize() crashes the program
«
Reply #3 on:
April 13, 2016, 10:36:13 pm »
i thought it already has a texture and its size is 50x50
thanks
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
sf::Texture getSize() crashes the program
anything