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
[WIP] Implement WebGL depth texture #26052
Closed
+116
−5
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
implement webgl depth texture
- Loading branch information
commit b93af11270ee8204b01ce4e5a545763a77c4bab4
| @@ -0,0 +1,60 @@ | ||
| use super::{ | ||
| constants as webgl, ext_constants as ext, WebGLExtension, WebGLExtensionSpec, WebGLExtensions, | ||
| }; | ||
| use crate::dom::bindings::codegen::Bindings::WebGLDepthTextureBinding; | ||
| use crate::dom::webglrenderingcontext::WebGLRenderingContext; | ||
| use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; | ||
| use crate::dom::bindings::root::DomRoot; | ||
| use canvas_traits::webgl::WebGLVersion; | ||
| use sparkle::gl; | ||
| use dom_struct::dom_struct; | ||
|
|
||
| #[dom_struct] | ||
| pub struct WebGLDepthTexture { | ||
| reflector_: Reflector, | ||
| } | ||
|
|
||
| impl WebGLDepthTexture { | ||
| fn new_inherited() -> WebGLDepthTexture { | ||
| Self { | ||
| reflector_: Reflector::new(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl WebGLExtension for WebGLDepthTexture { | ||
| type Extension = WebGLDepthTexture; | ||
| fn new(ctx: &WebGLRenderingContext) -> DomRoot<WebGLDepthTexture> { | ||
| reflect_dom_object( | ||
| Box::new(WebGLDepthTexture::new_inherited()), | ||
| &*ctx.global(), | ||
| WebGLDepthTextureBinding::Wrap, | ||
| ) | ||
| } | ||
|
|
||
| fn spec() -> WebGLExtensionSpec { | ||
| WebGLExtensionSpec::Specific(WebGLVersion::WebGL1) | ||
| } | ||
|
|
||
| fn is_supported(ext: &WebGLExtensions) -> bool { | ||
| ext.supports_gl_extension("ANGLE_depth_texture") | ||
| } | ||
|
|
||
| fn enable(ext: &WebGLExtensions) { | ||
| let uint248 = gl::UNSIGNED_INT_24_8; | ||
| ext.enable_tex_type(uint248); | ||
| ext.add_effective_tex_internal_format(webgl::RGBA, uint248, ext::RGBA32F); | ||
| ext.add_effective_tex_internal_format(webgl::RGB, uint248, ext::RGB32F); | ||
| ext.add_effective_tex_internal_format(webgl::LUMINANCE, uint248, ext::LUMINANCE32F_ARB); | ||
| ext.add_effective_tex_internal_format(webgl::ALPHA, uint248, ext::ALPHA32F_ARB); | ||
| ext.add_effective_tex_internal_format( | ||
| webgl::LUMINANCE_ALPHA, | ||
| uint248, | ||
| ext::LUMINANCE_ALPHA32F_ARB, | ||
| ); | ||
| } | ||
|
|
||
| fn name() -> &'static str { | ||
| "ANGLE_depth_texture" | ||
| } | ||
| } |
| @@ -82,7 +82,7 @@ use std::cmp; | ||
| use std::ptr::{self, NonNull}; | ||
| use std::rc::Rc; | ||
| use webxr_api::SwapChainId as WebXRSwapChainId; | ||
|
|
||
| use sparkle::gl; | ||
| // From the GLES 2.0.25 spec, page 85: | ||
| // | ||
| // "If a texture that is currently bound to one of the targets | ||
| @@ -667,6 +667,7 @@ impl WebGLRenderingContext { | ||
| Some(ref buffer) => match buffer.get_array_type() { | ||
| Type::Uint8 => 1, | ||
| Type::Uint16 => 2, | ||
| Type::Uint32 => 4, | ||
| Type::Float32 => 4, | ||
| _ => { | ||
| self.webgl_error(InvalidOperation); | ||
| @@ -4227,7 +4228,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { | ||
| handle_potential_webgl_error!(self, self.validate_ownership(texture), return); | ||
| } | ||
|
|
||
| if target != constants::FRAMEBUFFER { | ||
| if target != gl::UNSIGNED_INT_24_8 { | ||
jdm
Member
|
||
| return self.webgl_error(InvalidEnum); | ||
| } | ||
|
|
||
| @@ -0,0 +1,12 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
| /* | ||
| * WebGL IDL definitions from the Khronos specification: | ||
| * https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/ | ||
| */ | ||
|
|
||
| [NoInterfaceObject, Exposed=Window] | ||
| interface WebGLDepthTexture { | ||
| const GLenum UNSIGNED_INT_24_8_WEBGL = 0x84FA; | ||
| }; |
Binary file not shown.
Binary file not shown.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
This change does not make sense to me. What is the intention here?