Original Post
I am have been using GLUT 3.7.6 for quite a while now... I have done some practice programs that render simple polygons and animate them.
Now... few days ago... I compiled a program that just rendered a triangle(no animations)... when I executed the program, the triangle appeared with desired results... now I change my window(Select internet explorer or any other application).... then click back to the opengl... the triangle became smaller... then I repeated the same thing.... the triangle became much smaller until it disappeared...
So, I set a callback to IdleFunc with Rendering function.... Now, when I execute the program, the triangle that is rendered becomes smaller very fast and disappears...
Thats the best explanation of the problem I can give right now....
I have the code of the program... I have done rendering and animation of simple polygons... it worked perfectly.... but I don't have a clue about what is going right now....
If I don't use the 'changeSize' function, I does'nt render anything.......
Any ideas?
Now... few days ago... I compiled a program that just rendered a triangle(no animations)... when I executed the program, the triangle appeared with desired results... now I change my window(Select internet explorer or any other application).... then click back to the opengl... the triangle became smaller... then I repeated the same thing.... the triangle became much smaller until it disappeared...
So, I set a callback to IdleFunc with Rendering function.... Now, when I execute the program, the triangle that is rendered becomes smaller very fast and disappears...
Thats the best explanation of the problem I can give right now....
I have the code of the program... I have done rendering and animation of simple polygons... it worked perfectly.... but I don't have a clue about what is going right now....
#include <GL\glut.h>
void changeSize(int w, int h) {
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if (h == 0)
h = 1;
float ratio = w * 1.0 / h;
// Use the Projection Matrix
glMatrixMode(GL_PROJECTION);
// Reset Matrix
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0, 0, w, h);
// Set the correct perspective.
gluPerspective(45.0f, ratio, 0.1f, 100.0f);
// Get Back to the Modelview
glMatrixMode(GL_MODELVIEW);
}
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluLookAt(0, 0, 5,
0, 0, 0,
0, 1, 0);
glBegin(GL_TRIANGLES);
glVertex2f(2, 3);
glVertex2f(-3, 3);
glVertex2f(-3, -3);
glEnd();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
// glutInitWindowSize(640, 480);
glutCreateWindow("Practice 3");
glutDisplayFunc(RenderScene);
glutReshapeFunc(changeSize);
// glutIdleFunc(RenderScene);
glutMainLoop();
return 0;
}
If I don't use the 'changeSize' function, I does'nt render anything.......
Any ideas?