gl: make framecount usize

This commit is contained in:
chyyran 2022-11-20 00:05:50 -05:00
parent 5ed6cc6e52
commit eb582e396e
4 changed files with 13 additions and 21 deletions

View file

@ -139,7 +139,7 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
Value::FrameCountMod(_, value) => Some(*value),
_ => None,
})
.unwrap_or(0),
.unwrap_or(1),
srgb_framebuffer: shader_values
.iter()
.find_map(|f| match f {

View file

@ -487,7 +487,7 @@ impl FilterChain {
})
}
pub fn frame(&mut self, count: u32, vp: &Viewport, input: GlImage, _clear: bool) {
pub fn frame(&mut self, count: usize, vp: &Viewport, input: GlImage, _clear: bool) {
if self.passes.is_empty() {
return;
}
@ -540,7 +540,7 @@ impl FilterChain {
let target = &self.common.outputs[index];
pass.draw(
&self.common,
count,
(count % pass.config.frame_count_mod as usize) as u32,
1,
vp,
&original,
@ -560,7 +560,7 @@ impl FilterChain {
source.mip_filter = pass.config.filter;
pass.draw(
&self.common,
count,
(count % pass.config.frame_count_mod as usize) as u32,
1,
vp,
&original,

View file

@ -267,6 +267,7 @@ pub fn do_loop(
triangle_vao: GLuint,
filter: &mut FilterChain,
) {
let mut framecount = 0;
let mut rendered_framebuffer = 0;
let mut rendered_texture = 0;
let mut quad_vbuf = 0;
@ -478,8 +479,6 @@ void main()
unsafe {
// render to fb
gl::BindFramebuffer(gl::FRAMEBUFFER, rendered_framebuffer);
// gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::Viewport(0, 0, WIDTH as GLsizei, HEIGHT as GLsizei);
// clear color
@ -501,17 +500,9 @@ void main()
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
}
// eprintln!("[core] rendered texture is {rendered_texture}");
// do offscreen passes
// unsafe {
// gl::ActiveTexture(gl::TEXTURE0);
// gl::BindTexture(gl::TEXTURE_2D, rendered_texture);
// }
unsafe {
filter.frame(
0,
framecount,
&Viewport {
x: 0,
y: 0,
@ -533,10 +524,7 @@ void main()
unsafe {
// texture is done now.
// todo: insert postprocessing stuff to rendered_texture
// map quad to screen
// draw quad to screen
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
gl::UseProgram(quad_programid);
@ -544,10 +532,11 @@ void main()
gl::BindTexture(gl::TEXTURE_2D, output_texture);
gl::BindVertexArray(quad_vao);
gl::DrawArrays(gl::TRIANGLE_STRIP, 0, 4);
}
framecount += 1;
window.swap_buffers();
}
}

View file

@ -2,7 +2,10 @@ use crate::framebuffer::Framebuffer;
use crate::util::Viewport;
static DEFAULT_MVP: &[f32] = &[
2f32, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, -1.0, -1.0, 0.0, 1.0,
2f32, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
-1.0, -1.0, 0.0, 1.0,
];
#[derive(Debug, Copy, Clone)]