Hi!
I want to resize the backbuffer without zooming in or out. I mean, the rendered primitives should be the same size as before. I assume I have to change the view matrix, but how?
Resizing
Started by Oybl, Nov 23 2006 06:00 PM
7 replies to this topic
#1
Posted 23 November 2006 - 06:00 PM
#2
Posted 23 November 2006 - 06:38 PM
You mean you want them to be the same size in relation to the size of the screen, like changing screen resolutions? If that's the case, then you don't need to alter the view matrix at all. If you want them to be the same size in pixels, you'll need to reconstruct the view matrix with a smaller/larger field of view, proportional to the fraction by which you changed the size. You won't get pixel perfect accuracy but it will be close.
reedbeta.com - developer blog, OpenGL demos, and other projects
#3
Posted 23 November 2006 - 11:10 PM
I want them to be the same size in pixels. I was thinking about changing the camera position (zooming in or out), but I dont know how to calculate the amount.
#4
Posted 24 November 2006 - 02:53 AM
Don't move the camera. Just change the field of view. If for instance you increased the size of the back buffer by 5%, then increase the field of view by 5%.
(Note: technically what you need to do is increase the tangent of 1/2 of the field of view by 5%. But that takes some more complicated math to figure out, so for now just increase the field of view by 5%; it'll be approximately right.)
(Note: technically what you need to do is increase the tangent of 1/2 of the field of view by 5%. But that takes some more complicated math to figure out, so for now just increase the field of view by 5%; it'll be approximately right.)
reedbeta.com - developer blog, OpenGL demos, and other projects
#5
Posted 24 November 2006 - 03:45 AM
Or you could alter the projection matrix, by scaling it with the correct value. Scale it by 0.5 in case you are using 2 times bigger render target.
#6
Posted 24 November 2006 - 04:20 AM
Juhnu: won't that also scale your near and far plane distances?
reedbeta.com - developer blog, OpenGL demos, and other projects
#7
Posted 24 November 2006 - 06:21 AM
Reedbeta, yeah you are right. So..one should scale X and Y axis and leave Z as it was. That should work.
#8
Posted 25 November 2006 - 11:30 PM
Ok thanks guys, I will give it a try.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












