/**
   * Create a rendering engine to be used when the HLE modules have not yet been started.
   *
   * @return the initial rendering engine
   */
  public static IRenderingEngine createInitialRenderingEngine() {
    IRenderingEngine re = RenderingEngineLwjgl.newInstance();

    if (enableDebugProxy) {
      re = new DebugProxy(re);
    }

    return re;
  }
  private static IRenderingEngine createRenderingEngine(boolean enableSoftwareRendering) {
    // Build the rendering pipeline, from the last entry to the first one.
    IRenderingEngine re;

    if (enableSoftwareRendering) {
      // RenderingEngine using a complete software implementation, i.e. not using the GPU
      re = new RESoftware();
    } else {
      // RenderingEngine performing the OpenGL calls by using the LWJGL library
      re = RenderingEngineLwjgl.newInstance();
    }

    if (enableStatisticsProxy && DurationStatistics.collectStatistics) {
      // Proxy collecting statistics for all the calls (number of calls and execution time)
      re = new StatisticsProxy(re);
    }

    if (enableDebugProxy) {
      // Proxy logging the calls at the DEBUG level
      re = new DebugProxy(re);
    }

    if (!enableSoftwareRendering) {
      if (REShader.useShaders(re)) {
        // RenderingEngine using shaders
        re = new REShader(re);
      } else {
        // RenderingEngine using the OpenGL fixed-function pipeline (i.e. without shaders)
        re = new REFixedFunction(re);
      }
    }

    // Proxy removing redundant calls.
    // E.g. calls setting multiple times the same value,
    // or calls with an invalid parameter (e.g. for unused shader uniforms).
    // In the rendering pipeline, the State Proxy has to be called after
    // the Anisotropic/Viewport filters. These are modifying some parameters
    // and the State Proxy has to use the final parameter values.
    re = new StateProxy(re);

    // Proxy implementing a texture anisotropic filter
    re = new AnisotropicFilter(re);

    // Proxy implementing a viewport resizing filter
    re = new ViewportFilter(re);

    // Return the first entry in the pipeline
    return re;
  }