   {
     do {
       switch (error) {
-      case GL_INVALID_ENUM: fprintf(stderr, "GL_INVALID_ENUM\n"); break;
-      case GL_INVALID_VALUE: fprintf(stderr, "GL_INVALID_VALUE\n"); break;
-      case GL_INVALID_OPERATION: fprintf(stderr, "GL_INVALID_OPERATION\n"); break;
-      case GL_INVALID_FRAMEBUFFER_OPERATION: fprintf(stderr, "GL_INVALID_FRAMEBUFFER_OPERATION\n"); break;
-      case GL_OUT_OF_MEMORY: fprintf(stderr, "GL_OUT_OF_MEMORY\n"); break;
-      case GL_STACK_OVERFLOW: fprintf(stderr, "GL_STACK_OVERFLOW\n"); break;
-      case GL_STACK_UNDERFLOW: fprintf(stderr, "GL_STACK_UNDERFLOW\n"); break;
-      default: fprintf(stderr, "Unknown error"); break;
+      case GL_INVALID_ENUM: LOG_ERROR("GL_INVALID_ENUM"); break;
+      case GL_INVALID_VALUE: LOG_ERROR("GL_INVALID_VALUE"); break;
+      case GL_INVALID_OPERATION: LOG_ERROR("GL_INVALID_OPERATION"); break;
+      case GL_INVALID_FRAMEBUFFER_OPERATION: LOG_ERROR("GL_INVALID_FRAMEBUFFER_OPERATION"); break;
+      case GL_OUT_OF_MEMORY: LOG_ERROR("GL_OUT_OF_MEMORY"); break;
+      case GL_STACK_OVERFLOW: LOG_ERROR("GL_STACK_OVERFLOW"); break;
+      case GL_STACK_UNDERFLOW: LOG_ERROR("GL_STACK_UNDERFLOW"); break;
+      default: LOG_ERROR("Unknown error"); break;
       }
       error = glGetError();
     } while (error != GL_NO_ERROR);

  bool wireframe = false;
  bool recreate_context = true;
  bool indexed = true;
  float threshold = 0.f;

  std::vector<char> scalarField_host;

  void onGLFWError(int error, const char* what)
  {
    fprintf(stderr, "GLFW Error: %s\n", what);
  }

  void onKey(GLFWwindow* window, int key, int scancode, int action, int mods)

      nvtxRangePop();
#endif
      CHECKED_CUDA(cudaMemGetInfo(&free, &total));
      LOG_ALWAYS("%12s: %.2f FPS (%.0fMVPS) cuda: %.2fms (%.0f MVPS) %ux%ux%u Nv=%u Ni=%u memfree=%zumb/%zumb",
              bc.name,
              iterations / elapsed, (float(iterations) * field_size.x * field_size.y * field_size.z) / (1000000.f * elapsed),
              cuda_ms / cuda_ms_n, (float(cuda_ms_n) * field_size.x * field_size.y * field_size.z) / (1000.f * cuda_ms),
