Wiki

Clone wiki

scl-manips-v2 / helpme / GlutProblems

Weird and unexpected problems with graphics

This page has some quick fixes for graphics rendering problems.

‣ Display is blank (everything else is fine) : Thread ordering

When threading with OpenMP, the GLUT main loop should run in the first thread.

This is good:

#!c++
  omp_set_num_threads(2);
  int thread_id;

#pragma omp parallel private(thread_id)
  {
    thread_id = omp_get_thread_num();

    if(thread_id == 0) // <<<<< NOTE THIS
    { runGraphics(); } // I will do useful stuff.
    else if (thread_id == 1) 
    { doOtherStuff(); }
  }

This is bad:

#!c++
  omp_set_num_threads(2);
  int thread_id;

#pragma omp parallel private(thread_id)
  {
    thread_id = omp_get_thread_num();

    if(thread_id == 1) // <<<<< NOTE THIS
    { runGraphics(); } // I will not do anything useful.
    else if (thread_id == 0) 
    { doOtherStuff(); }
  }

Updated