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

gl: fix disembodied player model found in #141 #484

Merged
merged 3 commits into from
Jan 18, 2021
Merged

gl: fix disembodied player model found in #141 #484

merged 3 commits into from
Jan 18, 2021

Conversation

iceiix
Copy link
Owner

@iceiix iceiix commented Jan 18, 2021

Regression introduced in #262 by the glow port, correct the raw size to
account for the matrix. See #141 (comment)

Regression introduced in #262 by the glow port, correct the raw size to
account for the matrix. See #141 (comment)
@iceiix iceiix added the bug Something isn't working label Jan 18, 2021
@iceiix
Copy link
Owner Author

iceiix commented Jan 18, 2021

Before: Screen Shot 2021-01-18 at 10 46 38 AM

After:
Screen Shot 2021-01-18 at 11 15 27 AM

This works but there were subsequent changes to src/gl/mod.rs to remove "replace set_float_multi_raw with a safer set_float_multi", in #451 for WebGL

Broken code:

    #[allow(clippy::missing_safety_doc)]
     pub unsafe fn set_float_multi_raw(&self, data: *const f32, len: usize) {
         glow_context().uniform_4_f32_slice(Some(&self.0), std::slice::from_raw_parts(data, len));
     }

working code, but using unsafe raw pointers:

// src/render/model.rs
                    unsafe {
                        v.set_float_multi_raw(model.colors.as_ptr() as *const _, model.colors.len())
                    }

// src/gl/mod.rs
    #[allow(clippy::missing_safety_doc)]
     pub unsafe fn set_float_multi_raw(&self, data: *const f32, len: usize) {
         glow_context().uniform_4_f32_slice(Some(&self.0), std::slice::from_raw_parts(data, len * 4 * 4));
     }

broken code using slices:

// src/render/model.rs
                    v.set_float_multi(&model.colors)

// src/gl/mod.rs
    pub fn set_float_multi(&self, v: &[[f32; 4]]) {
        unsafe {
            glow_context()
                .uniform_4_f32_slice(Some(&self.0), &*(v as *const [[f32; 4]] as *const [f32; 4]))
        }
    }

@iceiix iceiix merged commit 2b6103e into master Jan 18, 2021
@iceiix iceiix deleted the glow_multi branch January 18, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant