Skip to content
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

Shrink unsafe block #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/gl/src/buffer/framebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ impl Drop for FrameBuffer {

impl Buffer for FrameBuffer {
fn bind_to(&self, gl: &Gl) {
// First make sure our associated render buffer is bound to RENDERBUFFER.
self.render_buffer.bind_to(&self.gl);
unsafe {
// First make sure our associated render buffer is bound to RENDERBUFFER.
self.render_buffer.bind_to(&self.gl);

// Now bind ourselves.
gl.BindFramebuffer(FRAMEBUFFER, self.id);
Expand Down
4 changes: 2 additions & 2 deletions components/gl/src/buffer/vbo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ impl VertexBufferObject {

/// Stores new vertex data, overwriting any that might already exist in this VBO.
pub fn store_vertex_data(&mut self, data: &[f32]) {
self.bind_to(&self.gl);
unsafe {
self.bind_to(&self.gl);
self.gl.BufferData(
ARRAY_BUFFER, // target
(data.len() * std::mem::size_of::<f32>()) as GLsizeiptr, // size of data in bytes
data.as_ptr() as *const GLvoid, // pointer to data
STATIC_DRAW, // usage
);
unbind_array_buffer_globally(&self.gl);
}
unbind_array_buffer_globally(&self.gl);
}
}

Expand Down
7 changes: 3 additions & 4 deletions components/gl/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ pub fn bool_from_glint(glint: GLint) -> bool {
}

pub fn opengl_version(gl: &Gl) -> String {
unsafe {
let data = CStr::from_ptr(gl.GetString(VERSION) as *const _)

let data = unsafe { CStr::from_ptr(gl.GetString(VERSION) as *const _)
.to_bytes()
.to_vec();
.to_vec() };
String::from_utf8(data).unwrap()
}
}

pub(crate) fn create_whitespace_cstring(len: usize) -> CString {
Expand Down