# Video as gl texture setup?

**URL:** <https://discourse.processing.org/t/video-as-gl-texture-setup/11427>\
**Category:** Coding Questions\
**Created:** [May 20, 2019, 3:44pm UTC](https://discourse.processing.org/t/video-as-gl-texture-setup/11427 "2019-05-20T15:44:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jedierikb](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jedierikb/32/5268_2.png) [@jedierikb](https://discourse.processing.org/u/jedierikb)\
**Post date:** [May 20, 2019, 3:44pm UTC](https://discourse.processing.org/t/video-as-gl-texture-setup/11427/1 "2019-05-20T15:44:24Z")

</div>

Trying to get a video as a gl texture:  
[https://codepen.io/jedierikb/pen/MdvqGp](https://codepen.io/jedierikb/pen/MdvqGp)

Any suggestions what steps I missed to get the video to appear as a texture?  
Much appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![jedierikb](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jedierikb/32/5268_2.png) [@jedierikb](https://discourse.processing.org/u/jedierikb)\
**Post date:** [May 21, 2019, 2:45am UTC](https://discourse.processing.org/t/video-as-gl-texture-setup/11427/2 "2019-05-21T02:45:21Z")

</div>

Got it -  
[https://codepen.io/jedierikb/pen/dEVKWL?editors=0010](https://codepen.io/jedierikb/pen/dEVKWL?editors=0010)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 21, 2019, 2:45am UTC](https://discourse.processing.org/t/video-as-gl-texture-setup/11427/3 "2019-05-21T02:45:53Z")

</div>

Thank you for sharing your solution!

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 21, 2019, 3:09am UTC](https://discourse.processing.org/t/video-as-gl-texture-setup/11427/4 "2019-05-21T03:09:54Z")

</div>

B/c CodePen uses the “https://” scheme, any loadings have to use it as well in order to avert CORS access exceptions:

Change:  
‘[http://CommonDataStorage.GoogleApis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4](http://CommonDataStorage.GoogleApis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4)’

To:  
‘[https://CommonDataStorage.GoogleApis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4](https://CommonDataStorage.GoogleApis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4)’

Also, you can delete the 2nd `sk.texture(sk.vid);` statement.

---

<div class="post-metadata">

**Author:** ![jedierikb](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jedierikb/32/5268_2.png) [@jedierikb](https://discourse.processing.org/u/jedierikb)\
**Post date:** [May 21, 2019, 12:28pm UTC](https://discourse.processing.org/t/video-as-gl-texture-setup/11427/5 "2019-05-21T12:28:41Z")

</div>

A note on documentation -

> **[processing/p5.js](https://github.com/processing/p5.js/wiki/Getting-started-with-WebGL-in-p5)**
>
> p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Proces...

says  
_Loading images for texturing inside the preload() method is generally a best practice, but it is especially helpful when working with video since video files are generally larger than static images and can take therefore extra time to load._

But, as my first attempt demonstrates, I was not able to use preload. Is the documentation out of date or is there a different way to use preload for video effectively in this situation? Thanks!
