summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/lib.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs
index d848112..ec969f8 100644
--- a/engine/src/lib.rs
+++ b/engine/src/lib.rs
@@ -154,6 +154,20 @@ impl Engine
.map_err(Error::GetKeyStateFailed)
}
+ /// Returns the cursor position.
+ ///
+ /// # Errors
+ /// Will return `Err` if unable to get the cursor position from GLFW.
+ pub fn get_cursor_pos(&self) -> Result<Vec2<f64>, Error>
+ {
+ let pos = self
+ .window
+ .get_cursor_position()
+ .map_err(Error::GetCursorPosFailed)?;
+
+ Ok(Vec2 { x: pos.x, y: pos.y })
+ }
+
fn update_delta_time(&mut self, prev_frame_start: &mut Option<Instant>)
{
let frame_start_time = Instant::now();
@@ -187,4 +201,7 @@ pub enum Error
#[error("Failed to get key state")]
GetKeyStateFailed(#[source] glfw::Error),
+
+ #[error("Failed to get cursor position")]
+ GetCursorPosFailed(#[source] glfw::Error),
}