Discovering the necessary WebGL browser Add-ons

I have been developing a WebGL application using ThreeJs to showcase 3D models with various effects (shaders). In order to test if the user's browser can run the app, I need to retrieve a list of supported plugins.

The Query:

My main dilemma is determining the required plugins for my application. Is there a way to automatically detect them?


Further Insights:

Let me provide an example to clarify the issue:

  1. On my MacBook Pro running Mac OSX Maverix, the application runs smoothly.
  2. However, when testing the app on my Lenovo Laptop equipped with Windows 7 and Windows 8, it fails due to the Bokeh2 Shader.

Upon examining the list of supported WebGL extensions, I noticed that some extensions were missing on the Lenovo compared to the Mac. How can I identify the necessary extensions that, if absent, would cause the WebGL app to malfunction?

Below is a comparison of the extensions available on both the Mac and Lenovo.

Extensions on my Mac:

ANGLE_instanced_arrays

WEBKIT_EXT_texture_filter_anisotropic

OES_element_index_uint

OES_standard_derivatives

OES_texture_float

OES_texture_float_linear

OES_texture_half_float

OES_texture_half_float_linear

OES_vertex_array_object

WEBKIT_WEBGL_compressed_texture_s3tc

WEBKIT_WEBGL_depth_texture

WEBGL_draw_buffers

WEBGL_lose_context

WEBGL_debug_renderer_info

Extensions on my Lenovo:

ANGLE_instanced_arrays

WEBKIT_EXT_texture_filter_anisotropic

OES_element_index_uint

OES_standard_derivatives

OES_texture_float

OES_texture_half_float

OES_texture_half_float_linear

OES_vertex_array_object

WEBKIT_WEBGL_compressed_texture_s3tc

WEBGL_lose_context

WEBGL_debug_renderer_info

Notable Absences in Lenovo:

OES_texture_float_linear

WEBKIT_WEBGL_depth_texture

WEBGL_draw_buffers

Answer №1

If you want to check for the presence of an extension, one way is to request it specifically:

var ext = gl.getExtension("OES_texture_float_linear");
if (!ext) {
  alert("extension does not exist");
}

When working with three.js, you can access the WebGLRenderingContext using:

var gl = renderer.getContext();

To determine if the extension is necessary for your case, consider avoiding the use of the bokeh2 shader if the extension is not supported.

Alternatively, the responsibility falls on the application or framework to specify the required extensions. Here are three approaches:

  1. It's best if the application documentation lists the required extensions for specific features like Bokek2 needs extensions X, Y, and Z.

  2. You can inspect the code to see which extensions are being used.

  3. Another method is to override the getExtension function, logging the requested extensions and selectively returning null for certain ones to identify the essential ones.

The recommended approach is #2, but for #3, you can implement the following:

(function() {

  var originalGetExtensionFunction = WebGLRenderingContext.prototype.getExtension;

  // Initialize with an empty array. Add requested extensions here to determine the essentials.
  var extensionToReject = [
    "OES_texture_float",
    "OES_texture_float_linear",
  ];

  WebGLRenderingContext.prototype.getExtension = function() {
    var name = arguments[0];
    console.log("app requested extension: " + name); 
    if (extensionToReject.indexOf(name) >= 0) {
      console.log("rejected extension: " + name);
      return null;
    } 
    var ext = originalGetExtensionFunction.apply(this, arguments);
    console.log("extension " + name + " " + (ext ? "found" : "not found"));
    return ext;
  };

}());

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Jasmine is having trouble scrolling the window using executeScript

I usually use the following command: browser.driver.executeScript('window.scrollTo(0,1600);'); However, this command is no longer working. No errors are showing in the console, making it difficult to troubleshoot. Interestingly, the same scri ...

The specified type does not meet the constraint as it lacks the required index signature

I'm currently working on refactoring a TypeScript project that utilizes React Hooks. While I have some knowledge of TypeScript, I am still more of a beginner than an expert. My main goal is to create reusable code for this project through the use of ...

A guide on Extracting Values from Nested Objects

Although I am not well-versed in JavaScript, I have a small project where I need to use JavaScript. I am attempting to retrieve values from an object nested within another object. However, my code is throwing errors. Below is the snippet of my code with d ...

Troubleshooting three.js exceeding 2-minute load times and crashing issues

