PDA

View Full Version : Orthogonal view goes upside down



macsam
04-21-2015, 11:23 AM
Hi,

I have been using a perspective view but changed to an orthogonal view. When I used the perspective view I was able to walk through the model. Now with the Orthogonal when I walk through it seems to turn upside down!

Any clue as to what I might be doing wrong? Any help gratefully appreciated.

Agent D
04-22-2015, 04:37 AM
How do you compute the projection matrix?

macsam
04-23-2015, 05:55 AM
Thanks for your reply.

I presume this is what you would like to see:
Lvoid initializeGL(HWND hwnd, GLsizei width, GLsizei height)
{
GLfloat fmaxObjectSize, faspect;
GLdouble dnear_plane, dfar_plane,
glEmin = 0.0,
glEmax = 0.0,
glNmin = 0.0,
glNmax = 0.0,
glFar = 0.0 ;

GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };


/* glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);*/



glClearIndex( (GLfloat)BLACK_INDEX); //specify the clear value for the color index buffers BLACK_INDEX = black back ground
glClearDepth( 1.0 ); //clears the depth buffer


glEnable(GL_DEPTH_TEST); //enable or disable server-side GL capabilities, GL_DEPTH_TEST = do depth comparisons and update the depth buffer
///transparent stuff/////////////
glEnable( GL_BLEND);//for transparent
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
////end of transparent stuff///////

glMatrixMode( GL_PROJECTION ); //sets the current matrix mode. GL_PROJECTION Applies subsequent matrix operations to the projection matrix stack.

glClearColor (0.0, 0.0, 0.0, 0.0);//this is also required for transparent stuff
glShadeModel (GL_FLAT);

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);



glEmin = (GLdouble)e_3dMin -(GLdouble)(glfZoom - (GLfloat)radius ) ;
glEmax = (GLdouble)e_3dMax + (GLdouble)(glfZoom - (GLfloat)radius ) ;
glNmin = (GLdouble)n_3dMin - (GLdouble)(glfZoom - (GLfloat)radius ) ;
glNmax = (GLdouble)n_3dMax + (GLdouble)(glfZoom - (GLfloat)radius );
glFar = (GLdouble)(4.0 * mf_3d);

glOrtho( glEmin, glEmax, glNmin, glNmax, -glFar, glFar);




glMatrixMode( GL_MODELVIEW ); //specify which matrix is the current matrix. GL_MODELVIEW Applies subsequent matrix operations to the modelview matrix stack.

if( cUseOpenGL != 'u' )//ie do not reset everything, just update the objects
{
dnear_plane = 5.0;
dfar_plane = 2.0 * mf_3d;//700.0;
fmaxObjectSize = (float)mf_3d;//mf_d;//100.0F;//3.0F;
//radius = mf_3d * 1.5;//mf_d * 1.5;///200;//radius = near_plane + maxObjectSize/2.0;

if( cAllowWottieFiles == 'n' )
{
flatitude = 0.0F;
flongitude = 0.0F;
flatinc = 6.0F;
flonginc = 2.5F;
}
else
{
flatitude = 90.0F;
flongitude = 0.0F;
flatinc = 6.0F;
flonginc = 2.5F;
}
}

glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );//part of zoom initialisation OpenGL p 357
createObjects( hwnd );
}