gl: fix sampler binding
This commit is contained in:
parent
1f068bc0d5
commit
085f3a6444
|
@ -95,7 +95,7 @@ impl FilterPass {
|
|||
gl::ActiveTexture(gl::TEXTURE0 + binding.binding);
|
||||
|
||||
gl::BindTexture(gl::TEXTURE_2D, texture.image.handle);
|
||||
gl::BindSampler(gl::TEXTURE0 + binding.binding,
|
||||
gl::BindSampler(binding.binding,
|
||||
samplers.get(texture.wrap_mode, texture.filter, texture.mip_filter));
|
||||
// gl::TexParameteri(
|
||||
// gl::TEXTURE_2D,
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::framebuffer::{Framebuffer, GlImage, Viewport};
|
|||
|
||||
const WIDTH: u32 = 900;
|
||||
const HEIGHT: u32 = 700;
|
||||
const TITLE: &str = "Hello From OpenGL World!";
|
||||
const TITLE: &str = "librashader OpenGL";
|
||||
|
||||
pub fn compile_program(vertex: &str, fragment: &str) -> GLuint {
|
||||
let vertex_shader = unsafe { gl::CreateShader(gl::VERTEX_SHADER) };
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::iter::Filter;
|
||||
use gl::types::{GLenum, GLint, GLuint};
|
||||
use rustc_hash::FxHashMap;
|
||||
use librashader_common::{FilterMode, WrapMode};
|
||||
|
@ -32,6 +33,7 @@ impl SamplerSet {
|
|||
gl::TEXTURE_MAG_FILTER,
|
||||
GLenum::from(filter) as GLint,
|
||||
);
|
||||
|
||||
gl::SamplerParameteri(
|
||||
sampler,
|
||||
gl::TEXTURE_MIN_FILTER,
|
||||
|
@ -47,18 +49,24 @@ impl SamplerSet {
|
|||
for wrap_mode in wrap_modes {
|
||||
unsafe {
|
||||
let mut linear_linear = 0;
|
||||
let mut nearest_nearest = 0;
|
||||
let mut linear_nearest = 0;
|
||||
|
||||
let mut nearest_nearest = 0;
|
||||
let mut nearest_linear = 0;
|
||||
gl::GenSamplers(1, &mut linear_linear);
|
||||
gl::GenSamplers(1, &mut linear_nearest);
|
||||
gl::GenSamplers(1, &mut nearest_linear);
|
||||
gl::GenSamplers(1, &mut nearest_nearest);
|
||||
|
||||
SamplerSet::make_sampler(linear_linear, *wrap_mode, FilterMode::Linear, FilterMode::Linear);
|
||||
SamplerSet::make_sampler(linear_nearest, *wrap_mode, FilterMode::Linear, FilterMode::Linear);
|
||||
SamplerSet::make_sampler(nearest_linear, *wrap_mode, FilterMode::Nearest, FilterMode::Linear);
|
||||
SamplerSet::make_sampler(nearest_linear, *wrap_mode, FilterMode::Nearest, FilterMode::Nearest);
|
||||
SamplerSet::make_sampler(linear_linear, *wrap_mode,
|
||||
FilterMode::Linear, FilterMode::Linear);
|
||||
SamplerSet::make_sampler(linear_nearest, *wrap_mode,
|
||||
FilterMode::Linear, FilterMode::Nearest);
|
||||
SamplerSet::make_sampler(nearest_linear, *wrap_mode,
|
||||
FilterMode::Nearest, FilterMode::Linear);
|
||||
SamplerSet::make_sampler(nearest_nearest, *wrap_mode,
|
||||
FilterMode::Nearest, FilterMode::Nearest);
|
||||
|
||||
|
||||
samplers.insert((*wrap_mode, FilterMode::Linear, FilterMode::Linear), linear_linear);
|
||||
samplers.insert((*wrap_mode, FilterMode::Linear, FilterMode::Nearest), linear_nearest);
|
||||
|
|
Loading…
Reference in a new issue