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), Value::FrameCountMod(_, value) => Some(*value),
_ => None, _ => None,
}) })
.unwrap_or(0), .unwrap_or(1),
srgb_framebuffer: shader_values srgb_framebuffer: shader_values
.iter() .iter()
.find_map(|f| match f { .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() { if self.passes.is_empty() {
return; return;
} }
@ -540,7 +540,7 @@ impl FilterChain {
let target = &self.common.outputs[index]; let target = &self.common.outputs[index];
pass.draw( pass.draw(
&self.common, &self.common,
count, (count % pass.config.frame_count_mod as usize) as u32,
1, 1,
vp, vp,
&original, &original,
@ -560,7 +560,7 @@ impl FilterChain {
source.mip_filter = pass.config.filter; source.mip_filter = pass.config.filter;
pass.draw( pass.draw(
&self.common, &self.common,
count, (count % pass.config.frame_count_mod as usize) as u32,
1, 1,
vp, vp,
&original, &original,

View file

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

View file

@ -2,7 +2,10 @@ use crate::framebuffer::Framebuffer;
use crate::util::Viewport; use crate::util::Viewport;
static DEFAULT_MVP: &[f32] = &[ 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)] #[derive(Debug, Copy, Clone)]