Crates.io | trs_24 |
lib.rs | trs_24 |
version | 0.2.0 |
source | src |
created_at | 2023-12-01 06:34:08.484634 |
updated_at | 2024-08-11 07:29:04.049162 |
description | An OpenGL-Powered Game Engine (OpenGL 2.0+) |
homepage | |
repository | https://github.com/p0ryae/TRS_24 |
max_upload_size | |
id | 1054827 |
size | 96,624 |
An OpenGL-Powered Game Engine in Rust (OpenGL 2.0+)
Fundamentally, using two files is the ideal approach for using the engine. Primary file lib.rs
solely used for running the window on Android and building a shared object (*.so).
Secondary file main.rs
solely used for testing purposes on the host machine, and building for **Non-Android platforms. Both of these files need to be in the src
directory.
For both of these files to co-exist, the following needs to be in Cargo.toml
:
[lib]
# Causes the production of a dynamic system library
crate-type = ["cdylib"]
[[bin]]
name = "test"
path = "src/main.rs"
Both files will have their own respectable structure:
lib.rs
:[!NOTE] Notice the necessity of
#![cfg(target_os = "android")]
at the first line, and the#[no_mangle]
attribute before theandroid_main
function. They NEED to exist, otherwise you'll run to errors and crashes for compliation and building, respectively.
#![cfg(target_os = "android")]
use trs_24::overture::*;
#[no_mangle]
pub fn android_main(app: AndroidApp) {
// Creates an event loop for android platforms only.
let event_loop = EventLoopBuilder::new().with_android_app(app).build();
// The rest of your code here...
// 99% of the time, this is the place for the content of the
// main function in main.rs, excluding the event_loop definition
}
main.rs
:use trs_24::overture::*;
pub fn main() {
// Creates an event loop for non-android platforms only.
let event_loop = EventLoopBuilder::new().build();
// The rest of your code here...
}
ℹ️ To try and view a fully complete example, clone the repository and head to the example
directory.
Full instructions for Android and Non-Android target platforms are within the wiki page Build & Bundle.