Advertisement Jump to content
Sign in to follow this  

[solved]How is this being scaled?

This topic is 3102 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yes, I'm slow. But I'd still appreciate an explanation.

I have a textured quad.

I gather the borders of all the blobs and get this.

the coordinates for the polylines are specified in absolute [640x480] coordinates.

This is the broken-learning code I use to zoom out.

342 glMatrixMode(GL_PROJECTION);
343 glLoadIdentity();
344 xs -= 20.5f;
345 ys -= 20.5f;
346 zs -= 20.5f;
348 glOrtho(0+xs, 640+-xs, 480+-ys, 0+ys, -1, 1);
349 glMatrixMode(GL_MODELVIEW);
350 glLoadIdentity();
351 }

This is what I get.

Problem: There is no problem! The LINE_STRIP still fits to the image even those its coordinates haven't been altered, The viewport is no longer 640x480, but the line coordinates are and it remain intact. I'm confused. FWIW the code I'm using to draw the lines.

for(int i = 0; i < int(blobs.size()); i++)
541 {
542 glBegin(GL_LINE_STRIP);
543 std::vector<Point2D> outline = blobs.outline;
544 for(int p = 0; p < int(outline.size()); p++)
545 {
546 glVertex2d(outline

.x, outline

547 }
548 glEnd();

[Edited by - Giblodian on July 21, 2010 10:46:33 PM]

Share this post

Link to post
Share on other sites
The input data is staying the same, but you have changed how it draws.

Think of a 3D example. I have a small rock and to make it bigger I simply scale it bigger. So I send the same glVertex2d() data since it is the same rock, I simply just call glScalef() and that multiplies the glVertex2d() data. Again this is the same set of data, I just tell the graphics card I want it to be scaled before it draws it. One more example is that I can move anywhere on earth, but every longitude/latitude doesnt change. If I zoom a digital camera in, longitude/latituges positions don't change. It just changes how things are taken in the picture.

The same thing is happening here, you are simply just changing how it is drawn. If you click your mouse though, yes your mouse is in the 640x480 range and all your not drawing it in that range anymore so mapping the mouse to your newly drawn points wont work.

For doing this, you would have to either put your mouse through the same math that these are being drawn in, or apply your scale on the actual input points (and bring them back to the 640x480 region.)

hope that helps.

Share this post

Link to post
Share on other sites
I simply just call glScalef() and that multiplies the glVertex2d() data

Ahh, so this is what is happening? I thought glOrtho was just increasing/decrasing the viewing area.

Should I be using glScale or does it not matter?

Share this post

Link to post
Share on other sites
No, what your doing is fine, I was just applying the idea for a different topic. Essentially glOrtho changes the Orthographic field of view for your "camera". So your simply allowing your camera to see more of the world. Again every point in your world is still static in your world, but when you change the camera field of view, a point is going to draw to a different pixel. You could also move up or down, and your changing your camera position to view the map, your not actually changing the map position in the world. You are changing YOUR position in the world.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!