cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.12k stars 1.92k forks source link

Is it appropriate to use floating point to store the window size? #12098

Open minggo opened 2 years ago

minggo commented 2 years ago

As the title said, is there any situation that need float window size? If not, i think we should use integer to store window size.

star-e commented 2 years ago

I have always used unsigned int to store window size. There are some graphics/system APIs which take float as input, but AFAIK they only use the integer part.

oahcy commented 2 years ago

In the end, it still needs to be converted to a int pixels, which feels unnecessary.

minggo commented 2 years ago

I have always used unsigned int to store window size. There are some graphics/system APIs which take float as input, but AFAIK they only use the integer part.

Yep, unsigned int is better. As negative value is meaningless.