
How to zoom into a 2D window?
Hi all.
I am making a simple (!) 2d drawing editor and I use a homemade linked list to store all objects and their vertices in. All works fine.
Thing is I need to implement a zoom function that lets the user draw a rectangle on the drawing area and then that area is zoomed in on so it covers the whole drawing area. Anyone got it?
How do I do this? I am quite new to opengl as you might guess. Has something to do with the viewport and gluOrtho2D I guess..
Thanks!

November 06, 2001 12:56 PM
void glTranslatef(
GLfloat x,
GLfloat y,
GLfloat z
);
void glScalef(
GLfloat x,
GLfloat y,
GLfloat z
);
GLfloat x,
GLfloat y,
GLfloat z
);
void glScalef(
GLfloat x,
GLfloat y,
GLfloat z
);
Er, nicely done, AP.
You''re making a 2D editor in OpenGL? Interesting.
I think you can do what you want to do with gluOrtho2D and gluUnProject.
All your bases belong to us
You''re making a 2D editor in OpenGL? Interesting.
I think you can do what you want to do with gluOrtho2D and gluUnProject.
|
All your bases belong to us
Thanks for the reply.
I''m afraid I can''t get it to work though. First of all glUnProject() needs z-parameters aswell so I just put it this way:
gluUnProject(x1, y1, 0, model, proj, view, &wx1, &wy1, &wz1);
where wz1 is defined just like you defined wx1 and wy1;
I did the same thing on next function call. After calling the Zoomfunction I call Display(), is this what I should do? Do I have to call Reshape() aswell with the rectangle''s width and height? Tried both options but nothing at all happens.
Please help again!
Thanks
I''m afraid I can''t get it to work though. First of all glUnProject() needs z-parameters aswell so I just put it this way:
gluUnProject(x1, y1, 0, model, proj, view, &wx1, &wy1, &wz1);
where wz1 is defined just like you defined wx1 and wy1;
I did the same thing on next function call. After calling the Zoomfunction I call Display(), is this what I should do? Do I have to call Reshape() aswell with the rectangle''s width and height? Tried both options but nothing at all happens.
Please help again!
Thanks
Perhaps you could translate the screen where the rectangle would be centered, use glScalef(), then render.
The zoom rectangle would have to have the same aspect ratio as the viewport, or the zoomed image would be distorted.
After the aspect ratio is the same, find the ratio :
viewport rect/zoom rect = glScalef() values
Maybe I''m a bit off, but that should get you off in the right direction.
email
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
The zoom rectangle would have to have the same aspect ratio as the viewport, or the zoomed image would be distorted.
After the aspect ratio is the same, find the ratio :
viewport rect/zoom rect = glScalef() values
Maybe I''m a bit off, but that should get you off in the right direction.
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
[email=JValentine_13@hotmail.com]contact[/email]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement