webgl-examples | Code examples that accompany the MDN WebGL documentation | Learning library

 by   mdn JavaScript Version: Current License: CC0-1.0

kandi X-RAY | webgl-examples Summary

kandi X-RAY | webgl-examples Summary

webgl-examples is a JavaScript library typically used in Tutorial, Learning, WebGL applications. webgl-examples has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

This repository is hope to examples for the MDN Web Docs content about the WebGL API, which is used for 2D and 3D graphics on the web. Specifically, each of these examples pairs with an article in the MDN WebGL tutorial.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              webgl-examples has a medium active ecosystem.
              It has 1181 star(s) with 1039 fork(s). There are 58 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              webgl-examples has no issues reported. On average issues are closed in 54 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of webgl-examples is current.

            kandi-Quality Quality

              webgl-examples has 0 bugs and 0 code smells.

            kandi-Security Security

              webgl-examples has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              webgl-examples code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              webgl-examples is licensed under the CC0-1.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              webgl-examples releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi has reviewed webgl-examples and discovered the below as its top functions. This is intended to give you an instant insight into webgl-examples implemented functionality, and help decide if they suit your requirements.
            • Draws the scene .
            • Main program .
            • Load a texture
            • Initializes rectangle buffers .
            • Create a video .
            • create texture
            • Load a shader
            • Initialize a shader program
            • Render the scene
            • Updates a texture
            Get all kandi verified functions for this library.

            webgl-examples Key Features

            No Key Features are available at this moment for webgl-examples.

            webgl-examples Examples and Code Snippets

            No Code Snippets are available at this moment for webgl-examples.

            Community Discussions

            QUESTION

            How do I apply a 2d shader to a webgl canvas in js?
            Asked 2022-Mar-24 at 14:13

            I hope I'm not taking the wrong approach here but I feel like I'm on the right track and this shouldn't be too complicated. I want to take a simple function of x and y on the screen and return a color applied to each pixel of a webGL canvas.

            For example: f(x,y) -> rgb(x/canvasWidth,y/canvasHeight) where x and y are positions on the canvas and color is that of the pixel.

            My first thought is to take this example and modify it so that the rectangle fills the screen and the color is as described. I think this is achieved by modifying the vertex shader so that the rectangle covers the canvas and fragment shader to implement the color but I'm not sure how to apply the vertex shader based on window size or get my x and y variables in the context of the fragment shader.

            Here's the shader code for the tutorial I'm going off of. I Haven't tried much besides manually changing the constant color in the fragment shader and mutating the square by changing the values in the intitBuffers method.

            ...

            ANSWER

            Answered 2022-Mar-17 at 10:15

            You're on the right track, for having a quad fill the screen you can skip all the matrix transforms in the vertex shader and just feed normalized device coordinates (-1 ... +1) directly into gl_Position then use gl_FragCoord to access the position of the pixel in the fragment shader.

            Source https://stackoverflow.com/questions/71499942

            QUESTION

            WebGL textures from YouTube video frames
            Asked 2022-Jan-08 at 15:24

            I'm using the technique described here (code, demo) for using video frames as WebGL textures, and the simple scene (just showing the image in 2D, rather than a 3D rotating cube) from here.

            The goal is a Tampermonkey userscript (with WebGL shaders, i.e. video effects) for YouTube.

            The canvas is filled grey due to gl.clearColor(0.5,0.5,0.5,1). But the next lines of code, which should draw the frame from the video, have no visible effect. What part might be wrong? There are no errors.

            I tried to shorten the code before posting, but apparently even simple WebGL scenes require a lot of boilerplate code.

            ...

            ANSWER

            Answered 2022-Jan-08 at 15:24

            Edit: As it has been pointed out, first two sections of this answer are completely wrong.

            TLDR: This might not be feasible without a backend server first fetching the video data.

            If you check the MDN tutorial you followed, the video object passed to texImage2D is actually an MP4 video. However, in your script, the video object you have access to (document.getElementsByTagName("video")[0]) is just a DOM object. You don't have the actual video data. And it is not easy to get access to that for YouTube. The YouTube player do not fetch the video data in one shot, rather the YouTube streaming server makes sure to stream chunks of the video. I am not absolutely sure on this, but I think it'll be very difficult to work around this if your goal is to have a real time video effects. I found some discussion on this (link1, link2) which might help.

            That being said, there are some issues in your code from WebGL perspective. Ideally the code you have should be showing a blue rectangle as that is the texture data you are creating, instead of the initial glClearColor color. And after the video starts to play, it should switch to the video texture (which will show as black due to the issue I have explained above).

            I think it is due to the way you had setup your position data and doing clip space calculation in the shader. That can be skipped to directly send normalized device coordinate position data. Here is the updated code, with some cleaning up to make it shorter, which behaves as expected:

            Source https://stackoverflow.com/questions/70627240

            QUESTION

            Canvas added to YouTube is not visible
            Asked 2022-Jan-06 at 02:35

            I'm following the WebGL tutorial from MDN (code, demo (black rectangle)) to create a WebGL canvas.

            The goal is a userscript (with WebGL shaders, i.e. video effects) for YouTube. So I opened a YouTube video page and put the code below (from the link above) into the JavaScript console. The canvas got created, but it is invisible.

            The canvas inherits a lot of CSS from YouTube by default. Am I overlooking some CSS properties that make it invisible? What to look out for in such cases? It should be black.

            ...

            ANSWER

            Answered 2022-Jan-04 at 02:19

            Your canvas is there, but it's not on-top. Set some additional CSS for positioning. For example:

            Source https://stackoverflow.com/questions/70573336

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install webgl-examples

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/mdn/webgl-examples.git

          • CLI

            gh repo clone mdn/webgl-examples

          • sshUrl

            git@github.com:mdn/webgl-examples.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link