I am currently in the process of developing a 3D game and have encountered an issue with the localhost GET request taking longer than expected. After around 15-45 seconds, the canvas turns white and I receive a warning in the console indicating that the We ...

What is the best way to extract the date and pricing information directly from an interactive graph using Python?

My attempt to gather data from a graph using web scraping with the Selenium library was unsuccessful. The graph can be found at this link. from selenium import webdriver driver = webdriver.Chrome() driver.get('https://www.mtgprice.com/sets/Ravnica_All ...

Looking to showcase a loading gif inside a popover before swapping it out with ajax-generated content

My goal is to populate a popover with content using ajax requests. Here's the setup: $('.openMessagePopover').popover({ html: true, content: function() { $threadId = $(this).data('id'); return getContent($threadId) ...

Ways to insert a line break using ajax

document.getElementById("msg").innerHTML += "<strike>b:</strike> "+ msgs[i].childNodes[1].firstChild.nodeValue; After retrieving the messages, I noticed that they are all displayed close to each other. Is there a way to display each message on ...

Build a row within an HTML table that is devoid of both an ID and a class

Creating an additional row in an HTML table is a common task, but it can become tricky when dealing with multiple forms and tables on one page. In my case, I have a form that contains only a table element, and I want to move some columns from the first row ...

When data is stored in Internet Explorer's cache, any changes made are not being reflected in

Internet Explorer stores data in cache and even if there are changes, it may not reflect onclick. However, when I open the developer mode and try to access the same, then it works perfectly. This issue only seems to occur in IE as all other browsers work f ...

Preventing click event from bubbling up the DOM: Using Vue's @click

How can I access the child elements within a parent component? <div v-on:click.stop.prevent="onClickTemplateHandler"> <div> <h3 style="">Title</h3> <p>{{ lorem }}</p> </div> ...

Is the order of query execution being altered when using the MongoClient in Node.js?

I am currently developing a registration API endpoint that utilizes MongoDB to validate two specific conditions: If the username provided already exists in the database, it will return a status of 500 If the email address provided already exists in the da ...

Tips for adjusting the color of multi-line text when hovering with the mouse

I'm facing a challenge in changing the color of text when someone hovers over it, but so far I've only been able to make it work if the mouse scrolls over the top border of the text. The text I'm testing is located in the top left corner an ...

Achieving accurate JSON output from Elasticsearch's autosuggest feature can be

Running my node.js server involves sending queries to an elasticsearch instance. I have a JSON example of the query's output: { "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 ...

How about: "Add random HTML content using jQuery each time the page is refreshed

Currently facing this issue: I implemented a jquery plugin fullPage.js by Alvaro Trigo on my website. The plugin script automatically inserts the html structure in certain elements... in my html I have: <div class="section fp-auto-height-responsive" ...

Retrieving the result of a callback function within a nested function

I'm struggling with a function that needs to return a value. The value is located inside a callback function within the downloadOrders function. The problem I'm encountering is that "go" (logged in the post request) appears before "close" (logged ...

Control the line height in DataTables

Is there a way to adjust the line height for a tr using either DataTables settings or CSS? I've attempted different methods, but nothing seems to change the line-height. https://i.sstatic.net/GwFaD.png Table CSS ...

Unusual issue encountered when launching an express application in node.js

Starting my app is easy with nodemon - just type nodemon However, I encountered an error when trying node app.js https://i.sstatic.net/rRXhZ.png I have checked my package.json and it is properly configured with: "scripts": { "start": "node ./bin/ww ...

What are some effective tactics for reducers in react and redux?

Working on a React + Redux project to create a web app that communicates with an API, similar to the example provided at https://github.com/reactjs/redux/tree/master/examples/real-world. The API I'm using returns lists of artists, albums, and tracks, ...

What causes the appearance of a nested URL like '/auth/auth/ ' when the original URL does not exist?

While following a tutorial, I encountered an issue where if the URL is not included in the routes.ts file, it redirects to a nested /auth/auth/...../login/ instead of redirecting to localhost:3000/auth/login middleware.ts import authConfig from "./au ...

Employing a function to concatenate promises

In my coding process, I have come across a situation where I need to fetch content and then save it using two separate functions. Each function performs a different task based on the type of content provided. These functions act as helper functions in my o ...