david123
June 26th, 2007, 02:15 AM
Dear all
Regards
following is my code for zooming a triangle, but it is not working , i think some problem in GLlookAt();
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
System.Drawing.Size s = Size;
width = (double)s.Width;
height = (double)s.Height;
GL.glViewport(0,0,s.Width,s.Height);
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(60.0, (float)s.Width / (float)s.Height, 1.0, 50.0);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
}
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
GL.glLoadIdentity(); // Reset The Current Modelview Matrix
GL.gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0);
GL.glLoadIdentity();
GL.glTranslatef(-1.5f, 0.0f, -6.0f); // Move Left 1.5 Units And Into The Screen 6.0
GL.glBegin(GL.GL_TRIANGLES); // Drawing Using Triangles
GL.glVertex3f(0.0f, 1.0f, 0.0f); // Top
GL.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
GL.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
GL.glEnd();
this.Refresh();
// GL.glFlush();
}
kindly help me while zooming the above triangle.
waiting for your help
regards
david
Regards
following is my code for zooming a triangle, but it is not working , i think some problem in GLlookAt();
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
System.Drawing.Size s = Size;
width = (double)s.Width;
height = (double)s.Height;
GL.glViewport(0,0,s.Width,s.Height);
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(60.0, (float)s.Width / (float)s.Height, 1.0, 50.0);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glLoadIdentity();
}
public override void glDraw()
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
GL.glLoadIdentity(); // Reset The Current Modelview Matrix
GL.gluLookAt(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0);
GL.glLoadIdentity();
GL.glTranslatef(-1.5f, 0.0f, -6.0f); // Move Left 1.5 Units And Into The Screen 6.0
GL.glBegin(GL.GL_TRIANGLES); // Drawing Using Triangles
GL.glVertex3f(0.0f, 1.0f, 0.0f); // Top
GL.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
GL.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
GL.glEnd();
this.Refresh();
// GL.glFlush();
}
kindly help me while zooming the above triangle.
waiting for your help
regards
david