Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: zoom implementation

Threaded View

  1. #1
    Newbie Newbie
    Join Date
    Sep 2013
    Posts
    1

    zoom implementation

    Hello,
    I am new to opengl . I am using opengl with Qt ,my problem is , i am making a quad and trying to implement zoomin and zoomout option .
    but i have some doubts , and need help.
    1. i tried with scalef () .. is it the right approach to implement that or i need to use glulookat () or any other function for zoom implementation???
    2. when i am using scalef() , the object moves with the zoomfactor.. how to scale an object around its own axis..

    here is the code of paintGL() function :

    void glwidget::resizeGL(int w, int h)
    {
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0,w,0,h,1.01,300.01);
    glMatrixMode(GL_MODELVIEW);

    }

    void glwidget:: paintGL()
    {

    glClear(GL_COLOR_BUFFER_BIT);
    glLoadIdentity();

    gluLookAt(0,0,50,
    0,0,0,
    0,1,0);
    glPushMatrix();
    glScalef(zoomfactor,zoomfactor,1);
    //glTranslatef(-zoomfactor,-zoomfactor,1);
    glBegin(GL_QUADS);
    glVertex3f(200,200,0);
    glVertex3f(250,200,0);
    glVertex3f(250,250,0);
    glVertex3f(200,250,0);
    glEnd();
    glPopMatrix();

    }

    where should i change in code so that it shows proper zooming ...

    Thanks in Advance
    Last edited by new-to-opengl; 09-30-2013 at 11:10 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •