Closed kalexmills closed 4 years ago
BuildFromWindowSettings hardcodes srgb to true, but the upstream API settings in Piston has an srgb flag.
BuildFromWindowSettings
srgb
Running from within WSL, I can get the following glium code to render properly through a local X Server.
Some slightly modified code from this library fails to render for me in part because of these lines.
I'd like to open a PR to resolve this.
BuildFromWindowSettings
hardcodessrgb
to true, but the upstream API settings in Piston has ansrgb
flag.Running from within WSL, I can get the following glium code to render properly through a local X Server.
example glium code
``` #[macro_use] extern crate glium; fn main() { use glium::{glutin, Surface}; use glutin::*; let mut event_loop = glutin::event_loop::EventLoop::new(); let wb = glutin::window::WindowBuilder::new(); let cb = glutin::ContextBuilder::new() .with_gl(GlRequest::Specific(Api::OpenGl, (3,2))) .with_srgb(false) // breaks if true .with_vsync(true); // breaks if false let display = glium::Display::new(wb, cb, &event_loop).unwrap(); event_loop.run(move |ev, _, control_flow| { let mut target = display.draw(); target.clear_color(0.0, 0.0, 1.0, 1.0); target.finish().unwrap(); let next_frame_time = std::time::Instant::now() + std::time::Duration::from_nanos(16_666_667); *control_flow = glutin::event_loop::ControlFlow::WaitUntil(next_frame_time); match ev { glutin::event::Event::WindowEvent { event, .. } => match event { glutin::event::WindowEvent::CloseRequested => { *control_flow = glutin::event_loop::ControlFlow::Exit; return; }, _ => return, }, _ => (), } }); } ```Some slightly modified code from this library fails to render for me in part because of these lines.
example glium_graphics code
``` extern crate glium_graphics; extern crate graphics; extern crate piston; use glium_graphics::{Flip, Glium2d, GliumWindow, OpenGL, Texture, TextureSettings}; use piston::event_loop::EventLoop; use piston::input::RenderEvent; use piston::window::WindowSettings; fn main() { let opengl = OpenGL::V3_2; let (w, h) = (300, 300); let ref mut window: GliumWindow = WindowSettings::new("glium_graphics: image_test", [w, h]) .exit_on_esc(true) .graphics_api(opengl) .srgb(false) .vsync(true) .build() .unwrap(); let mut g2d = Glium2d::new(opengl, window); window.set_lazy(true); while let Some(e) = window.next() { use graphics::*; if let Some(args) = e.render_args() { let mut target = window.draw(); g2d.draw(&mut target, args.viewport(), |c, g| { clear(color::WHITE, g); rectangle( [1.0, 0.0, 0.0, 1.0], [0.0, 0.0, 100.0, 100.0], c.transform, g, ); rectangle( [0.0, 1.0, 0.0, 0.3], [50.0, 50.0, 100.0, 100.0], c.transform, g, ); }); target.finish().unwrap(); } } } ```I'd like to open a PR to resolve this.