diff options
author | HampusM <hampus@hampusmat.com> | 2025-10-18 17:14:46 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-10-18 17:14:46 +0200 |
commit | 178723c9627a3aebb2f83dc476abe7d23de63eac (patch) | |
tree | 7591c4a864f93d7404af85f3e6a82dd9b972d886 /glfw/src/init.rs | |
parent | 7083a19bf1029bff21a9550d40cc3260e99aac53 (diff) |
chore: remove glfw crate
Diffstat (limited to 'glfw/src/init.rs')
-rw-r--r-- | glfw/src/init.rs | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/glfw/src/init.rs b/glfw/src/init.rs deleted file mode 100644 index df5a989..0000000 --- a/glfw/src/init.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::ffi::c_int; -use std::ptr::null_mut; - -use crate::util::is_main_thread; -use crate::{get_glfw_error, Error}; - -/// GLFW 3.x.x is supported -static SUPPORTED_GLFW_VERSION_MAJOR: c_int = 3; - -/// Initializes GLFW and returns a initialization token. -/// -/// # Errors -/// Will return `Err` if -/// - The current thread is not the main thread -/// - A GLFW error occurs -pub fn initialize() -> Result<Glfw, Error> -{ - if !is_main_thread() { - return Err(Error::NotInMainThread); - } - - let mut major: c_int = 0; - - unsafe { crate::ffi::glfwGetVersion(&mut major, null_mut(), null_mut()) }; - - if major != SUPPORTED_GLFW_VERSION_MAJOR { - return Err(Error::UnsupportedVersion); - } - - // SAFETY: The current thread is the main thread - let success = unsafe { crate::ffi::glfwInit() }; - - if success == crate::ffi::GLFW_FALSE { - get_glfw_error()?; - } - - Ok(Glfw { _priv: &() }) -} - -/// GLFW initialization token. -#[derive(Debug)] -pub struct Glfw -{ - /// This field has two purposes - /// - To make the struct not constructable without calling [`initialize`]. - /// - To make the struct `!Send` and `!Sync`. - _priv: *const (), -} - -impl Drop for Glfw -{ - fn drop(&mut self) - { - // SAFETY: The current thread cannot be any other thread than the main thread - // since the initialize function checks it and the GLFW initialization token is - // neither Send or Sync - unsafe { crate::ffi::glfwTerminate() }; - } -} |