PDA

View Full Version : wanted zooming code



debs
03-26-2007, 12:32 PM
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.

lerwen
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

RGHP
03-26-2007, 09:12 PM
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.

Zengar
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)

thinks
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.

debs
03-27-2007, 04:58 AM
thanks ppl for ur reply. i will just try out these stuffs and get back to u in case of any problem..

RGHP
03-27-2007, 09:28 AM
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/

thinks
03-27-2007, 09:30 AM
Yes, but rescaling is also bad, although not as bad as renormalizing.

Zengar
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 :)

lerwen
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

RGHP
03-27-2007, 07:50 PM
Ok sorry, i was wrong, I thought you were going ti transform in Modelview Matrix

:S

Sorry!