PDA

View Full Version : glutTimerFunc



chign
05-13-2010, 07:41 AM
#include <stdlib.h>
#include <glut.h>
#include <math.h>
#include <stdio.h>
GLsizei width=640;
GLsizei height=480;
GLsizei xwmin=-50;
GLsizei xwmax=50;
GLsizei ywmin=-50;
GLsizei ywmax=50;

void timerFunc(int value) {
glPushMatrix();
glTranslatef(20.0,10.0,0);
glScalef(1.0,2.0,1.0);
glColor3f(0,0,1);
glutSolidCube(10);
glColor3f(1,0,1);
glutWireCube(10);
glPopMatrix();
glutPostRedisplay();
}


void display()
{
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT);


glColor3f(0,0,1);
glutSolidCube(10);
glColor3f(1,0,1);
glutWireCube(10);

glPushMatrix();
glTranslatef(10.0,10.0,0);
glScalef(1.0,2.0,1.0);
glColor3f(0,0,1);
glutSolidCube(10);
glColor3f(1,0,1);
glutWireCube(10);
glPopMatrix();

glFlush();
}


int main (int argc, char** argv)
{
glutInit(&amp;argc,argv);
glutInitWindowPosition(50,50);
glutInitWindowSize(width,height);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutCreateWindow("attempt1");

glMatrixMode(GL_PROJECTION);
glOrtho(-50,50,-50,50,0,100);

glMatrixMode(GL_MODELVIEW);
gluLookAt(-30,-30,40,0,0,0,0,1,0);

glutDisplayFunc(display);
glutTimerFunc(2000,timerFunc,0);
glutMainLoop();

return 0;
}

i do not see the results of glutTimerFunc.. or i see it and it disappears immediately.. why??

ZbuffeR
05-13-2010, 10:32 AM
http://www.opengl.org/resources/faq/technical/glut.htm#glot0027

chign
05-13-2010, 10:45 AM
thanksss... anther one question:
i am calling the glutIdleFunc(idle) but i want it to stop when i press the button and continue the programm from where i left it..?? is it possible??

ZbuffeR
05-13-2010, 12:30 PM
http://www.opengl.org/resources/libraries/glut/spec3/node63.html
This is the last time I give you such an answer.

Seriously, just search and read the fine manuals already.

Good luck.