I have seen this FAQs: How can I automatically calculate a view that displays my entire model?
http://www.opengl.org/resources/faq/technical/viewing.htm
But this code does not run (for me), does any one know where is error on my code? I cannot see any thing on the screen with this code.
void Viewer::initGLES(){
glClearColor(0.f ,1.0f, 1.0f, 1.f);
glDisable(GL_DEPTH_TEST);
float diam = 1500;
float zNear = 1.3f;
float zFar = zNear + diam;
int cx = 0, cy = 0, cz = 0;
float left = cx - diam;
float right = cx + diam;
float bottom = cy - diam;
float top = cy + diam;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float aspect = iScreenWidth / iScreenHeight; // 240 x 320
if ( aspect < 1.0 ) { // window taller than wide
bottom /= aspect;
top /= aspect;
} else {
left *= aspect;
right *= aspect;
}
//glOrtho(left, right, bottom, top, zNear, zFar);
glOrthof(left, right, bottom, top, zNear, zFar);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0., 0., 2.*diam, cx, cy, cz, 0.0, 1.0, 0.0);
}
//------------------------------------
void Viewer::drawFP(){
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glEnableClientState(GL_VERTEX_ARRAY);
//glTranslatef (0,0,-5.f);
glColor4f(0,1,0,1);
static const GLfloat vertices[3 * 3] =
{
-1000, 1000, 0,
1000, -1000, 0,
1000, 1000, 0
};
glVertexPointer( 3, GL_FLOAT, 0, vertices );
glDrawArrays( GL_LINES, 0, 3);
}
Thanks all,