Screen isn't refreshing?

Hello. I try to make a rotatable triangle. But i have a problem

#include <GL/glut.h>
#include <stdlib.h>
GLfloat rquad=0.0;

GLfloat aci;
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void gluPerspective(GLdouble fov, GLdouble aspect, GLdouble near, GLdouble far);
void ayarlar(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_SMOOTH);
gluPerspective(0.0,0.0, 1.5, 20.0);
}
void gosterim(void)
{
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glMatrixMode (GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
glRotatef(aci,45.0f,45.0f,0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(0.75f,0.5f,0.0f);
glVertex3f(0.25f,0.5f,0.0f);
glVertex3f(0.5f,1.0f,0.2f);

glColor3f(0.0, 1.0, 0.0);
glVertex3f(0.75f,0.5f,-0.2f);
glVertex3f(0.25f,0.5f,-0.2f);
glVertex3f(0.5f,1.0f,-0.2f);
glEnd();
aci+=0.5f;
glFlush();
}
int main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
glutInitWindowPosition(0,0);
glutInitWindowSize(200,200);
glutCreateWindow("OpenGL");
ayarlar();
glutDisplayFunc(gosterim);
glutMainLoop();
return 0;
}

But triangles isn’t rotating. If i maximize the windows, the screen refreshing by 1 frame. Hope understand. Sorry for bad English…

did you try by adding glLoadIdentity (); after glMatrixMode (GL_MODELVIEW).?

Yes i tried. But same problem :confused:

I believe you need a glutIdleFunc which gets called whenever GLUT has nothing to do, in this you want to trigger a redisplay to redraw the scene, that will call your display function.

Thanks for reply. But I don’t know how to use it. Can you change my code?

You find the documentation here: 7.18 glutIdleFunc . If I would start fixing your code, I would also switch from the out-dated immediate mode to modern GL and I don’t have the time for that :wink:

I made it. Thank you :smiley: