zoom problem.

I cant get right set of lookat() bec it was inverse. For example, there are rectangle cube and cone: This is my init opengl codes with C#. using init opengl, then it should look like
1 2
/|–/|
3 5 4 |6
/\ |/_ |/
() 7 8

When I am using zoom function,then it should look this:
8 7 ()
/|–/| /
6 4 5 |3
|/_ |/
2 1

public OurView() : base()
{
GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GL.glShadeModel(GL.GL_SMOOTH);
GL.glClearDepth(1.0f);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDepthFunc(GL.GL_LEQUAL);
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(0.0f, 1.0f, 3.0f, 10.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
GL.glScalef(0.6f,0.6f,0.6f);
}

If I use “z” keyboard for zoom in, then
public void glZoomIn()
{
m_fDistance -= 1.0f;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
//GL.glMatrixMode(GL.GL_MODELVIEW);\ I tried this part but it wont work well
//GL.glLoadIdentity(); /
GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
GL.glScalef(0.6f,0.6f,0.6f);
GL.gluLookAt(0.0f, 0.0f, 2.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);
}

If I use “x” keyboard for zoom out, then
public void glZoomOut()
{
m_fDistance -= 1.0f;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
//GL.glMatrixMode(GL.GL_MODELVIEW);\ I tried this part but it wont work well
//GL.glLoadIdentity();
GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
GL.glScalef(0.6f,0.6f,0.6f);
GL.gluLookAt(0.0f, 0.0f, 2.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);
}
If you notice those codes that cause the problems, please correct it.
Thanks in Advance

Hi !

First of all, you use m_fDistance -= 1 for both zoom in and zoom out…guess that is wrong…

Then I guess you should uncomment the glLoadIdentity() before you call gluPerspective().

Mikael

Oh,yeah. I mistyped these variables, but it still have same problem. If I use these:GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity(); It shows part of shape is appearing and other part of shape is disappearing .

public OurView() : base()
{
GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GL.glShadeModel(GL.GL_SMOOTH);
GL.glClearDepth(1.0f);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glDepthFunc(GL.GL_LEQUAL);
GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(0.0f, 1.0f, 3.0f, 10.0f);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
GL.glScalef(0.6f,0.6f,0.6f);
}

If I use “z” keyboard for zoom in, then
public void glZoomIn()
{
m_fDistance += 1.0f;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
//GL.glMatrixMode(GL.GL_MODELVIEW);// I tried this part but it wont work well
//GL.glLoadIdentity(); /

GL.glScalef(0.6f,0.6f,0.6f);
GL.gluLookAt(0.0f, 0.0f, 2.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);
}

If I use “x” keyboard for zoom out, then
public void glZoomOut()
{
m_fDistance -= 1.0f;
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();

GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
//GL.glMatrixMode(GL.GL_MODELVIEW);// I tried this part but it wont work well
//GL.glLoadIdentity();
GL.glScalef(0.6f,0.6f,0.6f);
GL.gluLookAt(0.0f, 0.0f, 2.0f,0.0f, 0.0f, 0.0f,0.0f, 1.0f, 0.0f);
}

try making the 100.0f a larger number. In this statement GL.gluPerspective(m_fDistance , 1.0f, 1.0f, 100.0f);
the 100.0f can be changed to a larger number and when zooming out, it can take part of an image away… or has at least for me in the past. Try making it a bigger number and the part of the box may not dissapear.

Don’t think that is the problem, the only thing that is changing is the FOV.

Mikael

I am supecting that lookat() may cause a problem. When I am starting to running a program and it show a perfect view with rectangle cube, but if I am using zoomin() or zoomout(), it changed a location. For example, Before using zoom function, there is a dot on upper-left-back corner on cube. after using zoom, it changed to bottom-right-front corner on cube. I tried to used a zoom function without lookat() and dot is same place, but it didnt get right FOV bec it is missing some shape. so I have to use lookat() to get view a whole shape. I tried to tried to used a zoom function with lookat() and dot is different place and it shows all shape perfectly. I dont know how lookat() cause change a dot’s location. If you do, please explain it.