Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the GLFW example compiles. #30442

Merged
merged 2 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ group("flutter") {
"//flutter/sky",
]

# Ensure the example for a sample embedder compiles.
if (is_mac || is_linux) {
public_deps += [ "//flutter/examples/glfw" ]
}

# If enbaled, compile the SDK / snapshot.
if (!is_fuchsia) {
public_deps += [ "//flutter/lib/snapshot:generate_snapshot_bins" ]
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '88c2c61d323e3141849611b2d7fd4ac14103c61f',
'src': 'https://github.com/flutter/buildroot.git' + '@' + '4660f4a166979c64ff56f6b856b44ccc1dba5c63',

# Fuchsia compatibility
#
Expand Down
14 changes: 14 additions & 0 deletions examples/glfw/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

executable("glfw") {
output_name = "embedder_example"

sources = [ "FlutterEmbedderGLFW.cc" ]

deps = [
"//flutter/shell/platform/embedder:embedder",
"//third_party/glfw",
]
}
7 changes: 3 additions & 4 deletions examples/glfw/FlutterEmbedderGLFW.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ bool RunFlutter(GLFWwindow* window,
config.type = kOpenGL;
config.open_gl.struct_size = sizeof(config.open_gl);
config.open_gl.make_current = [](void* userdata) -> bool {
glfwMakeContextCurrent((GLFWwindow*)userdata);
glfwMakeContextCurrent(static_cast<GLFWwindow*>(userdata));
return true;
};
config.open_gl.clear_current = [](void*) -> bool {
glfwMakeContextCurrent(nullptr); // is this even a thing?
return true;
};
config.open_gl.present = [](void* userdata) -> bool {
glfwSwapBuffers((GLFWwindow*)userdata);
glfwSwapBuffers(static_cast<GLFWwindow*>(userdata));
return true;
};
config.open_gl.fbo_callback = [](void*) -> uint32_t {
Expand Down Expand Up @@ -125,7 +125,7 @@ bool RunFlutter(GLFWwindow* window,
}

void printUsage() {
std::cout << "usage: flutter_glfw <path to project> <path to icudtl.dat>"
std::cout << "usage: embedder_example <path to project> <path to icudtl.dat>"
<< std::endl;
}

Expand Down Expand Up @@ -163,7 +163,6 @@ int main(int argc, const char* argv[]) {
glfwSetMouseButtonCallback(window, GLFWmouseButtonCallback);

while (!glfwWindowShouldClose(window)) {
std::cout << "Looping..." << std::endl;
glfwWaitEvents();
}

Expand Down
5 changes: 5 additions & 0 deletions shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ shell_gpu_configuration("embedder_gpu_configuration") {

_framework_binary_subpath = "Versions/A/FlutterEmbedder"

config("embedder_header_config") {
include_dirs = [ "." ]
}

# Template for the embedder build. Used to allow building it multiple times with
# different flags.
template("embedder_source_set") {
Expand Down Expand Up @@ -108,6 +112,7 @@ template("embedder_source_set") {

public_configs += [
":embedder_gpu_configuration_config",
":embedder_header_config",
"//flutter:config",
]
}
Expand Down