Fix panic! warnings in integration_opengl example

This commit is contained in:
Héctor Ramón Jiménez 2021-08-13 20:05:10 +07:00
parent 9567808636
commit f1f58b2a8a
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 8 additions and 2 deletions

View file

@ -19,18 +19,23 @@ pub fn main() {
env_logger::init(); env_logger::init();
let (gl, event_loop, windowed_context, shader_version) = { let (gl, event_loop, windowed_context, shader_version) = {
let el = glutin::event_loop::EventLoop::new(); let el = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new() let wb = glutin::window::WindowBuilder::new()
.with_title("OpenGL integration example") .with_title("OpenGL integration example")
.with_inner_size(glutin::dpi::LogicalSize::new(1024.0, 768.0)); .with_inner_size(glutin::dpi::LogicalSize::new(1024.0, 768.0));
let windowed_context = glutin::ContextBuilder::new() let windowed_context = glutin::ContextBuilder::new()
.with_vsync(true) .with_vsync(true)
.build_windowed(wb, &el) .build_windowed(wb, &el)
.unwrap(); .unwrap();
unsafe { unsafe {
let windowed_context = windowed_context.make_current().unwrap(); let windowed_context = windowed_context.make_current().unwrap();
let gl = glow::Context::from_loader_function(|s| { let gl = glow::Context::from_loader_function(|s| {
windowed_context.get_proc_address(s) as *const _ windowed_context.get_proc_address(s) as *const _
}); });
// Enable auto-conversion from/to sRGB // Enable auto-conversion from/to sRGB
gl.enable(glow::FRAMEBUFFER_SRGB); gl.enable(glow::FRAMEBUFFER_SRGB);
@ -40,6 +45,7 @@ pub fn main() {
// Disable multisampling by default // Disable multisampling by default
gl.disable(glow::MULTISAMPLE); gl.disable(glow::MULTISAMPLE);
(gl, el, windowed_context, "#version 410") (gl, el, windowed_context, "#version 410")
} }
}; };

View file

@ -52,7 +52,7 @@ impl Scene {
); );
gl.compile_shader(shader); gl.compile_shader(shader);
if !gl.get_shader_compile_status(shader) { if !gl.get_shader_compile_status(shader) {
panic!(gl.get_shader_info_log(shader)); panic!("{}", gl.get_shader_info_log(shader));
} }
gl.attach_shader(program, shader); gl.attach_shader(program, shader);
shaders.push(shader); shaders.push(shader);
@ -60,7 +60,7 @@ impl Scene {
gl.link_program(program); gl.link_program(program);
if !gl.get_program_link_status(program) { if !gl.get_program_link_status(program) {
panic!(gl.get_program_info_log(program)); panic!("{}", gl.get_program_info_log(program));
} }
for shader in shaders { for shader in shaders {