Using the Projection Matrix to zoom in on a screen

BlitzMax Forums/BlitzMax Programming/Using the Projection Matrix to zoom in on a screen

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yan: Basically the code I had before from you on an old thread didn't rescale the coords or the images when you changed viewport size, which it should have done (Mutley's did). Don't know why. May have been the nearVal setting or I screwed it up somehow. Otherwise it looked the same.


ImaginaryHuman: OK thanks. All I'm doing is changing the view port size to simulate scaling not using the scale param so I'm pretty sure that's OK. I've tested it on my PC in DX and GL and on my mac in GL. It works fine on all in full-screen and windowed mode except for one case: GL Windowed Mode on the PC seems to be a little jerky when zooming in. I've no idea why, but my game won't support that driver anyway. Hopefully this will still be a valid approach when supporting widescreen but I haven't got to that bridge yet...

TonyG: I'd love to BUT because I'm contracting for BFG, any work I do I'm being paid for (and they own) and can't make public I'm afraid :-( But I can *maybe* talk about the general method I used (possibly my contract prohibits that too under proprietary information/secrets)...

Basically all I did was get Mutley's TProjectionMatrix and add in a Zoom field and OriginalWidth and OriginalHeight fields. Then I alter the Zoom value in a loop and work out the Width and Height based on the OriginalWidth/Height and zoom and the set up the projection matrix again. This has the effect of zooming in or out very nicely and doesn't involve using the scale parameter. Naturally I've added more methods to automate the zooming over a set time and to zoom to a certain point by shifting SetOrigin. When combined with my TSlowMotion type I get a wicked Matrix-style Bullet Time effect which you'll see in my next game.