resize objects is window

I am having trouble resizing the graphic in the window when I adjust the window size. I tried alot of the other example but none worked for mine. Here is some of my code…

void display(void)
{

drawManometer(); //function that calls graphics
glFlush ();

}

void reshape(int w, int h)
{

glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLsizei) w, 0.0, (GLsizei) h);
glMatrixMode(GL_MODELVIEW);

}

int main(int argc, char** argv)
{
glutInitDisplayMode (GLUT_DOUBLE| GLUT_RGB);
glutInitWindowSize (930, 200);
glutCreateWindow (“manometer bank v1.0”);
init();
glutDisplayFunc(display);
glutReshapeFunc (reshape);
glutMainLoop();
return 0;
}

Try this remove the ortho2D from your resize routine. make your orther2D a set size without the w/h variables.

put the ortho at the start of you display routine.

display()
glclear(…)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 100, 0.0, 100);
glMatrixMode(GL_MODELVIEW);

Originally posted by newguy:
[b]I am having trouble resizing the graphic in the window when I adjust the window size. I tried alot of the other example but none worked for mine. Here is some of my code…

void display(void)
{

drawManometer(); //function that calls graphics
glFlush ();

}

void reshape(int w, int h)
{

glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLsizei) w, 0.0, (GLsizei) h);
glMatrixMode(GL_MODELVIEW);

}

int main(int argc, char** argv)
{
glutInitDisplayMode (GLUT_DOUBLE| GLUT_RGB);
glutInitWindowSize (930, 200);
glutCreateWindow (“manometer bank v1.0”);
init();
glutDisplayFunc(display);
glutReshapeFunc (reshape);
glutMainLoop();
return 0;
}[/b]

thanks but it did not work. In my drawManometer(); I am calling data from a file to display in GL. But when I resize the window the graphics don’t fit in they get clipped. Is it because I am reading data from a file?

I think part of your problem is that you are using ortho mode, try changing to perspective view.

Originally posted by newguy:
thanks but it did not work. In my drawManometer(); I am calling data from a file to display in GL. But when I resize the window the graphics don’t fit in they get clipped. Is it because I am reading data from a file?

Hmm, I may be a bit grim here but what is it you want to do? For what you are drawing to resize with the window or not?