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

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';

What’s your projection matrix?

Thanks:



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);

The silence is deafening :slight_smile:

After only an hour and a half? Sorry, I have a job to be doing as well.

Thanks, I appreciate your help.

I should have said, glfZoom increases and decreases with the mouse wheel.

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

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.

Thank you. I will be using VBO’s in the near future because of memory problems I am having.

You can use VBOs with the matrix stack. Or add scaling to your own custom matrices. Or use your own custom matrices with glBegin/glEnd code. Or various combinations of some, all or none of these, any of which may or may not also include shaders.

For some reason the idea seems to exist (and it’s not just you, I’ve seen this elsewhere) that VBOs and shaders are modern OpenGL features, and that if you use them you have to go 100% modern OpenGL with everything.

That’s not actually the case at all. Both are actually very very old features, and you’re free to mix-and-match them with other old features as you see fit.

[QUOTE=mhagain;1287498]You can use VBOs with the matrix stack. Or add scaling to your own custom matrices. Or use your own custom matrices with glBegin/glEnd code. Or various combinations of some, all or none of these, any of which may or may not also include shaders.

For some reason the idea seems to exist (and it’s not just you, I’ve seen this elsewhere) that VBOs and shaders are modern OpenGL features, and that if you use them you have to go 100% modern OpenGL with everything.

That’s not actually the case at all. Both are actually very very old features, and you’re free to mix-and-match them with other old features as you see fit.[/QUOTE]

Thank you. I am sure it will not be the last time I am here.