Skip to content

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

Merged
iceiix merged 3 commits intomasterfrom
glow_multi
Jan 18, 2021
Merged

gl: fix disembodied player model found in #141#484
iceiix merged 3 commits intomasterfrom
glow_multi

Conversation

@iceiix
Copy link
Copy Markdown
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
Copy Markdown
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