Wanted zooming code

hey ppl i wanted to apply zoom in and zoom out effect to my existing code… if anyone has a small demo code implementing zooming effect ,kindly please send it to me so that its helpful to me to understand its concept.

thank u.

do a glScale(x, x, 1) to your projection matrix right after you load the identity (before any calls to glFrustum glOrtho and such) this will have a zooming effect when x > 1 and the opposite when x < 1

but glScale() with different factors reduce performance. Do the zoom quickly or do glSlace(x,x,x). In the page of opengl tutorials there is an article explaining this issue.

What are you talking about? There is no function like glSlace and glScale DOES NOT affect the performance at all (if you don’t call it thousands of times, of course)

Maybe the misunderstanding is that glScale is bad for performance if applied to the modelview matrix, since this means that normals must be renormalized? However, for the projection matrix this does not apply.

thanks ppl for ur reply. i will just try out these stuffs and get back to u in case of any problem…

Yes, whe I said glScale(x,y,z) where x!=y!=z, OpenGL have to recalculate normals. But if x=y=z, you can use
glEnable(GL_RESCALE_NORMAL);

See the first part of this:
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/

Yes, but rescaling is also bad, although not as bad as renormalizing.

RGHP, we talk about applying the scale to the projection matrix, while lighting (thus normal transformation) is performed in the modelview space. As thinks said. So no renormalization needed. Also, it is practically free on current hardware, even if it will be needed. I renormalize per-pixel :slight_smile:

Originally posted by RGHP:
but glScale() with different factors reduce performance. Do the zoom quickly or do glSlace(x,x,x). In the page of opengl tutorials there is an article explaining this issue.
I dont think it will reduce performance since you do the scale on the projection matrix, and all the normalization of normals (if any) takes place before the projection matrix is even used

Ok sorry, i was wrong, I thought you were going ti transform in Modelview Matrix

:S

Sorry!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.