use nearest sampler

This commit is contained in:
griffi-gh 2023-01-16 16:32:34 +01:00
parent 52099c5266
commit ef9e24722a

View file

@ -1,4 +1,5 @@
use glium::{Surface, uniform}; use glium::{Surface, uniform};
use glium::uniforms::{Sampler, MinifySamplerFilter, MagnifySamplerFilter};
use glium::glutin::{ use glium::glutin::{
event::{Event, WindowEvent, DeviceEvent, KeyboardInput, VirtualKeyCode}, event::{Event, WindowEvent, DeviceEvent, KeyboardInput, VirtualKeyCode},
event_loop::{EventLoop, ControlFlow}, event_loop::{EventLoop, ControlFlow},
@ -57,6 +58,12 @@ pub fn run() {
let mut last_render = Instant::now(); let mut last_render = Instant::now();
let sampler_nearest = glium::uniforms::SamplerBehavior {
minify_filter: MinifySamplerFilter::Nearest,
magnify_filter: MagnifySamplerFilter::Nearest,
..Default::default()
};
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Poll; *control_flow = ControlFlow::Poll;
match event { match event {
@ -100,6 +107,7 @@ pub fn run() {
let perspective = state.camera.perspective_matrix(target_dimensions); let perspective = state.camera.perspective_matrix(target_dimensions);
let view = state.camera.view_matrix(); let view = state.camera.view_matrix();
target.clear_color_and_depth((0.5, 0.5, 1., 1.), 1.); target.clear_color_and_depth((0.5, 0.5, 1., 1.), 1.);
target.draw( target.draw(
&vertex_buffer, &vertex_buffer,
glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList), glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList),
@ -113,7 +121,7 @@ pub fn run() {
], ],
view: view, view: view,
perspective: perspective, perspective: perspective,
tex: &assets.textures.block_atlas tex: Sampler(&assets.textures.block_atlas, sampler_nearest)
}, },
&Default::default() &Default::default()
).unwrap(); ).unwrap();