Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Các phần sau mô tả cách tích hợp thư viện Tuning Fork vào chuỗi công cụ và cách sử dụng các chức năng mà thư viện cung cấp. Thư viện này có sẵn dưới dạng một thư viện tĩnh hoặc thư viện chia sẻ trong Thư viện AGDK.
Sau khi bạn tải SDK xuống máy và kiểm nhập SDK đó vào hệ thống kiểm soát nguồn, hãy thực hiện những thay đổi được liệt kê tại các mục sau đây trong phần cài đặt bản dựng của dự án.
Trước khi bắt đầu
Bạn nên tích hợp thư viện Android Frame Pacing trước khi tích hợp thư viện Tuning Fork. Nếu làm như vậy, thư viện Tuning Fork có thể tự động ghi lại thời gian kết xuất khung hình; bạn không cần phải tự gọi các hàm đánh dấu nhịp độ khung hình.
Hãy xem các hướng dẫn về tích hợp sau đây để biết thêm thông tin:
Các bước trong phần thư viện tĩnh liên kết tĩnh với một phiên bản của thư viện Tuning Fork đã biên dịch cho tổ hợp ABI, cấp độ API, NDK và STL nhất định. Nếu chế độ cài đặt không có sẵn tổ hợp, bạn có thể liên kết với thư viện chia sẻ:
Thêm gamesdk/include vào trình biên dịch, bao gồm cả các đường dẫn.
Thêm đường dẫn của biểu mẫu sau trong đường dẫn thư viện trình liên kết:
Tính năng liên kết tĩnh sẽ giúp bạn tạo ra ít mã hơn nhiều vì bạn không cần phải gói thư viện chia sẻ libtuningfork.so.
Sử dụng CMake (chỉ dành cho thư viện tĩnh)
Nếu bạn đang sử dụng CMake, hãy xem tệp gamesdk/samples/tuningfork/insightsdemo/app/CMakeLists.txt để biết ví dụ về cấu hình CMake. Cấu hình này bao gồm một tệp tiện ích gamesdk/samples/gamesdk.cmake giúp thực hiện bước kiểm tra cuối cùng, thêm trình biên dịch phù hợp bao gồm các đường dẫn và tạo một mục tiêu mà bạn có thể dùng để liên kết thư viện đó.
Để sử dụng tiện ích này, hãy làm như sau:
Đưa tệp này vào trong tệp CMakeLists.txt của bạn: include("path/to/gamesdk/samples/gamesdk.cmake")
Gọi hàm add_gamesdk_target bằng thư mục chứa gamesdk: add_gamesdk_target(PACKAGE_DIR
path/to/gamesdk)
Trong target_link_libraries đối với thư viện gốc, thêm tuningfork làm phần phụ thuộc (và swappy nếu bạn đã tích hợp thư viện Android Frame Pacing):
target_link_libraries(native-lib swappy tuningfork ...)
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-26 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-26 UTC."],[],[],null,["The following sections describe how to integrate the Tuning Fork library\ninto your toolchain and how to use the functions that the library provides. The\nlibrary is available as a static or shared library in the AGDK Libraries.\n\nAfter you've [downloaded the SDK](/games/sdk#download) to your machine and\nchecked it into your source control system, make the changes listed in the\nfollowing sections to your project's build settings.\n\nBefore you begin\n\nYou should integrate the [Android Frame Pacing library](/games/sdk/frame-pacing)\nbefore integrating the Tuning Fork library. If you do this, the\nTuning Fork library can automatically record frame time; there is no\nneed to explicitly call the tick functions yourself.\n\nSee the following integration guides for more information:\n\n- [Integrate Android Frame Pacing into your OpenGL renderer](/games/sdk/frame-pacing/opengl)\n- [Integrate Android Frame Pacing into your Vulkan renderer](/games/sdk/frame-pacing/vulkan)\n\nStatic library\n\nTo link your project to the static library, do the following:\n\n1. Add `gamesdk/include` to your compiler include paths.\n2. Add a path of the following form in your linker library paths:\n\n ```\n gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release\n ```\n\n Look in `gamesdk/libs` and pick the one that best suits your toolchain (for\n example, `gamesdk/libs/arm64-v8a_API24_NDK17_cpp_static_Release`).\n3. Add `-ltuningfork_static` to your linker command (and `-lswappy_static` if\n you integrated the Android Frame Pacing library).\n\n4. Add the `INTERNET` permission to your `AndroidManifest.xml` file:\n\n \u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\nShared library\n\nThe steps in the [static library](#static-library) section statically link\nagainst a version of the Tuning Fork library compiled for the given ABI,\nAPI level, NDK, and STL combination. If the combination is not available for\nyour settings, you can instead link against the shared library:\n\n1. Add `gamesdk/include` to your compiler include paths.\n2. Add a path of the following form in your linker library paths:\n\n ```\n gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release/lib/tuningfork\n ```\n3. Add `-ltuningfork` to your linker command (and `-lswappy` if you integrated\n the Android Frame Pacing library).\n\n4. Add the `INTERNET` permission to your `AndroidManifest.xml` file:\n\n \u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\nStatic linking gives you a much smaller code footprint as you don't need to\nbundle the `libtuningfork.so` shared library.\n\nUsing CMake (static library only)\n\nIf you are using CMake, see the\n`gamesdk/samples/tuningfork/insightsdemo/app/CMakeLists.txt` file for an example\nCMake configuration. It includes a utility file,\n`gamesdk/samples/gamesdk.cmake`, which performs final checks, adds the proper\ncompiler include paths, and generates a target that you can use to link the\nlibrary.\n\nTo use this utility, do the following:\n\n1. Include this file in your `CMakeLists.txt` file: `include(\"`\u003cvar translate=\"no\"\u003epath/to/gamesdk\u003c/var\u003e`/samples/gamesdk.cmake\")`\n2. Call the `add_gamesdk_target` function with the folder containing the gamesdk: `add_gamesdk_target(PACKAGE_DIR\n `\u003cvar translate=\"no\"\u003epath/to/gamesdk\u003c/var\u003e`)`\n3. In your `target_link_libraries` for your native library, add `tuningfork` as a dependency (and `swappy` if you integrated the Android Frame Pacing library): ` target_link_libraries(native-lib swappy tuningfork ...) `\n\n| **Note:** The path to the gamesdk used for `include` and `add_gamesdk_target` can either be absolute (for example, `/home/yourusername/gamesdk` or `C:\\Android\\gamesdk`) or relative to the `CMakeLists.txt` file.\n\nFor advanced usage of CMake, see the [`gamesdk.cmake` source file](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/samples/gamesdk.cmake)."]]