perspective view problem

I am coding a small test application in Qt opengl and here is the code
/***********************************************************/

#ifndef gmopenglmain_cpp
#define gmopenglmain_cpp

#include<gmopenglmain.h>
#include<ui_xandyunits.h>
#include<QtGui/QDialog>
#include<QtGui/QMessageBox>
#include<QTGui/QColor>

gmopenglmain::
gmopenglmain( QWidget* parent , gmmainwidget *source )
:QGLWidget( parent )
{

object = 0;

m_source = source;

xydisplay = source-&gt;getXYDisplayEdit();

Ui_xandyunits *xyobj = new Ui_xandyunits();

QDialog *xyunits = new QDialog(this);

xyobj-&gt;setupUi( xyunits );

xyobj-&gt;xmeters-&gt;setText("50");

xyobj-&gt;ymeters-&gt;setText("50");

xyunits-&gt;exec();;

m_xmeters = (xyobj-&gt;xmeters-&gt;text()).toInt();

m_ymeters = (xyobj-&gt;ymeters-&gt;text()).toInt();

unitinmetersx = ((m_xmeters*.1) + 1 + 3);
unitinmetersy = ((m_ymeters*.1) + 1 + 3);


setMouseTracking(true);

}

gmopenglmain::
~gmopenglmain()
{
makeCurrent();
glDeleteLists( object, 1 );
}

/*!
Paint the box. The actual openGL commands for drawing the box are
performed here.
*/

void
gmopenglmain::
paintGL()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glLoadIdentity();

glCallList( object );

}

/*!
Set up the OpenGL rendering state, and define display list
*/

void
gmopenglmain::
initializeGL()
{
QColor black(0,0,0,255);
qglClearColor( black ); // Let OpenGL clear to black
object = makeObject();// Generate an OpenGL display list
glShadeModel( GL_FLAT );
}

/*!
Set up the OpenGL view port, matrix mode, etc.
*/

void
gmopenglmain::
resizeGL( int w, int h )
{
glViewport( 0, 0, (GLint)w, (GLint)h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0.0, unitinmetersx , //left and right
0.0,unitinmetersy, //bottom and top
150.0, 100.0 ); //near and far
glMatrixMode( GL_MODELVIEW );
}

/*!
Generate an OpenGL display list for the object to be shown, i.e. the box
*/

GLuint
gmopenglmain::
makeObject()
{
GLuint list;

list = glGenLists( 1 );

glNewList( list, GL_COMPILE );

qglColor( Qt::blue );  // Shorthand for glColor3f or glIndex
glTranslatef(0.0f,0.0f,0.0f);					

glBegin(GL_QUADS);						  // Draw A Quad

glVertex3f( 0.0f, 1.0f ,0.0f);// Top Left
glVertex3f( 1.0f, 1.0f , 0.0f); // Top Right
glVertex3f( 1.0f, 0.0f, 0.0f);// Bottom Right
glVertex3f( 0.0f,0.0f, 0.0f);// Bottom Left
glEnd(); // Done Drawing The Quad

glEndList();

return list;

}

#endif

/***********************************************************/

I am only able to see the box only when my znear is set to 100 in glortho or in glfrustrum

glOrtho( 0.0, unitinmetersx , //left and right
0.0,unitinmetersy, //bottom and top
150.0, 100.0 ); //near and far

This can not work because the near clipping plane must be in front of the far clipping plane. You must remember that znear and zfar are in fact negative values because z axis points toward the eye (eye is in (0,0,0)).
Usually znear is 0.1 and zfar 100

I am very much thank full for your reply
I have one more doubt on this
You mean to say that the near and far is always on negative z plane.Why it cannot be on the positive z plane

the near and far clipping planes must be in front of the eye which coordinates are (0,0,0). Like I said before the Z axis points toward the eye direction (out of the screen) so all clipping planes must be in the z negative area.

I did not mean that the znear and zfar values must be negative in the glOrtho function. opengl inverts these values automatically.

dletozeun, what you say about near and far clip planes are true for perspective projections. For orthographic projections, the values can be anything, except being equal.

The mapping between depth and clip planes is linear in orthographic projections, but not in perspective and the mapping doesn’t allow for arbitrary clip plane values in the same way. It’s a mathematical limitation, not a logical limitation (as in “near clip plane should be closer than the far one”, for example).

Ah ok I did not know that… Actually I had never took care of the opengl projection formula.

What I said before is what is more logical in my opinion when I use projections in opengl. Maybe AngelWarrior want to do a special projection. in this case he should take care of where he draws the scene objects.