Skip to content

Commit

Permalink
Some automated replacements
Browse files Browse the repository at this point in the history
Result of running:

for NAME in event_loop dpi platform window; do find book src benches examples tests -type f -exec sed -i "s/glutin::$NAME/winit::$NAME/" {} \; ; done
  • Loading branch information
est31 authored and Melchizedek6809 committed May 4, 2023
1 parent c431f6d commit dfd7e7c
Show file tree
Hide file tree
Showing 41 changed files with 133 additions and 133 deletions.
16 changes: 8 additions & 8 deletions book/tuto-01-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Initializing an OpenGL window with glutin can be done using the following steps:
fn main() {
use glium::glutin;

let mut event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let mut event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();
}
Expand All @@ -61,11 +61,11 @@ But there is a problem: as soon as the window has been created, our main functio
event_loop.run(move |ev, _, control_flow| {
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);
*control_flow = winit::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;
*control_flow = winit::event_loop::ControlFlow::Exit;
return;
},
_ => return,
Expand Down Expand Up @@ -120,8 +120,8 @@ extern crate glium;
fn main() {
use glium::{glutin, Surface};

let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand All @@ -134,11 +134,11 @@ fn main() {
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);
*control_flow = winit::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;
*control_flow = winit::event_loop::ControlFlow::Exit;
return;
},
_ => return,
Expand Down
8 changes: 4 additions & 4 deletions book/tuto-03-animated-triangle.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ event_loop.run(move |event, _, control_flow| {
match event {
glutin::event::Event::WindowEvent { event, .. } => match event {
glutin::event::WindowEvent::CloseRequested => {
*control_flow = glutin::event_loop::ControlFlow::Exit;
*control_flow = winit::event_loop::ControlFlow::Exit;
return;
},
_ => return,
Expand All @@ -28,7 +28,7 @@ event_loop.run(move |event, _, control_flow| {

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);
*control_flow = winit::event_loop::ControlFlow::WaitUntil(next_frame_time);

// we update `t`
t += 0.0002;
Expand Down Expand Up @@ -78,7 +78,7 @@ event_loop.run(move |event, _, control_flow| {
match event {
glutin::event::Event::WindowEvent { event, .. } => match event {
glutin::event::WindowEvent::CloseRequested => {
*control_flow = glutin::event_loop::ControlFlow::Exit;
*control_flow = winit::event_loop::ControlFlow::Exit;
return;
},
_ => return,
Expand All @@ -93,7 +93,7 @@ event_loop.run(move |event, _, control_flow| {

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);
*control_flow = winit::event_loop::ControlFlow::WaitUntil(next_frame_time);

// we update `t`
t += 0.0002;
Expand Down
4 changes: 2 additions & 2 deletions examples/blitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod support;

fn main() {
// Building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new().with_vsync(true);
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/compute_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use glium::{texture::UnsignedTexture2d, uniform, Surface, Texture2d};

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new()
.with_vsync(true)
.with_gl(glutin::GlRequest::Latest);
Expand Down
6 changes: 3 additions & 3 deletions examples/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ struct Data {
fn main() {
use cgmath::SquareMatrix;

let event_loop = glutin::event_loop::EventLoop::new();
let size: glutin::dpi::LogicalSize<u32> = (800, 500).into();
let wb = glutin::window::WindowBuilder::new()
let event_loop = winit::event_loop::EventLoop::new();
let size: winit::dpi::LogicalSize<u32> = (800, 500).into();
let wb = winit::window::WindowBuilder::new()
.with_inner_size(size)
.with_title("Glium Deferred Example");
let cb = glutin::ContextBuilder::new();
Expand Down
4 changes: 2 additions & 2 deletions examples/displacement_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod support;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
6 changes: 3 additions & 3 deletions examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use glium::Surface;
use glium::index::PrimitiveType;
#[allow(unused_imports)]
use glium::glutin::event::{self, ElementState, VirtualKeyCode, Event, WindowEvent};
use glium::glutin::window::Fullscreen;
use glium::winit::window::Fullscreen;

mod support;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/fxaa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ fn main() {
You can use the space bar to switch fxaa on and off.");

// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new()
.with_depth_buffer(24)
.with_vsync(true);
Expand Down
4 changes: 2 additions & 2 deletions examples/gpgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ extern crate glium;

#[allow(unused_imports)]
use glium::glutin;
use crate::glutin::dpi::PhysicalSize;
use crate::winit::dpi::PhysicalSize;

fn main() {
let event_loop = glium::glutin::event_loop::EventLoop::new();
let event_loop = glium::winit::event_loop::EventLoop::new();
let cb = glutin::ContextBuilder::new();
let size = PhysicalSize {
width: 800,
Expand Down
4 changes: 2 additions & 2 deletions examples/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ mod support;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new().with_vsync(true);
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ fn main() {
use glium::{glutin, Api, Profile, Version};

// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new().with_visible(false);
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new().with_visible(false);
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn main() {
teapot at each frame.");

// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new().with_depth_buffer(24);
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
10 changes: 5 additions & 5 deletions examples/manual-creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use std::os::raw::c_void;
fn main() {
// building the glutin window
// note that it's just `build` and not `build_glium`
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let gl_window = cb.build_windowed(wb, &event_loop).unwrap();
let gl_window = unsafe {
Expand Down Expand Up @@ -105,10 +105,10 @@ fn main() {
event_loop.run(|event, _, control_flow| {
*control_flow = match event {
glutin::event::Event::WindowEvent { event, .. } => match event {
glutin::event::WindowEvent::CloseRequested => glutin::event_loop::ControlFlow::Exit,
_ => glutin::event_loop::ControlFlow::Poll,
glutin::event::WindowEvent::CloseRequested => winit::event_loop::ControlFlow::Exit,
_ => winit::event_loop::ControlFlow::Poll,
},
_ => glutin::event_loop::ControlFlow::Poll,
_ => winit::event_loop::ControlFlow::Poll,
}
});
}
2 changes: 1 addition & 1 deletion examples/multiple_windows.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use glium::glutin::{window::WindowBuilder, ContextBuilder};
use glium::glutin::event_loop::{EventLoop, ControlFlow};
use glium::winit::event_loop::{EventLoop, ControlFlow};
use glium::glutin::event::{Event, WindowEvent, ElementState, MouseButton};
use glium::{Display, Surface};

Expand Down
4 changes: 2 additions & 2 deletions examples/picking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ implement_vertex!(PerInstance, id, w_position, color);

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new().with_depth_buffer(24);
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
8 changes: 4 additions & 4 deletions examples/screenshot-asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ mod screenshot {

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new().with_title("Press S to take screenshot");
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new().with_title("Press S to take screenshot");
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down Expand Up @@ -244,12 +244,12 @@ fn main() {

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);
*control_flow = winit::event_loop::ControlFlow::WaitUntil(next_frame_time);

match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => {
*control_flow = glutin::event_loop::ControlFlow::Exit;
*control_flow = winit::event_loop::ControlFlow::Exit;
return;
},
WindowEvent::KeyboardInput { input, .. } => {
Expand Down
4 changes: 2 additions & 2 deletions examples/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use glium::index::PrimitiveType;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new().with_visible(true);
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new().with_visible(true);
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
10 changes: 5 additions & 5 deletions examples/shadow_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cgmath::SquareMatrix;
#[allow(unused_imports)]
use glium::{glutin, Surface};
use std::time::Instant;
use crate::glutin::dpi::LogicalSize;
use crate::winit::dpi::LogicalSize;

fn main() {
let win_size = LogicalSize {
Expand All @@ -15,8 +15,8 @@ fn main() {
let shadow_map_size = 1024;

// Create the main window
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new()
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new()
.with_inner_size(win_size)
.with_title("Shadow Mapping");
let cb = glutin::ContextBuilder::new().with_vsync(true);
Expand Down Expand Up @@ -163,13 +163,13 @@ fn main() {

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);
*control_flow = winit::event_loop::ControlFlow::WaitUntil(next_frame_time);

// Handle events
match event {
glutin::event::Event::WindowEvent { event, .. } => match event {
glutin::event::WindowEvent::CloseRequested => {
*control_flow = glutin::event_loop::ControlFlow::Exit;
*control_flow = winit::event_loop::ControlFlow::Exit;
return;
},
glutin::event::WindowEvent::KeyboardInput { input, .. } => if input.state == glutin::event::ElementState::Pressed {
Expand Down
4 changes: 2 additions & 2 deletions examples/spirv/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use glium::program::{ProgramCreationInput, SpirvProgram, SpirvEntryPoint};

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new().with_visible(true);
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new().with_visible(true);
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/sprites-batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fn main() {
const SPRITES_COUNT: usize = 1024;
println!("Number of sprites: {}", SPRITES_COUNT);

let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/subroutines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use glium::program::ShaderStage;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::time::{Duration, Instant};
use glium::{self, Display};
use glium::vertex::VertexBufferAny;
use glium::glutin::event_loop::{EventLoop, ControlFlow};
use glium::winit::event_loop::{EventLoop, ControlFlow};
use glium::glutin::event::{Event, StartCause};

pub mod camera;
Expand Down
4 changes: 2 additions & 2 deletions examples/teapot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ mod support;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new().with_depth_buffer(24);
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions examples/tessellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod support;

fn main() {
// building the display, ie. the main object
let event_loop = glutin::event_loop::EventLoop::new();
let wb = glutin::window::WindowBuilder::new();
let event_loop = winit::event_loop::EventLoop::new();
let wb = winit::window::WindowBuilder::new();
let cb = glutin::ContextBuilder::new();
let display = glium::Display::new(wb, cb, &event_loop).unwrap();

Expand Down
Loading

0 comments on commit dfd7e7c

Please sign in to comment.