Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: using gluLookup to zoom

  1. #1
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30

    using gluLookup to zoom

    Hi

    I am trying to Zoom in and out of the model using the mouse wheel. Nothing happens except when the camera position Z coordinate changes from positive to negative when the model swaps from front to back and vice versa. I would expect to see the model getting smaller as the camera moves away from the model.

    Any help gratefully appreciated




    Code :
    BOOL bError ;
    		unsigned int ui;
    		GLfloat fXc, fYc, fZc,
    			fXt, fYt, fZt,
    			fXu, fYu, fZu,//up vector
    			fHorizOntalDistance;;
     
     
                   #define PI  3.14159265358979323846
     
    		bError = 0;
    		ui = 1;
     
     
    	     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    	     glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
     
     
    	        glPushMatrix(); //this must have a corresponding glPopMatrix
    		glMatrixMode(GL_MODELVIEW);
    		glLoadIdentity();
     
     
    		fHorizOntalDistance = glfZoom;// *(GLfloat)cos(rad(flatitude));
    		= fHorizOntalDistance * (GLfloat)cos(rad(flongitude));//this is opengl equivilant to the y axis in normal coords
     
    		fXc = 0.0;
    		fYc = 0.0;
    		fZc = fHorizOntalDistance;
     
                    fXt = 0.0f;
    		fYt = 0.0f;
    		fZt = 0.0f;
     
    		fXu =  0.0f;
    		fYu =  1.0f;
    		fZu =  0.0f;
     
     
    		gluLookAt(fXc, fYc, fZc, fXt, fYt, fZt, 0.0f, 1.0f, 0.0f);
     
     
     
     
    		if (uiTriPointer > 1)//(&& cDisplayRockFace == 'y')// && cUsePointCloud == 'n')
    		{
    			glIndexi(BLUE_INDEX);
    			do
    			{
    				//glPushMatrix();//apr 14
    				glCallList((GLuint)(icTrianglesConstant + 100 + ui++));// icTrianglesConstant[ui]);//MMGLTRIANGLE); 
    				//glPopMatrix();//apr 14
    			} while (((UINT)ui - 1) * 30000 < uiTriPointer);
    		}
     
     
     
     
    		glIndexi(RED_INDEX);
     
    		glCallList(MMGLPOINTCLOUD);
     
     
     
     
     
     
    	glFlush();
    	bError = SwapBuffers(ghDC);// SWAPBUFFERS;
    	//if (bError == FALSE)
    	//	bError = FALSE;
    	cDrawingInProgress = 'n';

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,685
    What's your projection matrix?

  3. #3
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30
    Quote Originally Posted by mhagain View Post
    What's your projection matrix?
    Thanks:

    Code :
     
    GLdouble gdEmin,
    		gdEmax,
    		gdNmin,
    		gdNmax,
    		gdZmin,
    		gdZmax,
    		gdMaxDim;
     
    	OrthoLimitsM(&gdEmin, &gdEmax, &gdNmin, &gdNmax, &gdZmin, &gdZmax);
    	gdMaxDim = 1.0f * SetZoom();
     
     
    	gdEmin = gdEmin - gdMaxDim; 
    	gdEmax = gdEmax + gdMaxDim
    	gdNmin = gdNmin - gdMaxDim
    	gdNmax = gdNmax + gdMaxDim; 
    	gdZmin = gdZmin - gdMaxDim;
    	gdZmax = gdZmax + gdMaxDim
     
    	glOrtho(gdEmin, gdEmax, gdNmin, gdNmax, gdZmin, gdZmax);

  4. #4
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30
    The silence is deafening

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,685
    After only an hour and a half? Sorry, I have a job to be doing as well.

  6. #6
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30
    Thanks, I appreciate your help.

  7. #7
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30
    I should have said, glfZoom increases and decreases with the mouse wheel.

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,402
    Quote Originally Posted by macsam View Post
    Code :
    	glOrtho(gdEmin, gdEmax, gdNmin, gdNmax, gdZmin, gdZmax);
    The phenomenon of objects appearing to grow larger as they move closer to the viewer is specific to perspective projections. It doesn't occur with an orthographic projection.

  9. #9
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    30
    Quote Originally Posted by GClements View Post
    The phenomenon of objects appearing to grow larger as they move closer to the viewer is specific to perspective projections. It doesn't occur with an orthographic projection.
    Thank you. Can an orthographic view be zoomed into using another method? I do not want perspective in the view, hence me using ortho.

    Regards

    MacSam

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,685
    You can add a glScalef to your projection matrix. Since you're using old OpenGL with it's matrix stack this would be an appropriate way of doing it.

Posting Permissions

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