Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renderbuffer #442

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
55ac2fd
Wrap some renderbuffer GL methods
iceiix Dec 24, 2020
08e5c8d
gl: Add RenderbufferStorageMultisample wrapper storage_multisample
iceiix Dec 24, 2020
5b972cb
Attempt to disable multisampling (glTexImage2D instead of glTexImage2…
iceiix Dec 25, 2020
0647017
cargo fmt
iceiix Dec 25, 2020
f34d681
Merge branch 'master' into renderbuffer
iceiix Dec 25, 2020
03f7a4f
Update to use renderbuffers in glow
iceiix Dec 25, 2020
7342c28
Revert "Attempt to disable multisampling (glTexImage2D instead of glT…
iceiix Dec 25, 2020
7ec4feb
cargo fmt
iceiix Dec 25, 2020
0953cc2
Merge branch 'master' into renderbuffer
iceiix Dec 27, 2020
b908e86
Try disabling multisampling again
iceiix Dec 27, 2020
93e0c2d
Enable debug-assertions in dev
iceiix Dec 27, 2020
f12f10c
Try fb_depth same image_2d_ex parameters as trans_depth
iceiix Dec 27, 2020
1b400d1
fb_depth use DEPTH_COMPONENT for both format/internalformat
iceiix Dec 27, 2020
19231f0
Use local copy of glow modified with [features] debug_trace_calls, de…
iceiix Dec 27, 2020
bda3c99
Revert "Use local copy of glow modified with [features] debug_trace_c…
iceiix Dec 27, 2020
b15129f
render: fix missing TEXTURE_2D{_MULTISAMPLE} in draw()
iceiix Dec 27, 2020
7826c2a
gl: use glow::Renderbuffer
iceiix Dec 27, 2020
6071a21
Update to glow release, remove image_2d_sample()
iceiix Dec 27, 2020
1b7c375
Merge branch 'master' into renderbuffer
iceiix Dec 27, 2020
f0d7224
Merge branch 'master' into renderbuffer
iceiix Dec 27, 2020
d0cd81f
gl: add glRenderbufferStorage wrapper (non-multisample)
iceiix Dec 27, 2020
15fc418
Change fb_color to a Renderbuffer (was a Texture)
iceiix Dec 27, 2020
1733174
fb_depth a Renderbuffer, too
iceiix Dec 27, 2020
1d967d0
Revert fb_color to a texture so the fragment shader can access it (tc…
iceiix Dec 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ path = "src/main.rs"
# However, building with full -O3 optimizations takes too long for a debug build.
# Use an -O1 optimization level strikes a good compromise between build and program performance.
opt-level = 1
debug-assertions = true

[dependencies]
cfg-if = "1.0.0"
Expand Down
55 changes: 55 additions & 0 deletions src/gl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,61 @@ impl Framebuffer {
);
}
}

pub fn renderbuffer(&self, attachment: Attachment, rb: &Renderbuffer) {
unsafe {
glow_context().framebuffer_renderbuffer(
gl::FRAMEBUFFER,
attachment,
gl::RENDERBUFFER,
Some(rb.0),
);
}
}
}

#[derive(Default)]
pub struct Renderbuffer(glow::Renderbuffer);

impl Renderbuffer {
pub fn new() -> Renderbuffer {
Renderbuffer(unsafe { glow_context().create_renderbuffer().unwrap() })
}

pub fn bind(&self) {
unsafe {
glow_context().bind_renderbuffer(gl::RENDERBUFFER, Some(self.0));
}
}

pub fn storage(&self, width: u32, height: u32, format: TextureFormat) {
unsafe {
glow_context().renderbuffer_storage(
gl::RENDERBUFFER,
format,
width as i32,
height as i32,
);
}
}

pub fn storage_multisample(
&self,
samples: i32,
width: u32,
height: u32,
format: TextureFormat,
) {
unsafe {
glow_context().renderbuffer_storage_multisample(
gl::RENDERBUFFER,
samples,
format,
width as i32,
height as i32,
);
}
}
}

impl Drop for Framebuffer {
Expand Down
25 changes: 9 additions & 16 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ impl Renderer {
struct TransInfo {
main: gl::Framebuffer,
fb_color: gl::Texture,
_fb_depth: gl::Texture,
_fb_depth: gl::Renderbuffer,
trans: gl::Framebuffer,
accum: gl::Texture,
revealage: gl::Texture,
Expand Down Expand Up @@ -870,22 +870,15 @@ impl TransInfo {
fb_color.set_parameter(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR);

main.texture_2d(gl::COLOR_ATTACHMENT_0, gl::TEXTURE_2D, &fb_color, 0);
let fb_depth = gl::Texture::new();
fb_depth.bind(gl::TEXTURE_2D);
fb_depth.image_2d_ex(
gl::TEXTURE_2D,
0,
width,
height,
gl::DEPTH_COMPONENT24,
gl::DEPTH_COMPONENT,
gl::UNSIGNED_BYTE,
None,
);
fb_depth.set_parameter(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR);
fb_depth.set_parameter(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR);

main.texture_2d(gl::DEPTH_ATTACHMENT, gl::TEXTURE_2D, &fb_depth, 0);
let fb_depth = gl::Renderbuffer::new();
fb_depth.bind();
fb_depth.storage(width, height, gl::DEPTH_COMPONENT24);
//fb_depth.set_parameter(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR);
//fb_depth.set_parameter(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR);

//main.texture_2d(gl::DEPTH_ATTACHMENT, gl::TEXTURE_2D, &fb_depth, 0);
main.renderbuffer(gl::DEPTH_ATTACHMENT, &fb_depth);
gl::check_framebuffer_status();

gl::unbind_framebuffer();
Expand Down