Trying to zoom in on an arbitrary rect within a screen-aligned quad.

Posted by mos on Stack Overflow See other posts from Stack Overflow or by mos
Published on 2010-06-08T21:00:41Z Indexed on 2010/06/08 21:02 UTC
Read the original article Hit count: 158

Filed under:
|
|

I've got a screen-aligned quad, and I'd like to zoom into an arbitrary rectangle within that quad, but I'm not getting my math right.

I think I've got the translate worked out, just not the scaling. Basically, my code is the following:

//
// render once zoomed in
glPushMatrix();
glTranslatef(offX, offY, 0);
glScalef(?wtf?, ?wtf?, 1.0f);

RenderQuad();

glPopMatrix();

//
// render PIP display
glPushMatrix();
glTranslatef(0.7f, 0.7f, 0);
glScalef(0.175f, 0.175f, 1.0f);

RenderQuad();

glPopMatrix();

Anyone have any tips? The user selects a rect area, and then those values are passed to my rendering object as [x, y, w, h], where those values are percentages of the viewport's width and height.

© Stack Overflow or respective owner

Related posts about c++

Related posts about opengl