OpenGL glScalef

Nibbie
Posts: 2
Joined: 2010.01
Post: #1
I'm trying to scale down a quad (assume lower left is at origin and it's a 10x10 square). I'm using GL_TRIANGLE_STRIP with 4 vertices to render it. Using glScalef will shrink/grow it relative to the origin since that's the lower left corner. If I want to have the quad shrink grow based on the exact center of that quad, what approach would I take?

Note: I'm using a glOrthof projection instead of glFrustrum.

Also, is this the right forum to ask OpenGL ES graphics questions?
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #2
Asking Open GL ES questions here is fine.
Your quad is actually growing and shrinking relative to the origin (0, 0, 0). If your quad is growing and shrinking relative to its bottom left corner then that would suggest the lower left corner happens to be on the origin. If you were to move the vertices so that they were spread equally around the origin this should fix your problem.
Code:
top right = 1.0, 1.0
top left = -1.0, 1.0
bottom left = -1.0, -1.0
bottom right = 1.0, -1.0
Hopefully that should be clear enough. I would emphasise that you really need to understand how transforms work before you proceed any further.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #3
If moving your actual vertex coordinates is inconvenient, you can always translate before (or after) scaling.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2010.01
Post: #4
backslash, your suggestion worked. Also, I'll review transforms.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  problems with glScalef() ghettotek 3 5,039 Feb 11, 2003 02:50 AM
Last Post: kelvin