S
S
sitev_ru2015-01-23 08:14:48
C++ / C#
sitev_ru, 2015-01-23 08:14:48

Is GLUT multitasking?

I am learning the GLUT library. Does GLUT give the impression that rendering and events work in parallel, creating multitasking?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Silin, 2015-01-23
@byme

No, but you can share it yourself. There everything is in one cycle, first input, and then TimerFunc. The input is fast, so it's invisible.
Test code

#include<glut.h>

void Keyboard(unsigned char key, int x, int y)
{
  while (true);
}
float angle = 0;
void Draw()
{
  angle++;
  glLoadIdentity();
  glRotatef(angle, 0,0,1);
  glClear(GL_COLOR_BUFFER_BIT);
  glBegin(GL_LINES);
    glVertex3f(1, 1, 0);
    glVertex3f(-1, -1, 0);
  glEnd();
  glFlush();
}
void Time(int)
{	
  Draw();
  glutTimerFunc(0,Time,50);
}
void Init()
{	
  glClearColor(1.0,1.0,1.0,0.0);  
  glColor3f(0,0,0);
  glOrtho(0.0,1,0.0,1, 1,-1); 
}

int main(int argv, char** argc)
{	
  glutInit(&argv, argc);
  glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); 
  glutInitWindowPosition(200,200);
  glutInitWindowSize(400,400);
  glutCreateWindow("hello");
  Init();
  glutKeyboardFunc(Keyboard);
  glutDisplayFunc(Draw);
  glutTimerFunc(0,Time,50);
  glutMainLoop();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question