shell/platform/glfw/flutter_glfw.cc
// Spins up an instance of the Flutter Engine.
//
// This function launches the Flutter Engine in a background thread, supplying
// the necessary callbacks for rendering within a GLFWwindow (if one is
// provided).
//
// Returns a caller-owned pointer to the engine.
Spins up an instance of the Flutter Engine.
This function launches the Flutter Engine in a background thread, supplying
the necessary callbacks for rendering within a GLFWwindow (if one is
provided).

Returns a caller-owned pointer to the engine.
Spins up an instance of the Flutter Engine . This function launches the Flutter Engine in a background thread supplying the necessary callbacks for rendering within a GLFWwindow ( if one is provided ) . Returns a caller - owned pointer to the engine .
static FlutterEngine RunFlutterEngine(GLFWwindow* window,
                                      const char* assets_path,
                                      const char* icu_data_path,
                                      const char** arguments,
                                      size_t arguments_count) {
  std::vector<const char*> argv = {"placeholder"};
  if (arguments_count > 0) {
    argv.insert(argv.end(), &arguments[0], &arguments[arguments_count]);
  }
  FlutterRendererConfig config = {};
  if (window == nullptr) {
    config.type = kOpenGL;
    config.open_gl.struct_size = sizeof(config.open_gl);
    config.open_gl.make_current = [](void* data) -> bool { return false; };
    config.open_gl.clear_current = [](void* data) -> bool { return false; };
    config.open_gl.present = [](void* data) -> bool { return false; };
    config.open_gl.fbo_callback = [](void* data) -> uint32_t { return 0; };
  } else {
    config.type = kOpenGL;
    config.open_gl.struct_size = sizeof(config.open_gl);
    config.open_gl.make_current = GLFWMakeContextCurrent;
    config.open_gl.clear_current = GLFWClearContext;
    config.open_gl.present = GLFWPresent;
    config.open_gl.fbo_callback = GLFWGetActiveFbo;
    config.open_gl.gl_proc_resolver = GLFWProcResolver;
  }
  FlutterProjectArgs args = {};
  args.struct_size = sizeof(FlutterProjectArgs);
  args.assets_path = assets_path;
  args.icu_data_path = icu_data_path;
  args.command_line_argc = static_cast<int>(argv.size());
  args.command_line_argv = &argv[0];
  args.platform_message_callback = GLFWOnFlutterPlatformMessage;
  FlutterEngine engine = nullptr;
  auto result =
      FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args, window, &engine);
  if (result != kSuccess || engine == nullptr) {
    std::cerr << "Failed to start Flutter engine: error " << result
              << std::endl;
    return nullptr;
  }
  return engine;
}
static FlutterEngine RunFlutterEngine ( GLFWwindow * window , const char * assets_path , const char * icu_data_path , const char * * arguments , size_t arguments_count ) { std :: vector < const char * > argv = { " " } ; if ( arguments_count > 0 ) { argv . insert ( argv . end ( ) , & arguments [ 0 ] , & arguments [ arguments_count ] ) ; } FlutterRendererConfig config = { } ; if ( window == nullptr ) { config . type = kOpenGL ; config . open_gl . struct_size = sizeof ( config . open_gl ) ; config . open_gl . make_current = [ ] ( void * data ) -> bool { return false ; } ; config . open_gl . clear_current = [ ] ( void * data ) -> bool { return false ; } ; config . open_gl . present = [ ] ( void * data ) -> bool { return false ; } ; config . open_gl . fbo_callback = [ ] ( void * data ) -> uint32_t { return 0 ; } ; } else { config . type = kOpenGL ; config . open_gl . struct_size = sizeof ( config . open_gl ) ; config . open_gl . make_current = GLFWMakeContextCurrent ; config . open_gl . clear_current = GLFWClearContext ; config . open_gl . present = GLFWPresent ; config . open_gl . fbo_callback = GLFWGetActiveFbo ; config . open_gl . gl_proc_resolver = GLFWProcResolver ; } FlutterProjectArgs args = { } ; args . struct_size = sizeof ( FlutterProjectArgs ) ; args . assets_path = assets_path ; args . icu_data_path = icu_data_path ; args . command_line_argc = static_cast < int > ( argv . size ( ) ) ; args . command_line_argv = & argv [ 0 ] ; args . platform_message_callback = GLFWOnFlutterPlatformMessage ; FlutterEngine engine = nullptr ; auto result = FlutterEngineRun ( FLUTTER_ENGINE_VERSION , & config , & args , window , & engine ) ; if ( result != kSuccess || engine == nullptr ) { std :: cerr << " " << result << std :: endl ; return nullptr ; } return engine ; }
Spins up an instance of the Flutter Engine.
Spins up an instance of the Flutter Engine .
// FlutterProjectArgs is expecting a full argv, so when processing it for // flags the first item is treated as the executable and ignored. Add a dummy // value so that all provided arguments are used. // Provide the necessary callbacks for rendering within a GLFWwindow.