mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Split platform module more
This commit is contained in:
parent
805ca353d5
commit
ebbf5bdff1
@ -6,7 +6,7 @@ categories = []
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
maplibre = { path = "../maplibre" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib", "cdylib"]
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
use maplibre::{MapBuilder, ScheduleMethod, TokioScheduleMethod};
|
||||
use maplibre::window::FromWindow;
|
||||
pub use std::time::Instant;
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
compile_error!("maplibre-android works only on android.");
|
||||
|
||||
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
|
||||
pub fn main() {
|
||||
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
||||
|
||||
MapBuilder::from_window("A fantastic window!")
|
||||
.with_schedule_method(ScheduleMethod::Tokio(TokioScheduleMethod::new()))
|
||||
.build()
|
||||
.run_sync();
|
||||
}
|
||||
@ -6,7 +6,7 @@ categories = []
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
maplibre = { path = "../maplibre" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
use maplibre::{MapBuilder, ScheduleMethod, TokioScheduleMethod};
|
||||
use maplibre::window::FromWindow;
|
||||
pub use std::time::Instant;
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
compile_error!("maplibre-apple works only on macOS and iOS.");
|
||||
|
||||
#[no_mangle]
|
||||
pub fn maplibre_apple_main() {
|
||||
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
||||
|
||||
MapBuilder::from_window("A fantastic window!")
|
||||
.with_schedule_method(ScheduleMethod::Tokio(TokioScheduleMethod::new()))
|
||||
.build()
|
||||
.run_sync();
|
||||
}
|
||||
@ -86,4 +86,3 @@ criterion = "0.3"
|
||||
|
||||
[build-dependencies]
|
||||
maplibre-build-tools = { path = "../maplibre-build-tools" }
|
||||
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
use crate::io::scheduler::ScheduleMethod;
|
||||
use crate::platform::schedule_method::TokioScheduleMethod;
|
||||
use crate::window::FromWindow;
|
||||
use crate::MapBuilder;
|
||||
pub use std::time::Instant;
|
||||
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
|
||||
|
||||
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
|
||||
pub fn main() {
|
||||
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
||||
|
||||
MapBuilder::from_window("A fantastic window!")
|
||||
.with_schedule_method(ScheduleMethod::Tokio(TokioScheduleMethod::new()))
|
||||
.build()
|
||||
.run_sync();
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
use crate::io::scheduler::ScheduleMethod;
|
||||
use crate::platform::schedule_method::TokioScheduleMethod;
|
||||
use crate::window::FromWindow;
|
||||
use crate::MapBuilder;
|
||||
pub use std::time::Instant;
|
||||
|
||||
// macOS and iOS (Metal)
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||
|
||||
#[no_mangle]
|
||||
pub fn maplibre_apple_main() {
|
||||
env_logger::init_from_env(env_logger::Env::default().default_filter_or("info"));
|
||||
|
||||
MapBuilder::from_window("A fantastic window!")
|
||||
.with_schedule_method(ScheduleMethod::Tokio(TokioScheduleMethod::new()))
|
||||
.build()
|
||||
.run_sync();
|
||||
}
|
||||
@ -1,23 +1,27 @@
|
||||
//! This module handles platform specific code. Depending on the compilation target different
|
||||
//! parts of this module are used
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
// WebGPU
|
||||
#[cfg(all(target_arch = "wasm32", not(feature = "web-webgl")))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8Unorm;
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
mod apple;
|
||||
// WebGL
|
||||
#[cfg(all(target_arch = "wasm32", feature = "web-webgl"))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
||||
|
||||
// Vulkan Android
|
||||
#[cfg(target_os = "android")]
|
||||
mod android;
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod noweb;
|
||||
// macOS and iOS (Metal)
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||
|
||||
/// For Vulkan/OpenGL
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
any(target_os = "macos", target_os = "ios"),
|
||||
target_arch = "wasm32"
|
||||
)))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||
@ -37,3 +41,9 @@ pub use noweb::*;
|
||||
// FIXME: This limit is enforced by WebGL. Actually this makes sense!
|
||||
// FIXME: This can also be achieved by _pad attributes in shader_ffi.rs
|
||||
pub const MIN_BUFFER_SIZE: u64 = 32;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod noweb;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
|
||||
@ -20,14 +20,6 @@ pub mod legacy_webworker_fetcher;
|
||||
mod pool;
|
||||
pub mod schedule_method;
|
||||
|
||||
// WebGPU
|
||||
#[cfg(not(feature = "web-webgl"))]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8Unorm;
|
||||
|
||||
// WebGL
|
||||
#[cfg(feature = "web-webgl")]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
||||
|
||||
#[cfg(feature = "enable-tracing")]
|
||||
fn enable_tracing() {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
|
||||
@ -1 +1,4 @@
|
||||
pub use maplibre_core::*;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
compile_error!("maplibre-web works only on wasm32.");
|
||||
Loading…
x
Reference in New Issue
Block a user