Handling resize in WebGL

Share this:

PS: dont expect my board to be clean every time. I use my board a lot and I dont write to share but write it to learn things and teach myself new things every day.

When we are rendering something in canvas, we need to handle the resize of canvas because we cant render the same thing on different canvas sizes and likewise we can’t always preassume that the display size will remain the same all over time.

So, as a good programmer, we should add something to our code that handles resizing of browser or canvas.

It is a pretty basic thing but if you dive deep it is tricky as well. For me, I am not new to it but I thought to reread an awesome article for a short coffee break yesterday to refresh so many things and ideas.

Meanwhile, I am sharing what I checked and updated my concept on display size but I am not sure that all are there on my board but I think it should be a good start.

I don’t consider devicePixelRatio for resizing but now after reading this article, I think how bad it could have gone.

what the board is trying to say is what does resize mean for WebGL and Canvas as well as how can we handle it
there is another issue which is zoom in a browser that we usually do with ctrl and + in windows OR by going to zoom option after clicking hamburger button in the browser.

Something I would suggest checking:

Likewise, it would be a great read if you consider checking the high Dpi display. It is important to understand how things are rendered in the display and that is a pixel. I know how the retina display and the mobile display are different than our desktop display but there are some ideas that I am still confused so if I check it again in my spare time and have something on my board then I will share it.

Again, as I say, I dont write on my board to share but share what I have. If you find it useful, that’s nice, if you dont like it it is not the end of the internet.

Have a good day and share what you know and what you learned or learning so that education won’t be a privilege only for some people.

Happy Learning and always be nice.


Related posts

Leave a Reply