◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
7 changes: 5 additions & 2 deletions ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ pub extern "C" fn processing_init() {
#[unsafe(no_mangle)]
pub extern "C" fn processing_create_surface(
window_handle: u64,
width: u32,
height: u32,
scale_factor: f32,
) -> u64 {
error::clear_error();
error::check(|| renderer::create_surface(window_handle, width, height, scale_factor))
.unwrap_or(0)
}

/// Destroy the surface associated with the given window ID.
Expand Down
31 changes: 27 additions & 4 deletions renderer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod error;
pub mod render;

use std::{cell::RefCell, num::NonZero, sync::OnceLock};

use bevy::{
app::{App, AppExit},
Expand Down Expand Up @@ -95,6 +95,7 @@ impl HasDisplayHandle for GlfwWindow {
/// actually create the surface.
pub fn create_surface(
window_handle: u64,
width: u32,
height: u32,
scale_factor: f32,
Expand Down Expand Up @@ -132,7 +133,7 @@ pub fn create_surface(
}
};

let window = AppKitWindowHandle::new(std::ptr::NonNull::new(ns_view_ptr).unwrap());
let display = AppKitDisplayHandle::new();
(
RawWindowHandle::AppKit(window),
Expand Down Expand Up @@ -178,8 +179,30 @@ pub fn create_surface(
};

#[cfg(target_os = "linux")]
let (raw_window_handle, raw_display_handle) =
{ todo!("implement linux raw window handle conversion") };

let glfw_window = GlfwWindow {
window_handle: raw_window_handle,
Expand Down
Toggle all file notes Toggle all file annotations