• Advertisement
Sign in to follow this  

program not looping

This topic is 4407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

//this program not looping... #include <windows.h> #include <stdio.h> #include <gl\gl.h> #include <gl\glu.h> #include <gl\glaux.h> #include <gl\glut.h> static float x1 = -0.5f, y1 = -0.5f, x2 = 0.5f, y2 = -0.5f, x3 = 0.5f, y3 = 0.5f, x4 = -0.5f, y4 = 0.5f; GLuint texture[1]; AUX_RGBImageRec *LoadBMP(char *Filename) { FILE *File=NULL; return auxDIBImageLoad(Filename); return NULL; } int LoadGLTextures() { AUX_RGBImageRec *TextureImage; TextureImage=LoadBMP("Data/dat.bmp"); glGenTextures(1, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); return TRUE; } int InitGL(GLvoid) { if (!LoadGLTextures()) { return FALSE; } glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); return TRUE; } void DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(x1, y1, 0.5f); glTexCoord2f(1.0f, 0.0f); glVertex3f( x2, y2, 0.5f); glTexCoord2f(1.0f, 1.0f); glVertex3f( x3, y3, 0.5f); glTexCoord2f(0.0f, 1.0f); glVertex3f( x4, y4, 0.5f); glEnd(); //glFlush(); glutSwapBuffers(); printf("Looping..."); /*Problem: Quads drawing and i can see the texture... But This Program not looping Console Output: Looping...(Only one time, not looping) What is the program */ } void main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(320,320); glutCreateWindow("GLut BUrak"); InitGL(); glutDisplayFunc(DrawGLScene); glutMainLoop();//loop } hello i am from turkey... this program not looping what can i do?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
as I recall, glut apps only update when they think they need to, so unless you resize the window or make a call to glutPostRedisplay, the program doesn't know it needs to redraw.

Share this post


Link to post
Share on other sites
ok, how i will animate my quad?
i used x1 =+ 0.01(animating but only one time(i want every time))
i used x1 += 0.01(animating but only one time(i want every time))
i used x1++ (animating but only one time(i want every time))

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement