-
Notifications
You must be signed in to change notification settings - Fork 63
Release 0.4.2 #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 0.4.2 #90
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon May 02 15:39:12 BST 2022 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ fn android_main(app: AndroidApp) { | |
|
||
let mut quit = false; | ||
let mut redraw_pending = true; | ||
let mut render_state: Option<()> = Default::default(); | ||
let mut native_window: Option<ndk::native_window::NativeWindow> = None; | ||
|
||
while !quit { | ||
app.poll_events( | ||
|
@@ -37,11 +37,11 @@ fn android_main(app: AndroidApp) { | |
} | ||
} | ||
MainEvent::InitWindow { .. } => { | ||
render_state = Some(()); | ||
native_window = app.native_window(); | ||
redraw_pending = true; | ||
} | ||
MainEvent::TerminateWindow { .. } => { | ||
render_state = None; | ||
native_window = None; | ||
} | ||
MainEvent::WindowResized { .. } => { | ||
redraw_pending = true; | ||
|
@@ -65,7 +65,7 @@ fn android_main(app: AndroidApp) { | |
} | ||
|
||
if redraw_pending { | ||
if let Some(_rs) = render_state { | ||
if let Some(native_window) = &native_window { | ||
redraw_pending = false; | ||
|
||
// Handle input | ||
|
@@ -75,9 +75,32 @@ fn android_main(app: AndroidApp) { | |
}); | ||
|
||
info!("Render..."); | ||
dummy_render(native_window); | ||
} | ||
} | ||
}, | ||
); | ||
} | ||
} | ||
|
||
/// Post a NOP frame to the window | ||
/// | ||
/// Since this is a bare minimum test app we don't depend | ||
/// on any GPU graphics APIs but we do need to at least | ||
/// convince Android that we're drawing something and are | ||
/// responsive, otherwise it will stop delivering input | ||
/// events to us. | ||
fn dummy_render(native_window: &ndk::native_window::NativeWindow) { | ||
unsafe { | ||
let mut buf: ndk_sys::ANativeWindow_Buffer = std::mem::zeroed(); | ||
let mut rect: ndk_sys::ARect = std::mem::zeroed(); | ||
ndk_sys::ANativeWindow_lock( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't forget to bump these to the new API when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I just sync these examples by copying from rust-android-examples. |
||
native_window.ptr().as_ptr() as _, | ||
&mut buf as _, | ||
&mut rect as _, | ||
); | ||
// Note: we don't try and touch the buffer since that | ||
// also requires us to handle various buffer formats | ||
ndk_sys::ANativeWindow_unlockAndPost(native_window.ptr().as_ptr() as _); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon May 02 15:39:12 BST 2022 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
Uh oh!
There was an error while loading. Please reload this page.