Results 1 to 2 of 2

Thread: What use of glutTimerFunc()? It do not do job. 8(

  1. #1
    Member Contributor
    Join Date
    Dec 2000
    Location
    Kaifeng,He'nan,PRC
    Posts
    69

    What use of glutTimerFunc()? It do not do job. 8(

    it do not do any job except once.

    glutTimerFunc(),how to use?


    =================================


    #include <gl/glut.h>
    #include <gl/glaux.h>
    #include <windows.h>
    #include <stdio.h>
    #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
    float xx(-1.0f);

    void renderScene(void)
    {

    glClear(GL_COLOR_BUFFER_BIT);

    glColor4f(1.0f,0.0f,0.0f,0.0f);
    glBegin(GL_LINES);
    glVertex3f(0.0f,-1.0f,0.0f);
    glVertex3f(xx,1.0f,0.0f);
    glEnd();

    glFinish();


    }

    void pp(int k)
    {
    if(xx>=2.0f)xx=-1.5f;
    xx+=0.5f;
    renderScene();
    }
    void keyfunc(unsigned char key,int x,int y)
    {
    }


    void changeSize(int w, int h)
    {
    if(h == 0) h = 1; float ratio = 1.0* w / h;
    glMatrixMode(GL_PROJECTION);glLoadIdentity();
    glViewport(0, 0, w, h);

    gluPerspective(45,ratio,1,10);

    glMatrixMode(GL_MODELVIEW);glLoadIdentity();
    gluLookAt(0.0,0.0,5.0, 0.0,0.0,-1.0, 0.0f,1.0f,0.0f);
    }

    void main(int argc,char** argv)
    {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(320,320);
    glutCreateWindow("!!");
    glClearColor(1.0f,1.0f,1.0f,1.0f);
    glEnable(GL_TEXTURE_2D);
    glutKeyboardFunc(keyfunc);
    glutReshapeFunc(changeSize);
    /////////////////////////////////////////////
    ///here i call glutTimerFun(),but is do no job but first time.
    glutTimerFunc(1,pp,1);
    //////////////////////////////////////////////
    glutDisplayFunc(renderScene);
    glutIdleFunc(renderScene);
    glutMainLoop();

    }
    ========================
    As an old Chinese saying:One Live a Short while Die a Long...
    If I am useful to this world,I am reasonable to myself.
    =========================

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: What use of glutTimerFunc()? It do not do job. 8(

    in the pp function stick another call to
    glutTimerFunc(1,pp,1);

Similar Threads

  1. How do I use gluttimerfunc .......?
    By karika in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-01-2015, 04:59 PM
  2. glutTimerFunc
    By jsim1982 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-11-2005, 11:26 PM
  3. Need some help with glutTimerFunc
    By ShinGouki in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 05-09-2003, 12:01 AM
  4. glutTimerFunc()?
    By beet6 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 01-19-2002, 08:24 PM
  5. How to use glutTimerFunc()?
    By beet6 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-18-2002, 06:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean