gl: accomodate for viewport x and y
This commit is contained in:
parent
f0bc2d92af
commit
0806114e12
|
@ -4,7 +4,7 @@ use crate::framebuffer::{Framebuffer, GlImage, Viewport};
|
|||
use crate::quad_render::DrawQuad;
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::util;
|
||||
use crate::util::{gl_get_version, InlineRingBuffer, Texture};
|
||||
use crate::util::{gl_get_version, InlineRingBuffer};
|
||||
use crate::error::{FilterChainError, Result};
|
||||
|
||||
use gl::types::{GLenum, GLint, GLsizei, GLsizeiptr, GLuint};
|
||||
|
@ -23,6 +23,7 @@ use std::path::Path;
|
|||
use librashader_reflect::back::{CompilerBackend, CompileShader, FromCompilation};
|
||||
use librashader_reflect::front::shaderc::GlslangCompilation;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::Texture;
|
||||
|
||||
pub struct FilterChain {
|
||||
passes: Box<[FilterPass]>,
|
||||
|
@ -658,7 +659,7 @@ impl FilterChain {
|
|||
viewport,
|
||||
&original,
|
||||
&source,
|
||||
RenderTarget::new(target, None),
|
||||
RenderTarget::new(target, None, 0, 0),
|
||||
);
|
||||
|
||||
let target = target.as_texture(pass.config.filter, pass.config.wrap_mode);
|
||||
|
@ -683,7 +684,7 @@ impl FilterChain {
|
|||
viewport,
|
||||
&original,
|
||||
&source,
|
||||
RenderTarget::new(viewport.output, viewport.mvp),
|
||||
RenderTarget::new(viewport.output, viewport.mvp, viewport.x, viewport.y),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ use crate::filter_chain::FilterCommon;
|
|||
use crate::framebuffer::Viewport;
|
||||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::util::{InlineRingBuffer, RingBuffer, Texture};
|
||||
use crate::texture::Texture;
|
||||
use crate::util::{InlineRingBuffer, RingBuffer};
|
||||
|
||||
pub struct FilterPass {
|
||||
pub reflection: ShaderReflection,
|
||||
|
@ -97,26 +98,6 @@ impl FilterPass {
|
|||
gl::BindTexture(gl::TEXTURE_2D, texture.image.handle);
|
||||
gl::BindSampler(binding.binding,
|
||||
samplers.get(texture.wrap_mode, texture.filter, texture.mip_filter));
|
||||
// gl::TexParameteri(
|
||||
// gl::TEXTURE_2D,
|
||||
// gl::TEXTURE_MAG_FILTER,
|
||||
// GLenum::from(texture.filter) as GLint,
|
||||
// );
|
||||
// gl::TexParameteri(
|
||||
// gl::TEXTURE_2D,
|
||||
// gl::TEXTURE_MIN_FILTER,
|
||||
// texture.filter.gl_mip(texture.mip_filter) as GLint,
|
||||
// );
|
||||
// gl::TexParameteri(
|
||||
// gl::TEXTURE_2D,
|
||||
// gl::TEXTURE_WRAP_S,
|
||||
// GLenum::from(texture.wrap_mode) as GLint,
|
||||
// );
|
||||
// gl::TexParameteri(
|
||||
// gl::TEXTURE_2D,
|
||||
// gl::TEXTURE_WRAP_T,
|
||||
// GLenum::from(texture.wrap_mode) as GLint,
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,16 +171,14 @@ impl FilterPass {
|
|||
}
|
||||
}
|
||||
|
||||
// todo: final pass?
|
||||
|
||||
unsafe {
|
||||
gl::ColorMask(gl::TRUE, gl::TRUE, gl::TRUE, gl::TRUE);
|
||||
gl::ClearColor(0.0f32, 0.0f32, 0.0f32, 0.0f32);
|
||||
gl::Clear(gl::COLOR_BUFFER_BIT);
|
||||
//
|
||||
gl::Viewport(
|
||||
0,
|
||||
0,
|
||||
output.x,
|
||||
output.y,
|
||||
framebuffer.size.width as GLsizei,
|
||||
framebuffer.size.height as GLsizei,
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::util;
|
||||
use crate::util::Texture;
|
||||
use crate::texture::Texture;
|
||||
use gl::types::{GLenum, GLint, GLsizei, GLuint};
|
||||
use librashader_common::{FilterMode, ShaderFormat, Size, WrapMode};
|
||||
use librashader_presets::{Scale2D, ScaleType, Scaling};
|
||||
|
|
|
@ -19,6 +19,7 @@ pub use framebuffer::Viewport;
|
|||
|
||||
#[cfg(test)]
|
||||
mod hello_triangle;
|
||||
mod texture;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
|
@ -12,19 +12,25 @@ static DEFAULT_MVP: &[f32] = &[
|
|||
pub struct RenderTarget<'a> {
|
||||
pub mvp: &'a [f32],
|
||||
pub framebuffer: &'a Framebuffer,
|
||||
pub x: i32,
|
||||
pub y: i32
|
||||
}
|
||||
|
||||
impl<'a> RenderTarget<'a> {
|
||||
pub fn new(backbuffer: &'a Framebuffer, mvp: Option<&'a [f32]>) -> Self {
|
||||
pub fn new(backbuffer: &'a Framebuffer, mvp: Option<&'a [f32]>, x: i32, y: i32) -> Self {
|
||||
if let Some(mvp) = mvp {
|
||||
RenderTarget {
|
||||
framebuffer: backbuffer,
|
||||
x,
|
||||
mvp,
|
||||
y,
|
||||
}
|
||||
} else {
|
||||
RenderTarget {
|
||||
framebuffer: backbuffer,
|
||||
x,
|
||||
mvp: DEFAULT_MVP,
|
||||
y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +38,6 @@ impl<'a> RenderTarget<'a> {
|
|||
|
||||
impl<'a> From<&Viewport<'a>> for RenderTarget<'a> {
|
||||
fn from(value: &Viewport<'a>) -> Self {
|
||||
RenderTarget::new(value.output, value.mvp)
|
||||
RenderTarget::new(value.output, value.mvp, value.x, value.y)
|
||||
}
|
||||
}
|
||||
|
|
10
librashader-runtime-gl/src/texture.rs
Normal file
10
librashader-runtime-gl/src/texture.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use librashader_common::{FilterMode, WrapMode};
|
||||
use crate::GlImage;
|
||||
|
||||
#[derive(Default, Debug, Copy, Clone)]
|
||||
pub struct Texture {
|
||||
pub image: GlImage,
|
||||
pub filter: FilterMode,
|
||||
pub mip_filter: FilterMode,
|
||||
pub wrap_mode: WrapMode,
|
||||
}
|
|
@ -14,14 +14,6 @@ pub fn calc_miplevel(size: Size<u32>) -> u32 {
|
|||
levels
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Copy, Clone)]
|
||||
pub struct Texture {
|
||||
pub image: GlImage,
|
||||
pub filter: FilterMode,
|
||||
pub mip_filter: FilterMode,
|
||||
pub wrap_mode: WrapMode,
|
||||
}
|
||||
|
||||
pub trait RingBuffer<T> {
|
||||
fn current(&self) -> &T;
|
||||
fn current_mut(&mut self) -> &mut T;
|
||||
|
|
Loading…
Reference in a new issue