summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-12-03 20:59:53 +0100
committerHampusM <hampus@hampusmat.com>2023-12-03 21:00:06 +0100
commitd7e22f3586801c25a00874e4ec422e79ff9123b6 (patch)
tree5fbf6e8bf8e52574041a8a883543a690a44d2549
parent6e452b58c2a8655a451edf137f376fe7dea5cb1c (diff)
chore(glfw): add OpenGL crate feature
-rw-r--r--glfw/Cargo.toml3
-rw-r--r--glfw/src/window.rs6
2 files changed, 7 insertions, 2 deletions
diff --git a/glfw/Cargo.toml b/glfw/Cargo.toml
index 71d4913..110ed96 100644
--- a/glfw/Cargo.toml
+++ b/glfw/Cargo.toml
@@ -3,6 +3,9 @@ name = "glfw"
version = "0.1.0"
edition = "2021"
+[features]
+opengl = []
+
[dependencies]
libc = "0.2.148"
thiserror = "1.0.49"
diff --git a/glfw/src/window.rs b/glfw/src/window.rs
index 3926cce..4c7652c 100644
--- a/glfw/src/window.rs
+++ b/glfw/src/window.rs
@@ -1,5 +1,5 @@
use std::cell::RefCell;
-use std::ffi::{c_int, CStr, CString};
+use std::ffi::{c_int, CString};
use std::hint::unreachable_unchecked;
use std::panic::catch_unwind;
use std::ptr::null_mut;
@@ -21,6 +21,7 @@ impl Window
/// # Errors
/// Will return `Err` if a GLFW platform error occurs or if no OpenGL context is
/// present.
+ #[cfg(feature = "opengl")]
pub fn make_context_current(&self) -> Result<(), Error>
{
unsafe { crate::ffi::glfwMakeContextCurrent(self.handle) };
@@ -36,9 +37,10 @@ impl Window
/// # Errors
/// Will return `Err` if a GLFW platform error occurs or if no current context has
/// been set.
+ #[cfg(feature = "opengl")]
pub fn get_proc_address(
&self,
- proc_name: &CStr,
+ proc_name: &std::ffi::CStr,
) -> Result<unsafe extern "C" fn(), Error>
{
let proc_addr = unsafe { crate::ffi::glfwGetProcAddress(proc_name.as_ptr()) };