19 "This Flutter Embedder was authored against the stable Flutter "
20 "API at version 1. There has been a serious breakage in the "
21 "API. Please read the ChangeLog and take appropriate action "
22 "before updating this assertion");
34 std::chrono::duration_cast<std::chrono::microseconds>(
35 std::chrono::high_resolution_clock::now().time_since_epoch())
53 if (
key == GLFW_MOUSE_BUTTON_1 &&
action == GLFW_PRESS) {
60 if (
key == GLFW_MOUSE_BUTTON_1 &&
action == GLFW_RELEASE) {
64 glfwSetCursorPosCallback(
window,
nullptr);
73 if (
key == GLFW_KEY_ESCAPE &&
action == GLFW_PRESS) {
93 const std::string& project_path,
94 const std::string& icudtl_path) {
99 glfwMakeContextCurrent(
static_cast<GLFWwindow*
>(userdata));
103 glfwMakeContextCurrent(
nullptr);
107 glfwSwapBuffers(
static_cast<GLFWwindow*
>(userdata));
114 return reinterpret_cast<void*
>(glfwGetProcAddress(
name));
118 std::string assets_path = project_path +
"/build/flutter_assets";
121 .assets_path = assets_path.c_str(),
130 std::cout <<
"Could not run the Flutter Engine." << std::endl;
141 std::cout <<
"usage: embedder_example <path to project> <path to icudtl.dat>"
146 std::cout <<
"GLFW Error: (" <<
error <<
") " << description << std::endl;
155 std::string project_path =
argv[1];
156 std::string icudtl_path =
argv[2];
162 std::cout <<
"Could not initialize GLFW." << std::endl;
166#if defined(__linux__)
167 glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
170 GLFWwindow*
window = glfwCreateWindow(
173 std::cout <<
"Could not create GLFW window." << std::endl;
177 int framebuffer_width, framebuffer_height;
178 glfwGetFramebufferSize(
window, &framebuffer_width, &framebuffer_height);
183 std::cout <<
"Could not run the Flutter engine." << std::endl;
191 while (!glfwWindowShouldClose(
window)) {
195 glfwDestroyWindow(
window);
FlutterEngineResult FlutterEngineRun(size_t version, const FlutterRendererConfig *config, const FlutterProjectArgs *args, void *user_data, FLUTTER_API_SYMBOL(FlutterEngine) *engine_out)
Initialize and run a Flutter engine instance and return a handle to it. This is a convenience method ...
FlutterEngineResult FlutterEngineSendWindowMetricsEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterWindowMetricsEvent *flutter_metrics)
FlutterEngineResult FlutterEngineSendPointerEvent(FLUTTER_API_SYMBOL(FlutterEngine) engine, const FlutterPointerEvent *pointers, size_t events_count)
FlutterPointerPhase
The phase of the pointer event.
#define FLUTTER_ENGINE_VERSION
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
bool RunFlutter(GLFWwindow *window, const std::string &project_path, const std::string &icudtl_path)
static void GLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
static double g_pixelRatio
static constexpr FlutterViewId kImplicitViewId
void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, FlutterPointerPhase phase, double x, double y)
static const size_t kInitialWindowHeight
int main(int argc, const char *argv[])
static const size_t kInitialWindowWidth
void GLFWwindowSizeCallback(GLFWwindow *window, int width, int height)
void GLFWcursorPositionCallback(GLFWwindow *window, double x, double y)
void GLFWmouseButtonCallback(GLFWwindow *window, int key, int action, int mods)
void GLFW_ErrorCallback(int error, const char *description)
DEF_SWITCHES_START aot vmservice shared library name
ProcResolver gl_proc_resolver
BoolCallback make_current
UIntCallback fbo_callback
size_t struct_size
The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
BoolCallback clear_current
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
FlutterOpenGLRendererConfig open_gl
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).