mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.12k stars 22.45k forks source link

Example code on WEBGL_depth_texture gives GL_INVALID_VALUE when run in WebGL 2 #30130

Open TeraV8 opened 10 months ago

TeraV8 commented 10 months ago

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_depth_texture

What specific section or headline is this issue about?

Examples

What information was incorrect, unhelpful, or incomplete?

The example code calls

gl.texImage2D( gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, 512, 512, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_SHORT, null );

which will throw a gl.INVALID_VALUE.

What did you expect to see?

The code should be modified by replacing the first gl.DEPTH_COMPONENT with gl.DEPTH_COMPONENT16.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details * Folder: `en-us/web/api/webgl_depth_texture` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_depth_texture * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/webgl_depth_texture/index.md * Last commit: https://github.com/mdn/content/commit/acfe8c9f1f4145f77653a2bc64a9744b001358dc * Document last modified: 2023-07-07T07:19:19.000Z
pepelsbey commented 10 months ago

Hey! Thank you for bringing this up :) Unfortunately, I’m not a WebGL expert. But it seems to me that this extension is specific to WebGL 1.0 and mentioned in the spec with this value:

The texImage2D entry point is extended to accept the format parameter DEPTH_COMPONENT and DEPTH_STENCIL

Do you think you may get the error because you’re using WebGL 2.0? It would also help if you could bring the full code code sample to the issue.