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.
Sau khi bạn tải thư viện xuống thiết bị và kiểm nhập thư viện vào hệ thống kiểm soát nguồn, vui lòng thực hiện những thay đổi sau đây cho các chế độ cài đặt bản dựng của dự án.
Thư viện tĩnh
Hãy làm theo các bước sau để liên kết dự án với thư viện tĩnh:
Thêm gamesdk/include vào trình biên dịch của bạn, bao gồm cả các đường dẫn.
Thêm swappy/swappyGL.h để tích hợp với OpenGL ES. Trong hầu hết các trường hợp, tệp tiêu đề chứa tất cả các hàm cần thiết để tích hợp thư viện vào công cụ.
Thêm đường dẫn của biểu mẫu sau vào đường dẫn thư viện trình liên kết của bạn:
Các bước trên liên kết tĩnh với một phiên bản thư viện Tốc độ khung hình được biên dịch cho tổ hợp ABI, cấp độ API, NDK và STL đã cho. Nếu tổ hợp không sẵn có cho trong chế độ cài đặt, thì bạn có thể liên kết với thư viện chia sẻ:
Làm theo các bước 1 và 2 trong mục trước để cập nhật trình biên dịch bao gồm các đường dẫn và sử dụng tệp tiêu đề thích hợp.
Thêm đường dẫn của biểu mẫu sau vào đường dẫn thư viện trình liên kết của bạn:
Mối liên kết tĩnh sẽ tạo ra lượng mã nhỏ hơn nhiều vì bạn không cần phải gói thư viện chia sẻ libswappy.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/bouncyball/app/CMakeLists.txttrong thư viện đã tải xuống để xem cấu hình CMake mẫu. 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 thử 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, vui lòng làm như sau:
Đưa tệp này vào trong CMakeLists.txt: include("path/to/gamesdk/samples/gamesdk.cmake")
Gọi hàm add_gamesdk_target với thư mục chứa gamesdk: add_gamesdk_target(PACKAGE_DIR path/to/gamesdk)
Trong target_link_libraries cho thư viện gốc, hãy thêm swappy làm
phần phụ thuộc:
target_link_libraries(native-lib swappy ...)
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,["After you've [downloaded the library](/games/sdk/frame-pacing/opengl) onto your\nmachine and have checked it into your source control system, make the following\nchanges to your project's build settings.\n\nStatic library\n\nDo the following steps to link your project to the static library:\n\n1. Add `gamesdk/include` to your compiler include paths.\n2. Include `swappy/swappyGL.h` for integration with OpenGL ES. In most cases, the header file contains all the functions you need to integrate the library into your engine.\n3. 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 For example: `gamesdk/libs/arm64-v8a_API24_NDK17_cpp_static_Release`\n4. Add `-lswappy_static` to your linker command.\n\nShared library\n\nThe above steps statically link against a version of the Frame Pacing library\ncompiled for the given ABI, API level, NDK and STL combination. If the combination\nis not available for your settings, you can instead link against the shared\nlibrary:\n\n1. Follow steps 1 and 2 from the previous section to update your compiler include paths and use the appropriate header file.\n2. Add a path of the following form in your linker library paths:\n\n ```\n gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release/lib/swappy\n ```\n3. Add `-lswappy` to your linker command.\n\nStatic linking will give you a much smaller code footprint as you don't need to\nbundle the `libswappy.so` shared library.\n\nUsing CMake (static library only)\n\nIf you are using CMake, see the `gamesdk/samples/bouncyball/app/CMakeLists.txt`\nfile in the [downloaded library](/games/sdk/frame-pacing/opengl)\nfor an example CMake configuration. It includes a utility file, `gamesdk/samples/gamesdk.cmake`,\nthat performs final checks, adds the proper compiler include paths and\ngenerates a target that you can use to link the library.\n\nTo use this utility, do the following:\n\n1. Include this file in your CMakeLists.txt: `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 `\u003cvar translate=\"no\"\u003epath/to/gamesdk\u003c/var\u003e`)`\n3. In your `target_link_libraries` for your native library, add `swappy` as a dependency: `\n target_link_libraries(native-lib swappy ...)\n `\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)."]]