♻️ More safening
parent
09ce9ab580
commit
c6f71abbca
|
@ -317,28 +317,33 @@ fn main () {
|
|||
glezz::uniform_matrix_4fv (unis ["mvp"], &mvp_mat);
|
||||
glezz::uniform_3fv (unis ["object_space_light"], &object_space_light);
|
||||
|
||||
// This stuff actually still is unsafe because it's reading
|
||||
// right from RAM I can still access. Using a VBO here
|
||||
// might actually make it easier to make it safe.
|
||||
|
||||
unsafe {
|
||||
point_to_model (&attrs, &model);
|
||||
|
||||
gl::DrawElements (gl::TRIANGLES, (model.meshes [0].num_triangles * 3) as i32, gl::UNSIGNED_INT, &model.get_index_slice (0) [0] as *const u8 as *const c_void);
|
||||
}
|
||||
|
||||
if true {
|
||||
gl::Uniform3fv (unis ["albedo"], 1, &green as *const Vec3 as *const f32);
|
||||
if true {
|
||||
glezz::uniform_3fv (unis ["albedo"], &green);
|
||||
|
||||
unsafe {
|
||||
gl::DrawElements (gl::TRIANGLES, (model.meshes [1].num_triangles * 3) as i32, gl::UNSIGNED_INT, &model.get_index_slice (1) [0] as *const u8 as *const c_void);
|
||||
}
|
||||
}
|
||||
|
||||
let draw_sky = true;
|
||||
if draw_sky {
|
||||
//println! ("Drawing sky");
|
||||
|
||||
gl::UniformMatrix4fv (unis ["mvp"], 1, FALSE_U8, &sky_mvp_mat as *const Mat4 as *const f32);
|
||||
|
||||
gl::Uniform3fv (unis ["albedo"], 1, &white as *const Vec3 as *const f32);
|
||||
gl::Uniform3fv (unis ["min_bright"], 1, &white as *const Vec3 as *const f32);
|
||||
gl::Uniform3fv (unis ["min_albedo"], 1, &black as *const Vec3 as *const f32);
|
||||
gl::Uniform1i (unis ["texture"], 0);
|
||||
let draw_sky = true;
|
||||
if draw_sky {
|
||||
glezz::uniform_matrix_4fv (unis ["mvp"], &sky_mvp_mat);
|
||||
glezz::uniform_3fv (unis ["albedo"], &white);
|
||||
glezz::uniform_3fv (unis ["min_bright"], &white);
|
||||
glezz::uniform_3fv (unis ["min_albedo"], &black);
|
||||
glezz::uniform_1i (unis ["texture"], 0);
|
||||
|
||||
unsafe {
|
||||
point_to_model (&attrs, &sky_model);
|
||||
|
||||
gl::DrawElements (gl::TRIANGLES, (sky_model.meshes [0].num_triangles * 3) as i32, gl::UNSIGNED_INT, &sky_model.get_index_slice (0) [0] as *const u8 as *const c_void);
|
||||
|
|
|
@ -26,6 +26,12 @@ pub fn enable (constant: u32) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uniform_1i (uni: i32, x: i32) {
|
||||
unsafe {
|
||||
gl::Uniform1i (uni, x);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uniform_3fv (uni: i32, v: &Vec3) {
|
||||
unsafe {
|
||||
gl::Uniform3fv (uni, 1, v as *const Vec3 as *const f32);
|
||||
|
|
Loading…
Reference in New Issue