Skip to main content
gamedev.net
🔒 Locked

How do I make a zoom function?

Started by darkzim Dec 8, 2005 at 3:17 PM 1 replies 1.6k views
Original Post
darkzim
darkzim
For my sniper rifle in my game I'm trying to implement a "zoom-in" function and a sniper scope overlayed on the screen. I searched the web but couldn't find anything on how to implement the zoom. Also, I can do the alpha-blending, but how do I stretch a bitmap across the whole screen regardless of the screen resolution to make the scope? Thanks.
---------------------------------darkzim
Drakex
Drakex
Zooming for things like sniper scopes can be achieved by changing the field-of-view of the camera. If you use D3DXPerspectiveFovLH to generate your view matrix, it's the second parameter. Normally, you use PI / 4 for this value, but making it smaller will make the view zoom in.

As for the scope bitmap - I'd just make the quad the same dimensions as the screen, assuming that the way you're drawing your 2D sets up the ortho matrix to be the same size as the screen (i.e. if you're using ID3DXSprite to draw it). If you're using your own method to draw the 2D, you could also just use a constant size for the ortho matrix (like 640 x 480), make your bitmap the same size, and it'll draw the same way no matter the resolution. Only problem with that is that you still don't have all the bases covered - then you're restricted to one screen aspect ratio. So you could set up the ortho matrix to be the same aspect ratio of the screen. Either way, you're going to have to know something about the screen resolution :)
___________Hoo-rah.
darkzim
darkzim
Thanks, I got it working now complete with low mouse sensitivity when zoomed in. [lol].
---------------------------------darkzim

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.