Search code examples
javascriptwebgl

WEBGL_debug_render_info extension appears in getSupportedExtensions but doesn't work


I have opened the following HTML on multiple browsers (Chrome, Opera, etc.) but in the console it always logs 'WEBGL_debug_render_info extension doesn't work' despite gl.getSupportedExtensions() showing a list where WEBGL_debug_render_info is present. Am I doing something wrong?

<!DOCTYPE html>
<html>
<body>
<script>
    
    var canvas = document.createElement('canvas');
    var gl = canvas.getContext('webgl');
    
    if (!gl) {
        console.log('WebGL not supported');
    } else {
        
        var extensions = gl.getSupportedExtensions();
        console.log('Supported extensions:', extensions);
        
        
        
        var debugInfo = gl.getExtension("WEBGL_debug_render_info");
        if (debugInfo) {
            var vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
            var renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
            console.log('Vendor: ' + vendor);
            console.log('Renderer: ' + renderer);
        } else {
            console.log('WEBGL_debug_render_info extension doesnt work');
        }
    }

  
</script>
</body>
</html>

Solution

  • The extension's name is WEBGL_debug_renderer_info, not WEBGL_debug_render_info. If you change the name in getExtension, it should work.