SFML community forums
Help => Graphics => Topic started by: lorence30 on April 12, 2016, 08:57:38 pm
Title:
sf::Texture getSize() crashes the program
Post by:
lorence30
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
;
}
Title:
Re: sf::Texture getSize() crashes the program
Post by:
AlejandroCoria
on
April 12, 2016, 09:47:36 pm
If you do not set a texture to a Shape, getTexture return nullptr.
Title:
AW: sf::Texture getSize() crashes the program
Post by:
eXpl0it3r
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.
Title:
Re: sf::Texture getSize() crashes the program
Post by:
lorence30
on
April 13, 2016, 10:36:13 pm
i thought it already has a texture and its size is 50x50
thanks :)