{
XEvent event;
KeySym keysym;
+ int repaint;
XNextEvent(display, &event);
+ repaint = 0;
switch(event.type)
{
case KeyPress:
{
update_view(display, &view, &event.xselection);
update_pending = 0;
+ repaint = 1;
}
break;
+ case Expose:
+ repaint = 1;
+ break;
default:
printf("event %d\n", event.type);
break;
}
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glUseProgram(view.programs[0]);
- glDrawElements(GL_TRIANGLE_STRIP, view.nelements, GL_UNSIGNED_SHORT, (void *)(12*sizeof(unsigned short)));
- glUseProgram(view.programs[1]);
- glDrawElements(GL_LINE_STRIP, 11, GL_UNSIGNED_SHORT, NULL);
- glXSwapBuffers(display, view.glx_window);
+ if(repaint)
+ {
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glUseProgram(view.programs[0]);
+ glDrawElements(GL_TRIANGLE_STRIP, view.nelements, GL_UNSIGNED_SHORT, (void *)(12*sizeof(unsigned short)));
+ glUseProgram(view.programs[1]);
+ glDrawElements(GL_LINE_STRIP, 11, GL_UNSIGNED_SHORT, NULL);
+ glXSwapBuffers(display, view.glx_window);
+ }
}
return 0;