View Full Version : 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.
03-26-2007, 08:15 PM
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.
03-27-2007, 12:33 AM
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)
03-27-2007, 03:50 AM
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
See the first part of this:
03-27-2007, 09:30 AM
Yes, but rescaling is also bad, although not as bad as renormalizing.
03-27-2007, 03:14 PM
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 :)
03-27-2007, 03:36 PM
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
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.